Create notion page blocks from AI response

New user migrating from Make.

I feel like I’m just missing something between the 2 applications (make and n8n)

workflow:
I make a AI agent output response as notion block API compliant. This responds with an array of blocks. I set the block option to the expression and I pass the array of blocks but I always get this error:

Bad request - please check your parameters
This version of the API does not support this type of block type. Please upgrade your API version.

Seems like this is a simple fix, there has to be a template, I just can’t find it. Since I’m new to n8n, I don’t know how to format community topics properly. I’m sure many people encounter the problem of adding notion page content, so if you know how to do this, please help.

I will provide more information for my workflow if need, but I think someone in this community has solved this alreay.

You’re leaving make for n8n? Nice. Are you using the AI agent to actually do the tool call and create the block? And are you able to create a simple block with the API normally, bc your getting a permissons/auth issues.

The agent just outputs the array of json object blocks formatted for the notion API. Make could read the full array of json and make the page content. But n8n does not.

I figured it out, all I have to do it set the block name as the block type and set the text to the content.

This is my agent output:

[
    {
        "object": "block",
        "type": "heading_2",
        "heading_2": {
            "rich_text": [
                {
                    "type": "text",
                    "text": {
                        "content": "Overview"
                    }
                }
            ]
        }
    },
    {
        "object": "block",
        "type": "paragraph",
        "paragraph": {
            "rich_text": [
                {
                    "type": "text",
                    "text": {
                        "content": "Cornell University offers one of the leading architecture..."
                    }
                }
            ]
        }
    },
    {
        "object": "block",
        "type": "heading_2",
        "heading_2": {
            "rich_text": [
                {
                    "type": "text",
                    "text": {
                        "content": "Location"
                    }
                }
            ]
        }
    },
    {
        "object": "block",
        "type": "paragraph",
        "paragraph": {
            "rich_text": [
                {
                    "type": "text",
                    "text": {
                        "content": "Cornell University is located in Ithaca, New York, USA..."
                    }
                }
            ]
        }
    }
]

As you can see, I need to loop through the blocks and it should work. This example shows how it will make the type of block and the content.

All I have to do is tell the agent to output a notion api block format, but only include the type and content of the block, then loop over the array of blocks and it should work. If the output is messed up, I might just output the full array and then use a module to parse the json objects.

I need to learn:

  1. looping
  2. parsing
1 Like

This is how to properly format content for a Notion page.

In the user message for AI message model, you must format the output to use the Notion Block API, and also give an example of the json output with only the parts you need, which is only type and content

The output will be used to create Notion page blocks using the notion Block API. Use all possible blocks that are available from the Notion Block API. If using a bullet list, remember that each item is a type=bulleted_list_item, it is not all bullets in one list

Example output, an array of objects
[
{"type":"heading_2", "content":"Overview"},
{"type":"paragraph", "content":"This college...."},
...
]

Then using the code node, convert the message content into an array of json objects. Then use the Notion Append Block node to make all the blocks

Resulting Notion Page

1 Like

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