Combine Notion page content into a single string

Hi everyone,

I would like to extract all page content from a Notion page, and if the content is in the form of text (toggle heading, heading, paragraph, numbered list, etc.), I want to combine it (in correct sequence) and put it into a property.

The problem is that Make is showing me each of the different block types like this:

So basically, for each block type, it’s storing the content in an array with a different name (heading 1, heading 2, paragraph, etc.). How can I get just the content of the block out regardless of the type (+ all children of the blocks regardless of how many children the block has and if the child block has children block.

I am using a custom API call to retrieve page children: /v1/blocks/{{12.id}}/children.

Output of the API call is attached.
Notion Page Content.json (21.3 KB)

Try something like this

You can replace “List Page Contents” with an Iterator module with the “results” variable.

Or you could just use the “List Page Contents” module, because it has an interface with all the possible fields available for you to easily map:

3 Likes

Thanks @samliew. This got me closer.

The problem occurs when there are multiple blocks of the same type, for example multiple paragraphs. Any thoughts on how to address this? The Collection you are seeing are paragraphs.

Scratch that - I got this working. However, the problem I am having that only the top level blocks are pulled in, excluding the children blocks (see Toggle Heading 1 - it has child content)
image

You’ll need to recurse through each of the child’s blocks to get the child content blocks to get the block content.

Here are some examples of scenarios calling itself again with the children IDs to get children item details. While they are not “Notion” – the same concept applies to begin a scenario with a Webhook, which you can pass additional details about the current item you want to get the children content for, using the HTTP module.

3 Likes