Creating header and paragraph blocks in notion update content

I’m making a scenario for research using Notion and OpenAI. Problem is the markdown output from OpenAI doesn’t work with Notion paragraph block.

Steps:

  1. Get database item from Notion. Use the name property as output to a openAI prompt.
  2. Format the output from openAI to json.
  3. Use the json parser to create a bundle object
  4. use iterator to cycle through the bundle objects. Each object has a header and content key
  5. notion > for each header key make a header_h2 block and for each content key make a paragraph block

Output from the iterator

This is where I’m stuck. How do I map notion to make a header block and paragraph block.

Note this is a condensed output, when I get this working I will have many more objects

Thanks in advance

I solved it. No iterator needed. The solution is the way you format the output of OpenAI.

Here is an example OpenAIprompt:
"
You are an expert research assistant tasked with providing detailed information about a specific architectural college. The college to research is [INSERT COLLEGE NAME HERE].. Gather comprehensive details that would be essential for a prospective student evaluating the institution for undergraduate or graduate architecture programs. Include the following:

  1. Overview: A brief description of the college, its architecture program, and its reputation in the field.
  2. Location: The city, state (if applicable), and country, along with a note on the campus environment (urban, suburban, rural).
  3. Programs Offered: Details on undergraduate and graduate architecture programs (e.g., B.Arch, M.Arch, Ph.D.), including program duration and specializations (e.g., sustainable design, urban planning).
  4. Admissions: Key admission requirements (e.g., portfolio, GPA, standardized tests like SAT/ACT or GRE), application deadlines, and acceptance rates (if available).

Output Requirement: Structure the response in JSON format, with clear keys corresponding to the requested categories (e.g., “overview”, “location”, “programs_offered”). Ensure the JSON is properly formatted, concise, and includes all requested details. If any information is missing, include a note under the relevant key (e.g., “Data not publicly available”).

Example Output format:
{“data”:[ {
“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”: “The University of California, Los Angeles (UCLA) is a prestigious public research university…”
}
}
]
}
}
]}
"
End of prompt

Better visual of the forced formatting of output

{"data":[  {
    "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": "The University of California, Los Angeles (UCLA) is a prestigious public research university..."
          }
        }
      ]
    }
  }
]}

Use the JSON parser on the OpenAI result which will output a single bundle with data

Use the json parser output data in notion append page content module

Resulting Notion page

1 Like

Upon working with this further I learned that openAI is fully aware of the notion block api and can format a json output will all the block types.

Prompt update:
required output is json formatted for the Notion block api. Use appropriate blocks for the best viewing and formatting for a notion page. Use any of the blocks like header_2, paragraph, bullets, etc..