Issue merging Notion Page Titles (getAll: databasePage) + Blocks (getAll: blocks)

Hi everyone :wave:

I’m working on a Notion automation with n8n, and I’m stuck trying to merge page titles with their content.

:mag: Context
I successfully retrieve all pages from a Notion database (each with an id and a property_nom as title).

Then, for each page, I get its content blocks (paragraphs) using getAll: block.

So I have:

A list of pages with id and title

A list of blocks with root_id and content

:x: What I can’t manage to do
I’d like to merge these two so that for each block I get its associated page title, and format the output like this:

Page 1  
Content 1.1

Page 1  
Content 1.2

Page 2  
Content 2

I tried:

The Merge node (Combine, SQL Query…)

A Code node with $input.all(), but I’m getting stuck with input types and structure.

:technologist: What would help me:
A working Code node to do the merge

Or a way to use Merge → SQL with matching id / root_id

Or any clean workaround :blush:

Thanks a lot in advance :pray:

Hi @Luc_Mandula Welcome to n8n :n8n: community :tada:

Without a sample workflow or more details about what you’re trying to achieve—and the errors you’re encountering—it’s a bit difficult to provide specific help.

Could you share a sample of your current workflow and maybe a small snippet of the data you’re working with? That would help a lot!

1 Like

Hello @mohamed3nan, thank you very much for your help!

Here I get the data at the page level of my Notion DB (title):

Page 1
Page 2
Page 3

Here I get the content of each page of my Notion DB (content):

Content 1.1
Content 1.2
Content 2

I would like to obtain this result with the merge module or any other module :

Page 1  
Content 1.1

Page 1  
Content 1.2

Page 2  
Content 2

This is what my current workflow looks like:

Okay, I think the trick is in the Merge node.
You need to use it in Combine mode, set the matching fields, and enable Fields to Match Have Different Names
Then, enter your fields (id, parent_id)

I think you need to configure it like this:

2 Likes

@mohamed3nan it worked thanks!

However I don’t understand why it works with ‘Fixed’, but not with ‘Expressions.’

Anyways, thanks!

1 Like

Glad it works!

Because we are referring to the input field name directly, we didn’t use an expression,
However, if you want to use an expression, you can use {{ $json.id }} and {{ $json.parent_id }}

This topic was automatically closed 7 days after the last reply. New replies are no longer allowed.