Get Notion DB Page content not justDB properties

Hmmm weirdo …
Add me full access Ill add my integration to your notion page and will check if it will accure problem on my instance them. Maybe it’s sth with notion

Just sent it. Lmk if you can access it

1 Like

Cannot get access from n8n

@MutedJam Do you maybe see why n8n could say items not defined ?

Could it be because the Function Item node is being used here instead of the Function node?

The Function Item node would run once for each item and you’d reference the current item via item rather than items.

If you need to pull in multiple items in the Function Item node you could consider using something like $items("Node Name") in your code (replacing Node Name with the name of the node you want to fetch items from).

@MutedJam thanks for the reply. Tried this

let result = [];

$items("Read page content").map(i => {
  i.json.property_property.map(channels => {
    result.push(
      {
        json: {
          channels: channel,
          name: i.json.name
        }
      }
    )

    return channel;
  })
  
  return i;
})

return result

Error is: ERROR: Cannot read properties of undefined (reading ‘map’) [Line 4]

Details

Stack

TypeError: Cannot read properties of undefined (reading 'map')
    at C:\Users\poori\AppData\Local\Programs\n8n\resources\app\node_modules\n8n-nodes-base\dist\nodes\Function:4:28
    at BaseHandler.apply (C:\Users\poori\AppData\Local\Programs\n8n\resources\app\node_modules\vm2\lib\bridge.js:479:11)
    at Array.map (<anonymous>)
    at BaseHandler.apply (C:\Users\poori\AppData\Local\Programs\n8n\resources\app\node_modules\vm2\lib/bridge.js:479:11)
    at C:\Users\poori\AppData\Local\Programs\n8n\resources\app\node_modules\n8n-nodes-base\dist\nodes\Function:3:29
    at C:\Users\poori\AppData\Local\Programs\n8n\resources\app\node_modules\n8n-nodes-base\dist\nodes\Function:21:2
    at BaseHandler.apply (C:\Users\poori\AppData\Local\Programs\n8n\resources\app\node_modules\vm2\lib\bridge.js:479:11)
    at NodeVM.run (C:\Users\poori\AppData\Local\Programs\n8n\resources\app\node_modules\vm2\lib\nodevm.js:425:23)
    at Object.execute (C:\Users\poori\AppData\Local\Programs\n8n\resources\app\node_modules\n8n-nodes-base\dist\nodes\Function\Function.node.js:96:31)
    at Workflow.runNode (C:\Users\poori\AppData\Local\Programs\n8n\resources\app\node_modules\n8n-workflow\dist\src\Workflow.js:594:51)

Function

Execute node

Parameters


Docs

JavaScript Code

1

2

3

4

5

6

7

8

9

10

11

12

13

14

15

16

17

18

19

20

let result = [];

$items("Read page content").map(i => {
  i.json.property_property.map(channels => {
    result.push(
      {
        json: {
          channels: channel,
          name: i.json.name
        }
      }
    )

    return channel;
  })
  
  return i;
})

return result

I wish this node would…

Problem executing workflow

There was a problem executing the workflow:
“Cannot read properties of undefined (reading ‘map’) [Line 4]”

It’s based on the notion DBs here I just need to switch the path based on the chosen Channel from the relation property

Hey @pooria, I think Function Item and Function is still being mixed up here. Function Item handles individual items and would also return a single item.

You’re however trying to return an array of items from the looks of it which is something you’d do in the Function node instead.

So in a first step you want to get rid of your Function Item node and use a Function node instead. You can then access items as suggested by @Shirobachi above.

As for the individual properties of your items I couldn’t see property_property in your screenshots. Can you confirm the exact JSON data you’re sending to your Function node if you’re still facing any trouble after switching to the Function node?

@MutedJam

This is the output from the last Notion node “Read Page Content”:

[
{
"object": "block",
"parent_id": "1f1aa79b-1824-4d52-ba7b-da164812b38e",
"id": "e77bce77-3069-4504-af36-25a41e01dddc",
"parent": {
"type": "page_id",
"page_id": "1f1aa79b-1824-4d52-ba7b-da164812b38e"
},
"created_time": "2022-07-02T16:53:00.000Z",
"last_edited_time": "2022-07-02T16:53:00.000Z",
"created_by": {
"object": "user",
"id": "f88037ff-f284-4448-a98e-b19e6fa623a2"
},
"last_edited_by": {
"object": "user",
"id": "f88037ff-f284-4448-a98e-b19e6fa623a2"
},
"has_children": false,
"archived": false,
"type": "paragraph",
"paragraph": {
"color": "default",
"text": [
{
"type": "text",
"text": {
"content": "this is a youtube video caption ",
"link": null
},
"annotations": {
"bold": false,
"italic": false,
"strikethrough": false,
"underline": false,
"code": false,
"color": "default"
},
"plain_text": "this is a youtube video caption ",
"href": null
}
]
}
},
{
"object": "block",
"parent_id": "1f1aa79b-1824-4d52-ba7b-da164812b38e",
"id": "7f3be61e-e796-46ae-9e30-0799b12d888b",
"parent": {
"type": "page_id",
"page_id": "1f1aa79b-1824-4d52-ba7b-da164812b38e"
},
"created_time": "2022-07-02T16:53:00.000Z",
"last_edited_time": "2022-07-02T16:54:00.000Z",
"created_by": {
"object": "user",
"id": "f88037ff-f284-4448-a98e-b19e6fa623a2"
},
"last_edited_by": {
"object": "user",
"id": "f88037ff-f284-4448-a98e-b19e6fa623a2"
},
"has_children": false,
"archived": false,
"type": "video",
"video": {
"caption": [
],
"type": "file",
"file": {
"url": "https://s3.us-west-2.amazonaws.com/secure.notion-static.com/f9bb2b6c-2da3-465e-aae4-c21d6e223430/2_MetaDads_Beer_1_250.mp4?X-Amz-Algorithm=AWS4-HMAC-SHA256&X-Amz-Content-Sha256=UNSIGNED-PAYLOAD&X-Amz-Credential=AKIAT73L2G45EIPT3X45%2F20220705%2Fus-west-2%2Fs3%2Faws4_request&X-Amz-Date=20220705T052121Z&X-Amz-Expires=3600&X-Amz-Signature=73c6c41073b8c8a37c44d85ae0123dce844cfe8a33d6941deee8d99f73055a3e&X-Amz-SignedHeaders=host&x-id=GetObject",
"expiry_time": "2022-07-05T06:21:21.757Z"
}
}
},
{
"object": "block",
"parent_id": "1f1aa79b-1824-4d52-ba7b-da164812b38e",
"id": "654c053a-9f86-4010-8cc1-e4ee37868a43",
"parent": {
"type": "page_id",
"page_id": "1f1aa79b-1824-4d52-ba7b-da164812b38e"
},
"created_time": "2022-07-02T16:53:00.000Z",
"last_edited_time": "2022-07-02T16:53:00.000Z",
"created_by": {
"object": "user",
"id": "f88037ff-f284-4448-a98e-b19e6fa623a2"
},
"last_edited_by": {
"object": "user",
"id": "f88037ff-f284-4448-a98e-b19e6fa623a2"
},
"has_children": false,
"archived": false,
"type": "paragraph",
"paragraph": {
"color": "default",
"text": [
]
}
},
{
"object": "block",
"parent_id": "f0844d46-aae0-4e69-908d-094169352ab1",
"id": "708d6f04-1c68-45ce-865d-d712c84bfa02",
"parent": {
"type": "page_id",
"page_id": "f0844d46-aae0-4e69-908d-094169352ab1"
},
"created_time": "2022-07-02T16:52:00.000Z",
"last_edited_time": "2022-07-02T16:52:00.000Z",
"created_by": {
"object": "user",
"id": "f88037ff-f284-4448-a98e-b19e6fa623a2"
},
"last_edited_by": {
"object": "user",
"id": "f88037ff-f284-4448-a98e-b19e6fa623a2"
},
"has_children": false,
"archived": false,
"type": "paragraph",
"paragraph": {
"color": "default",
"text": [
{
"type": "text",
"text": {
"content": "CAPTION OF THE Linkedin post is here #hashtag #hashtag1",
"link": null
},
"annotations": {
"bold": false,
"italic": false,
"strikethrough": false,
"underline": false,
"code": false,
"color": "default"
},
"plain_text": "CAPTION OF THE Linkedin post is here #hashtag #hashtag1",
"href": null
}
]
}
},
{
"object": "block",
"parent_id": "f0844d46-aae0-4e69-908d-094169352ab1",
"id": "c0265096-d37b-40c1-9605-b96e8c37d9a3",
"parent": {
"type": "page_id",
"page_id": "f0844d46-aae0-4e69-908d-094169352ab1"
},
"created_time": "2022-07-02T16:52:00.000Z",
"last_edited_time": "2022-07-02T16:52:00.000Z",
"created_by": {
"object": "user",
"id": "f88037ff-f284-4448-a98e-b19e6fa623a2"
},
"last_edited_by": {
"object": "user",
"id": "f88037ff-f284-4448-a98e-b19e6fa623a2"
},
"has_children": false,
"archived": false,
"type": "image",
"image": {
"caption": [
],
"type": "file",
"file": {
"url": "https://s3.us-west-2.amazonaws.com/secure.notion-static.com/0330e401-6cd7-46a4-a93c-93dd65502c1f/DSC_1608.jpg?X-Amz-Algorithm=AWS4-HMAC-SHA256&X-Amz-Content-Sha256=UNSIGNED-PAYLOAD&X-Amz-Credential=AKIAT73L2G45EIPT3X45%2F20220705%2Fus-west-2%2Fs3%2Faws4_request&X-Amz-Date=20220705T052121Z&X-Amz-Expires=3600&X-Amz-Signature=249febf0cc2c03cc8f8e2df51de6289730930eec97929d5aea64ee40007c53d0&X-Amz-SignedHeaders=host&x-id=GetObject",
"expiry_time": "2022-07-05T06:21:21.856Z"
}
}
},
{
"object": "block",
"parent_id": "f0844d46-aae0-4e69-908d-094169352ab1",
"id": "fdbb1281-d740-4803-a85f-4b8b4d21e81c",
"parent": {
"type": "page_id",
"page_id": "f0844d46-aae0-4e69-908d-094169352ab1"
},
"created_time": "2022-07-02T16:52:00.000Z",
"last_edited_time": "2022-07-02T16:52:00.000Z",
"created_by": {
"object": "user",
"id": "f88037ff-f284-4448-a98e-b19e6fa623a2"
},
"last_edited_by": {
"object": "user",
"id": "f88037ff-f284-4448-a98e-b19e6fa623a2"
},
"has_children": false,
"archived": false,
"type": "paragraph",
"paragraph": {
"color": "default",
"text": [
]
}
},
{
"object": "block",
"parent_id": "36533ba7-acf7-414d-8aaf-6f1884a0cf4a",
"id": "bb7520c2-1e2e-471f-902d-8002255d0e74",
"parent": {
"type": "page_id",
"page_id": "36533ba7-acf7-414d-8aaf-6f1884a0cf4a"
},
"created_time": "2022-07-02T14:59:00.000Z",
"last_edited_time": "2022-07-02T16:52:00.000Z",
"created_by": {
"object": "user",
"id": "f88037ff-f284-4448-a98e-b19e6fa623a2"
},
"last_edited_by": {
"object": "user",
"id": "f88037ff-f284-4448-a98e-b19e6fa623a2"
},
"has_children": false,
"archived": false,
"type": "paragraph",
"paragraph": {
"color": "default",
"text": [
{
"type": "text",
"text": {
"content": "CAPTION OF THE instagram post is here #hashtag #hashtag1",
"link": null
},
"annotations": {
"bold": false,
"italic": false,
"strikethrough": false,
"underline": false,
"code": false,
"color": "default"
},
"plain_text": "CAPTION OF THE instagram post is here #hashtag #hashtag1",
"href": null
}
]
}
},
{
"object": "block",
"parent_id": "36533ba7-acf7-414d-8aaf-6f1884a0cf4a",
"id": "3e0c0597-6736-4110-871c-cec02575eb78",
"parent": {
"type": "page_id",
"page_id": "36533ba7-acf7-414d-8aaf-6f1884a0cf4a"
},
"created_time": "2022-07-02T16:52:00.000Z",
"last_edited_time": "2022-07-02T16:52:00.000Z",
"created_by": {
"object": "user",
"id": "f88037ff-f284-4448-a98e-b19e6fa623a2"
},
"last_edited_by": {
"object": "user",
"id": "f88037ff-f284-4448-a98e-b19e6fa623a2"
},
"has_children": false,
"archived": false,
"type": "image",
"image": {
"caption": [
],
"type": "file",
"file": {
"url": "https://s3.us-west-2.amazonaws.com/secure.notion-static.com/0330e401-6cd7-46a4-a93c-93dd65502c1f/DSC_1608.jpg?X-Amz-Algorithm=AWS4-HMAC-SHA256&X-Amz-Content-Sha256=UNSIGNED-PAYLOAD&X-Amz-Credential=AKIAT73L2G45EIPT3X45%2F20220705%2Fus-west-2%2Fs3%2Faws4_request&X-Amz-Date=20220705T052121Z&X-Amz-Expires=3600&X-Amz-Signature=249febf0cc2c03cc8f8e2df51de6289730930eec97929d5aea64ee40007c53d0&X-Amz-SignedHeaders=host&x-id=GetObject",
"expiry_time": "2022-07-05T06:21:21.955Z"
}
}
},
{
"object": "block",
"parent_id": "36533ba7-acf7-414d-8aaf-6f1884a0cf4a",
"id": "5558d714-2dfb-4754-b536-f1506760d51c",
"parent": {
"type": "page_id",
"page_id": "36533ba7-acf7-414d-8aaf-6f1884a0cf4a"
},
"created_time": "2022-07-02T15:00:00.000Z",
"last_edited_time": "2022-07-02T15:00:00.000Z",
"created_by": {
"object": "user",
"id": "f88037ff-f284-4448-a98e-b19e6fa623a2"
},
"last_edited_by": {
"object": "user",
"id": "f88037ff-f284-4448-a98e-b19e6fa623a2"
},
"has_children": false,
"archived": false,
"type": "paragraph",
"paragraph": {
"color": "default",
"text": [
]
}
},
{
"object": "block",
"parent_id": "54540a0e-a4c4-4302-9e6e-8cd88f1f2fa4",
"id": "354bc29c-d9dc-407f-933b-4c89ec667d34",
"parent": {
"type": "page_id",
"page_id": "54540a0e-a4c4-4302-9e6e-8cd88f1f2fa4"
},
"created_time": "2022-07-01T22:13:00.000Z",
"last_edited_time": "2022-07-02T14:59:00.000Z",
"created_by": {
"object": "user",
"id": "f88037ff-f284-4448-a98e-b19e6fa623a2"
},
"last_edited_by": {
"object": "user",
"id": "f88037ff-f284-4448-a98e-b19e6fa623a2"
},
"has_children": false,
"archived": false,
"type": "paragraph",
"paragraph": {
"color": "default",
"text": [
{
"type": "text",
"text": {
"content": "Hello",
"link": null
},
"annotations": {
"bold": true,
"italic": false,
"strikethrough": false,
"underline": false,
"code": false,
"color": "default"
},
"plain_text": "Hello",
"href": null
},
{
"type": "text",
"text": {
"content": " world",
"link": null
},
"annotations": {
"bold": false,
"italic": false,
"strikethrough": false,
"underline": false,
"code": false,
"color": "default"
},
"plain_text": " world",
"href": null
}
]
}
}
]

And using function node this is the JS code:

let result = [];

$item("Read page content").map(i => {
  i.json.property_property.map(channels => {
    result.push(
      {
        json: {
          channels: channel,
          text: i.json.name
        }
      }
    )

    return channel;
  })
  
  return i;
})

return result

Property_property is there

Hey @pooria, there is no property_property in the data you have shared coming from your Read Page Content, so you will not be able to access property_property in your Javascript code.

I am not fully sure I can follow this conversation to be honest. Are you still just trying to read content of a Notion database page? This would be doable via the Block > Get Child Blocks operation of the Notion node and not require code:

@MutedJam that was the code @Shirobachi suggested - but to adapt to my properties.

Automation idea is here

Read page content from row in Content DB, switch path based on relation property (Channels): if Twitter is selected, follow Twitter path to post to Twitter, if Twitter AND LinkedIn is selected, follow Twitter and LinkedIn path.

And investigating how to pass markup (like bold, italic) to post on socials and detect media in page content.

Does that make sense? :grinning:

So I get that idea, but I am not entirely sure what the Function node would achieve here. Aren’t you getting the channel information from your Get Channels node already? If so, would it perhaps make sense to immediately have your Switch node follow the Get Channels node?

You can then fetch the blocks after the Switch node as needed and wouldn’t need to bother with writing code to read this information.

Either way, this will be a project with lots of trial and error. As you can see from the screenshot the annotations/formatting in Notion doesn’t match the format any of your social media channels expect. So it might be easier to focus on just plain text in a first step and work on formatting at a later stage.

True. Agree with starting with plain text.

What the initial problem was is how can I switch based on the channel? Because it is not a select property in notion but a relation. And I guess the switch should happen after getting the content because it knows what channel to post it in.

Specifically what to put in value 1:

Ah, so this would be extra tricky then, sorry. Since one row can be posted to multiple channels I don’t think the Switch logic would work out of the box here (if an item is already sent to output 0, it can not be sent to output 1 as well).

So it might be simpler to just build separate workflows for each channel (so have one workflow processing your Tweets, one processing Facebook posts, etc.). Then in each workflow query the database pages that contain the respective channel instead of using the Switch node in a single huge workflow. This query would work like so for relation fields:

In the JSON filter field of the above example, you’d need to replace Relation Field with the name of your field (Channels) and the ID 1eb4e243945f47a0ac7fd4861c591d2a with the ID of the respective Channel page in your Notion database (explained here).

You mfer @MutedJam that worked!! I don’t know how you did it. I learned how to use JSON with Notion.

Imma attempt the big boy workflow with the switch soon. For now baby steps :)))

1 Like

Last one here @MutedJam now that I am focusing on single channel (say Twitter now), what should I pass as “Text” in Twitter node?

Inside the page content there’s multiple blocks (paragraphs, image…) how do I pass them all in one text?

So this is a bit tricky and is probably the point where you will need a bit of custom code if you want to convert multiple blocks (which each are an item on their own in n8n) into a single tweet.

Can you share the JSON data you currently have and also describe how you’d like to transform them? E.g. do all your 12 blocks describe a single tweet? Or would these 12 blocks represent multiple tweets?

Hey @MutedJam this is the output from the last node:

[
   {
      "object":"block",
      "parent_id":"54540a0e-a4c4-4302-9e6e-8cd88f1f2fa4",
      "id":"354bc29c-d9dc-407f-933b-4c89ec667d34",
      "parent":{
         "type":"page_id",
         "page_id":"54540a0e-a4c4-4302-9e6e-8cd88f1f2fa4"
      },
      "created_time":"2022-07-01T22:13:00.000Z",
      "last_edited_time":"2022-07-02T14:59:00.000Z",
      "created_by":{
         "object":"user",
         "id":"f88037ff-f284-4448-a98e-b19e6fa623a2"
      },
      "last_edited_by":{
         "object":"user",
         "id":"f88037ff-f284-4448-a98e-b19e6fa623a2"
      },
      "has_children":false,
      "archived":false,
      "type":"paragraph",
      "paragraph":{
         "color":"default",
         "text":[
            {
               "type":"text",
               "text":{
                  "content":"Hello",
                  "link":null
               },
               "annotations":{
                  "bold":true,
                  "italic":false,
                  "strikethrough":false,
                  "underline":false,
                  "code":false,
                  "color":"default"
               },
               "plain_text":"Hello",
               "href":null
            },
            {
               "type":"text",
               "text":{
                  "content":" world",
                  "link":null
               },
               "annotations":{
                  "bold":false,
                  "italic":false,
                  "strikethrough":false,
                  "underline":false,
                  "code":false,
                  "color":"default"
               },
               "plain_text":" world",
               "href":null
            }
         ]
      }
   },
   {
      "object":"block",
      "parent_id":"54540a0e-a4c4-4302-9e6e-8cd88f1f2fa4",
      "id":"b73303bc-c1f9-4d51-9a85-1c3fd031da6d",
      "parent":{
         "type":"page_id",
         "page_id":"54540a0e-a4c4-4302-9e6e-8cd88f1f2fa4"
      },
      "created_time":"2022-07-01T22:26:00.000Z",
      "last_edited_time":"2022-07-01T22:26:00.000Z",
      "created_by":{
         "object":"user",
         "id":"f88037ff-f284-4448-a98e-b19e6fa623a2"
      },
      "last_edited_by":{
         "object":"user",
         "id":"f88037ff-f284-4448-a98e-b19e6fa623a2"
      },
      "has_children":false,
      "archived":false,
      "type":"paragraph",
      "paragraph":{
         "color":"default",
         "text":[
            
         ]
      }
   },
   {
      "object":"block",
      "parent_id":"54540a0e-a4c4-4302-9e6e-8cd88f1f2fa4",
      "id":"a5800282-c968-42a3-b547-55e86a009670",
      "parent":{
         "type":"page_id",
         "page_id":"54540a0e-a4c4-4302-9e6e-8cd88f1f2fa4"
      },
      "created_time":"2022-07-01T22:26:00.000Z",
      "last_edited_time":"2022-07-02T16:47:00.000Z",
      "created_by":{
         "object":"user",
         "id":"f88037ff-f284-4448-a98e-b19e6fa623a2"
      },
      "last_edited_by":{
         "object":"user",
         "id":"f88037ff-f284-4448-a98e-b19e6fa623a2"
      },
      "has_children":false,
      "archived":false,
      "type":"paragraph",
      "paragraph":{
         "color":"default",
         "text":[
            {
               "type":"text",
               "text":{
                  "content":"Lorem Ipsum",
                  "link":null
               },
               "annotations":{
                  "bold":false,
                  "italic":true,
                  "strikethrough":false,
                  "underline":false,
                  "code":false,
                  "color":"default"
               },
               "plain_text":"Lorem Ipsum",
               "href":null
            },
            {
               "type":"text",
               "text":{
                  "content":" has been the industry's standard dummy text ever since the 1500s,",
                  "link":null
               },
               "annotations":{
                  "bold":false,
                  "italic":false,
                  "strikethrough":false,
                  "underline":false,
                  "code":false,
                  "color":"default"
               },
               "plain_text":" has been the industry's standard dummy text ever since the 1500s,",
               "href":null
            }
         ]
      }
   },
   {
      "object":"block",
      "parent_id":"54540a0e-a4c4-4302-9e6e-8cd88f1f2fa4",
      "id":"1cfa4dc8-3471-46ff-9033-7e53978b263b",
      "parent":{
         "type":"page_id",
         "page_id":"54540a0e-a4c4-4302-9e6e-8cd88f1f2fa4"
      },
      "created_time":"2022-07-01T22:26:00.000Z",
      "last_edited_time":"2022-07-01T22:26:00.000Z",
      "created_by":{
         "object":"user",
         "id":"f88037ff-f284-4448-a98e-b19e6fa623a2"
      },
      "last_edited_by":{
         "object":"user",
         "id":"f88037ff-f284-4448-a98e-b19e6fa623a2"
      },
      "has_children":false,
      "archived":false,
      "type":"image",
      "image":{
         "caption":[
            
         ],
         "type":"external",
         "external":{
            "url":"https://images.unsplash.com/photo-1615986201152-7686a4867f30?ixlib=rb-1.2.1&q=80&cs=tinysrgb&fm=jpg&crop=entropy"
         }
      }
   },
   {
      "object":"block",
      "parent_id":"54540a0e-a4c4-4302-9e6e-8cd88f1f2fa4",
      "id":"8f089e06-b5ec-448d-914f-0bd2c918824f",
      "parent":{
         "type":"page_id",
         "page_id":"54540a0e-a4c4-4302-9e6e-8cd88f1f2fa4"
      },
      "created_time":"2022-07-02T16:47:00.000Z",
      "last_edited_time":"2022-07-02T16:47:00.000Z",
      "created_by":{
         "object":"user",
         "id":"f88037ff-f284-4448-a98e-b19e6fa623a2"
      },
      "last_edited_by":{
         "object":"user",
         "id":"f88037ff-f284-4448-a98e-b19e6fa623a2"
      },
      "has_children":false,
      "archived":false,
      "type":"divider",
      "divider":{
         
      }
   },
   {
      "object":"block",
      "parent_id":"54540a0e-a4c4-4302-9e6e-8cd88f1f2fa4",
      "id":"4c69a0b1-6b35-4d0f-850a-c54d5fbe179a",
      "parent":{
         "type":"page_id",
         "page_id":"54540a0e-a4c4-4302-9e6e-8cd88f1f2fa4"
      },
      "created_time":"2022-07-01T22:26:00.000Z",
      "last_edited_time":"2022-07-02T16:48:00.000Z",
      "created_by":{
         "object":"user",
         "id":"f88037ff-f284-4448-a98e-b19e6fa623a2"
      },
      "last_edited_by":{
         "object":"user",
         "id":"f88037ff-f284-4448-a98e-b19e6fa623a2"
      },
      "has_children":false,
      "archived":false,
      "type":"paragraph",
      "paragraph":{
         "color":"default",
         "text":[
            {
               "type":"text",
               "text":{
                  "content":"This is where the second tweet begins just after this divide: ",
                  "link":null
               },
               "annotations":{
                  "bold":false,
                  "italic":false,
                  "strikethrough":false,
                  "underline":false,
                  "code":false,
                  "color":"default"
               },
               "plain_text":"This is where the second tweet begins just after this divide: ",
               "href":null
            }
         ]
      }
   },
   {
      "object":"block",
      "parent_id":"54540a0e-a4c4-4302-9e6e-8cd88f1f2fa4",
      "id":"c3e15d77-2b93-4b61-b30b-59e842b7ea5b",
      "parent":{
         "type":"page_id",
         "page_id":"54540a0e-a4c4-4302-9e6e-8cd88f1f2fa4"
      },
      "created_time":"2022-07-02T16:48:00.000Z",
      "last_edited_time":"2022-07-02T16:48:00.000Z",
      "created_by":{
         "object":"user",
         "id":"f88037ff-f284-4448-a98e-b19e6fa623a2"
      },
      "last_edited_by":{
         "object":"user",
         "id":"f88037ff-f284-4448-a98e-b19e6fa623a2"
      },
      "has_children":false,
      "archived":false,
      "type":"bulleted_list_item",
      "bulleted_list_item":{
         "color":"default",
         "text":[
            {
               "type":"text",
               "text":{
                  "content":"Bullet 1 ",
                  "link":null
               },
               "annotations":{
                  "bold":false,
                  "italic":false,
                  "strikethrough":false,
                  "underline":false,
                  "code":false,
                  "color":"default"
               },
               "plain_text":"Bullet 1 ",
               "href":null
            }
         ]
      }
   },
   {
      "object":"block",
      "parent_id":"54540a0e-a4c4-4302-9e6e-8cd88f1f2fa4",
      "id":"95b277b8-faac-4047-9a7f-3ac599873bc6",
      "parent":{
         "type":"page_id",
         "page_id":"54540a0e-a4c4-4302-9e6e-8cd88f1f2fa4"
      },
      "created_time":"2022-07-02T16:48:00.000Z",
      "last_edited_time":"2022-07-02T16:48:00.000Z",
      "created_by":{
         "object":"user",
         "id":"f88037ff-f284-4448-a98e-b19e6fa623a2"
      },
      "last_edited_by":{
         "object":"user",
         "id":"f88037ff-f284-4448-a98e-b19e6fa623a2"
      },
      "has_children":false,
      "archived":false,
      "type":"bulleted_list_item",
      "bulleted_list_item":{
         "color":"default",
         "text":[
            {
               "type":"text",
               "text":{
                  "content":"Bullet 2",
                  "link":null
               },
               "annotations":{
                  "bold":false,
                  "italic":false,
                  "strikethrough":false,
                  "underline":false,
                  "code":false,
                  "color":"default"
               },
               "plain_text":"Bullet 2",
               "href":null
            }
         ]
      }
   },
   {
      "object":"block",
      "parent_id":"54540a0e-a4c4-4302-9e6e-8cd88f1f2fa4",
      "id":"db6d122c-27f8-462e-a1ab-06df533d1364",
      "parent":{
         "type":"page_id",
         "page_id":"54540a0e-a4c4-4302-9e6e-8cd88f1f2fa4"
      },
      "created_time":"2022-07-02T16:48:00.000Z",
      "last_edited_time":"2022-07-02T16:48:00.000Z",
      "created_by":{
         "object":"user",
         "id":"f88037ff-f284-4448-a98e-b19e6fa623a2"
      },
      "last_edited_by":{
         "object":"user",
         "id":"f88037ff-f284-4448-a98e-b19e6fa623a2"
      },
      "has_children":false,
      "archived":false,
      "type":"bulleted_list_item",
      "bulleted_list_item":{
         "color":"default",
         "text":[
            {
               "type":"text",
               "text":{
                  "content":"Bullet 3",
                  "link":null
               },
               "annotations":{
                  "bold":false,
                  "italic":false,
                  "strikethrough":false,
                  "underline":false,
                  "code":false,
                  "color":"default"
               },
               "plain_text":"Bullet 3",
               "href":null
            }
         ]
      }
   },
   {
      "object":"block",
      "parent_id":"54540a0e-a4c4-4302-9e6e-8cd88f1f2fa4",
      "id":"d1702323-ff42-4501-93b6-13d8100d9239",
      "parent":{
         "type":"page_id",
         "page_id":"54540a0e-a4c4-4302-9e6e-8cd88f1f2fa4"
      },
      "created_time":"2022-07-02T16:48:00.000Z",
      "last_edited_time":"2022-07-02T16:48:00.000Z",
      "created_by":{
         "object":"user",
         "id":"f88037ff-f284-4448-a98e-b19e6fa623a2"
      },
      "last_edited_by":{
         "object":"user",
         "id":"f88037ff-f284-4448-a98e-b19e6fa623a2"
      },
      "has_children":false,
      "archived":false,
      "type":"divider",
      "divider":{
         
      }
   }
][
   {
      "object":"block",
      "parent_id":"54540a0e-a4c4-4302-9e6e-8cd88f1f2fa4",
      "id":"d1ae2758-d72e-42f2-b224-a648deca3ff2",
      "parent":{
         "type":"page_id",
         "page_id":"54540a0e-a4c4-4302-9e6e-8cd88f1f2fa4"
      },
      "created_time":"2022-07-02T16:48:00.000Z",
      "last_edited_time":"2022-07-02T16:48:00.000Z",
      "created_by":{
         "object":"user",
         "id":"f88037ff-f284-4448-a98e-b19e6fa623a2"
      },
      "last_edited_by":{
         "object":"user",
         "id":"f88037ff-f284-4448-a98e-b19e6fa623a2"
      },
      "has_children":false,
      "archived":false,
      "type":"paragraph",
      "paragraph":{
         "color":"default",
         "text":[
            {
               "type":"text",
               "text":{
                  "content":"This is where the third tweet begins:",
                  "link":null
               },
               "annotations":{
                  "bold":false,
                  "italic":false,
                  "strikethrough":false,
                  "underline":false,
                  "code":false,
                  "color":"default"
               },
               "plain_text":"This is where the third tweet begins:",
               "href":null
            }
         ]
      }
   },
   {
      "object":"block",
      "parent_id":"54540a0e-a4c4-4302-9e6e-8cd88f1f2fa4",
      "id":"3ae1f2f5-4d1b-40cd-ad43-69871129b558",
      "parent":{
         "type":"page_id",
         "page_id":"54540a0e-a4c4-4302-9e6e-8cd88f1f2fa4"
      },
      "created_time":"2022-07-02T16:48:00.000Z",
      "last_edited_time":"2022-07-02T16:48:00.000Z",
      "created_by":{
         "object":"user",
         "id":"f88037ff-f284-4448-a98e-b19e6fa623a2"
      },
      "last_edited_by":{
         "object":"user",
         "id":"f88037ff-f284-4448-a98e-b19e6fa623a2"
      },
      "has_children":false,
      "archived":false,
      "type":"video",
      "video":{
         "caption":[
            
         ],
         "type":"external",
         "external":{
            "url":"https://www.youtube.com/watch?v=PZ7lDrwYdZc"
         }
      }
   }
]
  1. If the paragraph blocks >1 or length of words in paragraphs > 280, separate into multiple tweets. If not it is single tweet

I figured that must work by storing that in an array or maybe variable where each posted paragraph (tweet) can we followed by split batches to get posted tweet URL and reply to that (for threads).

For separating the tweets I used a divider in the notion page content to identify them. For example, anything after a divider is a new tweet.

  1. If image block is present, use as attachment (for single tweet or multiple)

Are you sure that this is output? N8N and jsonformatter return syntax error

1 Like

@Shirobachi Yup it’s in 2 pages - the json output from these tables

Page 1

[
   {
      "object":"block",
      "parent_id":"54540a0e-a4c4-4302-9e6e-8cd88f1f2fa4",
      "id":"354bc29c-d9dc-407f-933b-4c89ec667d34",
      "parent":{
         "type":"page_id",
         "page_id":"54540a0e-a4c4-4302-9e6e-8cd88f1f2fa4"
      },
      "created_time":"2022-07-01T22:13:00.000Z",
      "last_edited_time":"2022-07-02T14:59:00.000Z",
      "created_by":{
         "object":"user",
         "id":"f88037ff-f284-4448-a98e-b19e6fa623a2"
      },
      "last_edited_by":{
         "object":"user",
         "id":"f88037ff-f284-4448-a98e-b19e6fa623a2"
      },
      "has_children":false,
      "archived":false,
      "type":"paragraph",
      "paragraph":{
         "color":"default",
         "text":[
            {
               "type":"text",
               "text":{
                  "content":"Hello",
                  "link":null
               },
               "annotations":{
                  "bold":true,
                  "italic":false,
                  "strikethrough":false,
                  "underline":false,
                  "code":false,
                  "color":"default"
               },
               "plain_text":"Hello",
               "href":null
            },
            {
               "type":"text",
               "text":{
                  "content":" world",
                  "link":null
               },
               "annotations":{
                  "bold":false,
                  "italic":false,
                  "strikethrough":false,
                  "underline":false,
                  "code":false,
                  "color":"default"
               },
               "plain_text":" world",
               "href":null
            }
         ]
      }
   },
   {
      "object":"block",
      "parent_id":"54540a0e-a4c4-4302-9e6e-8cd88f1f2fa4",
      "id":"b73303bc-c1f9-4d51-9a85-1c3fd031da6d",
      "parent":{
         "type":"page_id",
         "page_id":"54540a0e-a4c4-4302-9e6e-8cd88f1f2fa4"
      },
      "created_time":"2022-07-01T22:26:00.000Z",
      "last_edited_time":"2022-07-01T22:26:00.000Z",
      "created_by":{
         "object":"user",
         "id":"f88037ff-f284-4448-a98e-b19e6fa623a2"
      },
      "last_edited_by":{
         "object":"user",
         "id":"f88037ff-f284-4448-a98e-b19e6fa623a2"
      },
      "has_children":false,
      "archived":false,
      "type":"paragraph",
      "paragraph":{
         "color":"default",
         "text":[
            
         ]
      }
   },
   {
      "object":"block",
      "parent_id":"54540a0e-a4c4-4302-9e6e-8cd88f1f2fa4",
      "id":"a5800282-c968-42a3-b547-55e86a009670",
      "parent":{
         "type":"page_id",
         "page_id":"54540a0e-a4c4-4302-9e6e-8cd88f1f2fa4"
      },
      "created_time":"2022-07-01T22:26:00.000Z",
      "last_edited_time":"2022-07-02T16:47:00.000Z",
      "created_by":{
         "object":"user",
         "id":"f88037ff-f284-4448-a98e-b19e6fa623a2"
      },
      "last_edited_by":{
         "object":"user",
         "id":"f88037ff-f284-4448-a98e-b19e6fa623a2"
      },
      "has_children":false,
      "archived":false,
      "type":"paragraph",
      "paragraph":{
         "color":"default",
         "text":[
            {
               "type":"text",
               "text":{
                  "content":"Lorem Ipsum",
                  "link":null
               },
               "annotations":{
                  "bold":false,
                  "italic":true,
                  "strikethrough":false,
                  "underline":false,
                  "code":false,
                  "color":"default"
               },
               "plain_text":"Lorem Ipsum",
               "href":null
            },
            {
               "type":"text",
               "text":{
                  "content":" has been the industry's standard dummy text ever since the 1500s,",
                  "link":null
               },
               "annotations":{
                  "bold":false,
                  "italic":false,
                  "strikethrough":false,
                  "underline":false,
                  "code":false,
                  "color":"default"
               },
               "plain_text":" has been the industry's standard dummy text ever since the 1500s,",
               "href":null
            }
         ]
      }
   },
   {
      "object":"block",
      "parent_id":"54540a0e-a4c4-4302-9e6e-8cd88f1f2fa4",
      "id":"1cfa4dc8-3471-46ff-9033-7e53978b263b",
      "parent":{
         "type":"page_id",
         "page_id":"54540a0e-a4c4-4302-9e6e-8cd88f1f2fa4"
      },
      "created_time":"2022-07-01T22:26:00.000Z",
      "last_edited_time":"2022-07-01T22:26:00.000Z",
      "created_by":{
         "object":"user",
         "id":"f88037ff-f284-4448-a98e-b19e6fa623a2"
      },
      "last_edited_by":{
         "object":"user",
         "id":"f88037ff-f284-4448-a98e-b19e6fa623a2"
      },
      "has_children":false,
      "archived":false,
      "type":"image",
      "image":{
         "caption":[
            
         ],
         "type":"external",
         "external":{
            "url":"https://images.unsplash.com/photo-1615986201152-7686a4867f30?ixlib=rb-1.2.1&q=80&cs=tinysrgb&fm=jpg&crop=entropy"
         }
      }
   },
   {
      "object":"block",
      "parent_id":"54540a0e-a4c4-4302-9e6e-8cd88f1f2fa4",
      "id":"8f089e06-b5ec-448d-914f-0bd2c918824f",
      "parent":{
         "type":"page_id",
         "page_id":"54540a0e-a4c4-4302-9e6e-8cd88f1f2fa4"
      },
      "created_time":"2022-07-02T16:47:00.000Z",
      "last_edited_time":"2022-07-02T16:47:00.000Z",
      "created_by":{
         "object":"user",
         "id":"f88037ff-f284-4448-a98e-b19e6fa623a2"
      },
      "last_edited_by":{
         "object":"user",
         "id":"f88037ff-f284-4448-a98e-b19e6fa623a2"
      },
      "has_children":false,
      "archived":false,
      "type":"divider",
      "divider":{
         
      }
   },
   {
      "object":"block",
      "parent_id":"54540a0e-a4c4-4302-9e6e-8cd88f1f2fa4",
      "id":"4c69a0b1-6b35-4d0f-850a-c54d5fbe179a",
      "parent":{
         "type":"page_id",
         "page_id":"54540a0e-a4c4-4302-9e6e-8cd88f1f2fa4"
      },
      "created_time":"2022-07-01T22:26:00.000Z",
      "last_edited_time":"2022-07-02T16:48:00.000Z",
      "created_by":{
         "object":"user",
         "id":"f88037ff-f284-4448-a98e-b19e6fa623a2"
      },
      "last_edited_by":{
         "object":"user",
         "id":"f88037ff-f284-4448-a98e-b19e6fa623a2"
      },
      "has_children":false,
      "archived":false,
      "type":"paragraph",
      "paragraph":{
         "color":"default",
         "text":[
            {
               "type":"text",
               "text":{
                  "content":"This is where the second tweet begins just after this divide: ",
                  "link":null
               },
               "annotations":{
                  "bold":false,
                  "italic":false,
                  "strikethrough":false,
                  "underline":false,
                  "code":false,
                  "color":"default"
               },
               "plain_text":"This is where the second tweet begins just after this divide: ",
               "href":null
            }
         ]
      }
   },
   {
      "object":"block",
      "parent_id":"54540a0e-a4c4-4302-9e6e-8cd88f1f2fa4",
      "id":"c3e15d77-2b93-4b61-b30b-59e842b7ea5b",
      "parent":{
         "type":"page_id",
         "page_id":"54540a0e-a4c4-4302-9e6e-8cd88f1f2fa4"
      },
      "created_time":"2022-07-02T16:48:00.000Z",
      "last_edited_time":"2022-07-02T16:48:00.000Z",
      "created_by":{
         "object":"user",
         "id":"f88037ff-f284-4448-a98e-b19e6fa623a2"
      },
      "last_edited_by":{
         "object":"user",
         "id":"f88037ff-f284-4448-a98e-b19e6fa623a2"
      },
      "has_children":false,
      "archived":false,
      "type":"bulleted_list_item",
      "bulleted_list_item":{
         "color":"default",
         "text":[
            {
               "type":"text",
               "text":{
                  "content":"Bullet 1 ",
                  "link":null
               },
               "annotations":{
                  "bold":false,
                  "italic":false,
                  "strikethrough":false,
                  "underline":false,
                  "code":false,
                  "color":"default"
               },
               "plain_text":"Bullet 1 ",
               "href":null
            }
         ]
      }
   },
   {
      "object":"block",
      "parent_id":"54540a0e-a4c4-4302-9e6e-8cd88f1f2fa4",
      "id":"95b277b8-faac-4047-9a7f-3ac599873bc6",
      "parent":{
         "type":"page_id",
         "page_id":"54540a0e-a4c4-4302-9e6e-8cd88f1f2fa4"
      },
      "created_time":"2022-07-02T16:48:00.000Z",
      "last_edited_time":"2022-07-02T16:48:00.000Z",
      "created_by":{
         "object":"user",
         "id":"f88037ff-f284-4448-a98e-b19e6fa623a2"
      },
      "last_edited_by":{
         "object":"user",
         "id":"f88037ff-f284-4448-a98e-b19e6fa623a2"
      },
      "has_children":false,
      "archived":false,
      "type":"bulleted_list_item",
      "bulleted_list_item":{
         "color":"default",
         "text":[
            {
               "type":"text",
               "text":{
                  "content":"Bullet 2",
                  "link":null
               },
               "annotations":{
                  "bold":false,
                  "italic":false,
                  "strikethrough":false,
                  "underline":false,
                  "code":false,
                  "color":"default"
               },
               "plain_text":"Bullet 2",
               "href":null
            }
         ]
      }
   },
   {
      "object":"block",
      "parent_id":"54540a0e-a4c4-4302-9e6e-8cd88f1f2fa4",
      "id":"db6d122c-27f8-462e-a1ab-06df533d1364",
      "parent":{
         "type":"page_id",
         "page_id":"54540a0e-a4c4-4302-9e6e-8cd88f1f2fa4"
      },
      "created_time":"2022-07-02T16:48:00.000Z",
      "last_edited_time":"2022-07-02T16:48:00.000Z",
      "created_by":{
         "object":"user",
         "id":"f88037ff-f284-4448-a98e-b19e6fa623a2"
      },
      "last_edited_by":{
         "object":"user",
         "id":"f88037ff-f284-4448-a98e-b19e6fa623a2"
      },
      "has_children":false,
      "archived":false,
      "type":"bulleted_list_item",
      "bulleted_list_item":{
         "color":"default",
         "text":[
            {
               "type":"text",
               "text":{
                  "content":"Bullet 3",
                  "link":null
               },
               "annotations":{
                  "bold":false,
                  "italic":false,
                  "strikethrough":false,
                  "underline":false,
                  "code":false,
                  "color":"default"
               },
               "plain_text":"Bullet 3",
               "href":null
            }
         ]
      }
   },
   {
      "object":"block",
      "parent_id":"54540a0e-a4c4-4302-9e6e-8cd88f1f2fa4",
      "id":"d1702323-ff42-4501-93b6-13d8100d9239",
      "parent":{
         "type":"page_id",
         "page_id":"54540a0e-a4c4-4302-9e6e-8cd88f1f2fa4"
      },
      "created_time":"2022-07-02T16:48:00.000Z",
      "last_edited_time":"2022-07-02T16:48:00.000Z",
      "created_by":{
         "object":"user",
         "id":"f88037ff-f284-4448-a98e-b19e6fa623a2"
      },
      "last_edited_by":{
         "object":"user",
         "id":"f88037ff-f284-4448-a98e-b19e6fa623a2"
      },
      "has_children":false,
      "archived":false,
      "type":"divider",
      "divider":{
         
      }
   }
]

Page 2

[
  {
    "object": "block",
    "parent_id": "54540a0e-a4c4-4302-9e6e-8cd88f1f2fa4",
    "id": "d1ae2758-d72e-42f2-b224-a648deca3ff2",
    "parent": {
      "type": "page_id",
      "page_id": "54540a0e-a4c4-4302-9e6e-8cd88f1f2fa4"
    },
    "created_time": "2022-07-02T16:48:00.000Z",
    "last_edited_time": "2022-07-02T16:48:00.000Z",
    "created_by": {
      "object": "user",
      "id": "f88037ff-f284-4448-a98e-b19e6fa623a2"
    },
    "last_edited_by": {
      "object": "user",
      "id": "f88037ff-f284-4448-a98e-b19e6fa623a2"
    },
    "has_children": false,
    "archived": false,
    "type": "paragraph",
    "paragraph": {
      "color": "default",
      "text": [
        {
          "type": "text",
          "text": {
            "content": "This is where the third tweet begins:",
            "link": null
          },
          "annotations": {
            "bold": false,
            "italic": false,
            "strikethrough": false,
            "underline": false,
            "code": false,
            "color": "default"
          },
          "plain_text": "This is where the third tweet begins:",
          "href": null
        }
      ]
    }
  },
  {
    "object": "block",
    "parent_id": "54540a0e-a4c4-4302-9e6e-8cd88f1f2fa4",
    "id": "3ae1f2f5-4d1b-40cd-ad43-69871129b558",
    "parent": {
      "type": "page_id",
      "page_id": "54540a0e-a4c4-4302-9e6e-8cd88f1f2fa4"
    },
    "created_time": "2022-07-02T16:48:00.000Z",
    "last_edited_time": "2022-07-02T16:48:00.000Z",
    "created_by": {
      "object": "user",
      "id": "f88037ff-f284-4448-a98e-b19e6fa623a2"
    },
    "last_edited_by": {
      "object": "user",
      "id": "f88037ff-f284-4448-a98e-b19e6fa623a2"
    },
    "has_children": false,
    "archived": false,
    "type": "video",
    "video": {
      "caption": [],
      "type": "external",
      "external": {
        "url": "https://www.youtube.com/watch?v=PZ7lDrwYdZc"
      }
    }
  }
]

the images and videos do not come how do I get to get the images and videos?