Help creating json body dynamically

Hi guys,

This would usually be pretty simple if I were coding this but I’m having trouble wrapping my head around how to dynamically create a beehiiv post.

This is what the payload looks like in the “run code” block I have:

payload = {
    "title": "Newsletter Title",
    "subtitle": "Newsletter Subtitle",
    "blocks": [
        {
            "type": "heading",
            "level": "2",
            "text": "This is my block!!!",
            "anchorHeader": False,
            "anchorIncludeInToc": False,
        },
        {
            "type": "image",
            "imageUrl": "https://cdn.britannica.com/89/164789-050-D6B5E2C7/Barack-Obama-2012.jpg",
            "alt_text": "A picture of Barry Obama",
            "caption": "One Cool President",
            "captionAlignment": "center",
            "imageAlignment": "right",
            "title": "Barry O",
            "url": "https://www.whitehouse.gov/",
            "width": 75
        },
        {
            "type": "list",
            "items": ["g", "h", "i"],
            "listType": "unordered",
            "startNumber": 4
        },
        {
            "type": "paragraph",
            "formattedText": [
                {
                    "text": "Read the full story ",
                    "styling": ["italic"]
                },
                {
                    "text": "here",
                    "href": "/google.com",
                    "target": "_blank"
                    "styling": ["italic"]
                }
            ]
        },
    ],
    # ... 4 more
}

In my flow, I will eventually have 5 sets of the above blocks.

How would you advise to build a flow for such an output?

Thanks

Hey @mutty! If you’re reporting an issue with a flow or an error in a run, please include the run link and make sure it’s shareable so we can take a look.

  1. Find your run link on the history page. Format: https://www.gumloop.com/pipeline?run_id={your_run_id}&workbook_id={workbook_id}

  2. Make it shareable by clicking “Share” → ‘Anyone with the link can view’ in the top-left corner of the flow screen.
    GIF guide

  3. Provide details about the issue—more context helps us troubleshoot faster.

You can find your run history here: https://www.gumloop.com/history

Hey @mutty – I think the best option here would be to have AI (using the Ask AI) node to generate these blocks for you for each section. You can specify the exact format and then you can pass those blocks as inputs to your Run Code node or a Custom Node that can format them in the payload and send it to Beehiiv.

Let me know if this works for you. If you’ve the right set of prompts and a decent model like Claude 3.7 or GPT 4o this should work pretty well.

1 Like

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