Notion update: databasePage Error message when using Rich Text,texts is not iterable

Notion update: databasePage Error message when using Rich Text,texts is not iterable

Code node

const rawText = $input.first().json.choices[0].message.content;
const matches = rawText.match(/(\d+).\s*[^::]+[::]\s*[^0-9]+(?=\d+.|$)/g);
const richTexts = matches.map(text => ({
type: ‘text’,
text: { content: text.trim() },
annotations: {
bold: false,
italic: false,
strikethrough: false,
underline: false,
code: false,
color: ‘default’
}
}));
const result = matches.map(text => text.trim()).join(‘\n’);
return [{ json: { texts: richTexts, result } }];

Output content

`[
{
“texts”:
[
{
“type”:
“text”,
“text”:
{
“content”:
“1. 英语(English): How can high-quality mineral water be mass-produced? A comprehensive process analysis from water selection to bottling.”
},
“annotations”:
{
“bold”:
false,
“italic”:
false,
“strikethrough”:
false,
“underline”:
false,
“code”:
false,
“color”:
“default”
}
},
{
“type”:
“text”,
“text”:
{
“content”:
“2. 中文繁体(Traditional Chinese): 如何大量製造高品質礦泉水?從選水到灌裝的完整流程解析。”
},
“annotations”:
{
“bold”:
false,
“italic”:
false,
“strikethrough”:
false,
“underline”:
false,
“code”:
false,
“color”:
“default”
}
},
{
“type”:
“text”,
“text”:
{
“content”:
“3. 印地语(Hindi): उच्च गुणवत्ता वाली खनिज जल को बड़े पैमाने पर कैसे उत्पादित करें? पानी के चयन से बोतलबंदी तक पूरी प्रक्रिया का विश्लेषण।”
},
“annotations”:
{
“bold”:
false,
“italic”:
false,
“strikethrough”:
false,
“underline”:
false,
“code”:
false,
“color”:
“default”
}
},

{
“type”:
“text”,
“text”:
{
“content”:
“4. 西班牙语(Spanish): ¿Cómo producir en masa agua mineral de alta calidad?”
},
“annotations”:
{
“bold”:
false,
“italic”:
false,
“strikethrough”:
false,
“underline”:
false,
“code”:
false,
“color”:
“default”
}
}
],
“result”:
“1. 英语(English): How can high-quality mineral water be mass-produced? A comprehensive process analysis from water selection to bottling.\n2. 中文繁体(Traditional Chinese): 如何大量製造高品質礦泉水?從選水到灌裝的完整流程解析。\n3. 印地语(Hindi): उच्च गुणवत्ता वाली खनिज जल को बड़े पैमाने पर कैसे उत्पादित करें? पानी के चयन से बोतलबंदी तक पूरी प्रक्रिया का विश्लेषण।\n4. 西班牙语(Spanish): ¿Cómo producir en masa agua mineral de alta calidad?”
}

Notion types are heading_1, heading_2, paragraph etc…

In the AI system message, specify the you are want output formatted to the Notion Block API.
Works for basic formatting like headers, paragraphs and bullets. You have to added additional output requirements for n8n because all you need is type and content.

Use this for your output:

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…”},

]

This will still need to format into an array of json object. Notion will make each block for you.

Your method can only be implemented in columns with attribute names, but I want to achieve this in other columns. Therefore, I tried to use Rich Text, but encountered an issue and received an error.

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