Notion Page Title Content to Synced Block

Hi,

I’m hoping someone may have solved a similar problem before.

I’m trying to add a synced block to a Notion Page and add the content of the page title to that synced block.

The page title contains both text and page mentions. I used an iterate to pull the bundles within the array for the page title and then aggregated them so that I’m only creating 1 synced block when I make the API call.

However, I get an error if the first bundle in the array does not contain a page mention ID (if the bundle contains text) or does not contain text content (if the bundle contains a mention). I’m not sure if there’s a way to add error handling or filters to solve this.

The outcome I’m looking for is to have 1 synced block that contains the content of the page title. The page title contains both text and page mentions.

Any help is greatly appreciated!

Body of the API Call:

{
    "children": [
        {
            "object": "block",
            "type": "synced_block",
            "synced_block": {
                "synced_from": null,
                "children": [
                    {
                        "type": "paragraph",
                        "paragraph": {
                            "rich_text": [
                                {
                                    "type": "text",
                                    "text": {
                                        "content": "{{6.array[].text.content}}"
                                    }
                                },
                                {
                                    "type": "mention",
                                    "mention": {
                                        "type": "page",
                                        "page": {
                                            "id": "{{6.array[].mention.page.id}}"
                                        }
                                    }
                                }
                            ]
                        }
                    }
                ]
            }
        }
    ]
}