{
  "nodes": [
    {
      "id": "09c146a6-9715-413d-9d67-02ffbf09b1e7",
      "name": "IGPost URL",
      "type": "n8n-nodes-base.set",
      "position": [
        -448,
        240
      ],
      "parameters": {
        "options": {},
        "assignments": {
          "assignments": [
            {
              "id": "c54a258a-6b02-4cd3-8f04-ad92c44072a5",
              "name": "post_url",
              "type": "string",
              "value": "https://www.instagram.com/p/DQf3KpkE4cW/?img_index=11"
            }
          ]
        }
      },
      "typeVersion": 3.4
    },
    {
      "id": "e84fb49c-c0e7-48a1-ab4e-0bd10228bc53",
      "name": "Loop Over Items1",
      "type": "n8n-nodes-base.splitInBatches",
      "position": [
        592,
        240
      ],
      "parameters": {
        "options": {}
      },
      "typeVersion": 3
    },
    {
      "id": "463738b0-db8c-433c-a273-ff6a6a2f1499",
      "name": "Merge All Parsed Text",
      "type": "n8n-nodes-base.aggregate",
      "position": [
        784,
        0
      ],
      "parameters": {
        "options": {},
        "aggregate": "=aggregateAllItemData",
        "fieldsToAggregate": {
          "fieldToAggregate": [
            {}
          ]
        }
      },
      "typeVersion": 1
    },
    {
      "id": "12cb278c-c5df-4a5f-b3a9-c625e7b2ccf1",
      "name": "Retrieve Media",
      "type": "n8n-nodes-base.httpRequest",
      "position": [
        -224,
        240
      ],
      "parameters": {
        "url": "https://api.hikerapi.com/v1/media/by/url",
        "options": {},
        "sendQuery": true,
        "sendHeaders": true,
        "authentication": "genericCredentialType",
        "genericAuthType": "httpHeaderAuth",
        "queryParameters": {
          "parameters": [
            {
              "name": "url",
              "value": "={{ $json.post_url }}"
            }
          ]
        },
        "headerParameters": {
          "parameters": [
            {
              "name": "accept",
              "value": "application/json"
            }
          ]
        }
      },
      "credentials": {
        "httpHeaderAuth": {
          "name": "<your credential>"
        }
      },
      "typeVersion": 4.3
    },
    {
      "id": "6b232510-5d1b-4fca-bf92-27485534cae1",
      "name": "getOnlyText",
      "type": "n8n-nodes-base.code",
      "position": [
        1136,
        256
      ],
      "parameters": {
        "jsCode": "return [\n{\njson: {\nvalue: $input.first().json.ParsedResults[0].ParsedText\n}\n}\n]"
      },
      "typeVersion": 2
    },
    {
      "id": "a5b3bac1-82e1-4c7e-bca2-055c67034ae1",
      "name": "get_all_slide",
      "type": "n8n-nodes-base.code",
      "position": [
        224,
        240
      ],
      "parameters": {
        "jsCode": "return $input.first().json.resources"
      },
      "typeVersion": 2
    },
    {
      "id": "dbb9c2bf-8768-4e43-bf6e-351ee3586b69",
      "name": "OCR_Slide",
      "type": "n8n-nodes-base.httpRequest",
      "position": [
        864,
        256
      ],
      "parameters": {
        "url": "https://api.ocr.space/parse/imageurl",
        "options": {},
        "sendQuery": true,
        "authentication": "genericCredentialType",
        "genericAuthType": "httpQueryAuth",
        "queryParameters": {
          "parameters": [
            {
              "name": "url",
              "value": "={{ $json.image_versions[0].url }}"
            }
          ]
        }
      },
      "credentials": {
        "httpQueryAuth": {
          "name": "<your credential>"
        }
      },
      "typeVersion": 4.3,
      "alwaysOutputData": false
    },
    {
      "id": "8afdc123-ac76-4f19-9202-79aa86ed1185",
      "name": "OCR_Single",
      "type": "n8n-nodes-base.httpRequest",
      "position": [
        224,
        0
      ],
      "parameters": {
        "url": "https://api.ocr.space/parse/imageurl",
        "options": {},
        "sendQuery": true,
        "authentication": "genericCredentialType",
        "genericAuthType": "httpQueryAuth",
        "queryParameters": {
          "parameters": [
            {
              "name": "url",
              "value": "={{ $json.image_versions[0].url }}"
            }
          ]
        }
      },
      "credentials": {
        "httpQueryAuth": {
          "name": "<your credential>"
        }
      },
      "typeVersion": 4.3,
      "alwaysOutputData": false
    },
    {
      "id": "57330077-2514-4b0f-8b36-7df966d51424",
      "name": "getSingleText",
      "type": "n8n-nodes-base.code",
      "position": [
        512,
        0
      ],
      "parameters": {
        "jsCode": "return [\n{\njson: {\nvalue: $input.first().json.ParsedResults[0].ParsedText\n}\n}\n]"
      },
      "typeVersion": 2
    },
    {
      "id": "0894ac96-b32d-4e48-90f0-f5f4da743519",
      "name": "No Operation, do nothing",
      "type": "n8n-nodes-base.noOp",
      "position": [
        224,
        432
      ],
      "parameters": {},
      "typeVersion": 1
    },
    {
      "id": "a856d7dc-7a17-4b97-9c9d-0f67479b216b",
      "name": "Result of Raw Text",
      "type": "n8n-nodes-base.code",
      "position": [
        1056,
        0
      ],
      "parameters": {
        "jsCode": "const items = $input.all()\n\nconst result = items\n.flatMap(i => i.json.data) // ambil array \"data\"\n.map(d => d.value) // ambil value-nya\n.filter(Boolean) // buang yang kosong\n.join(\"\\n\") // gabung jadi teks\n\nreturn [\n{\njson: {\ntext: result\n}\n}\n]"
      },
      "typeVersion": 2
    },
    {
      "id": "ef6e1690-e477-42d8-bb55-9631ea4513f4",
      "name": "When clicking \u2018Execute workflow\u2019",
      "type": "n8n-nodes-base.manualTrigger",
      "position": [
        -672,
        240
      ],
      "parameters": {},
      "typeVersion": 1
    },
    {
      "id": "87bd3834-aa95-4ebd-806d-e117858a2bc9",
      "name": "Sticky Note",
      "type": "n8n-nodes-base.stickyNote",
      "position": [
        -1264,
        -32
      ],
      "parameters": {
        "width": 512,
        "height": 448,
        "content": "## Get Raw Text of Instagram Post with OCR\n\n### How it works\n\u2022 Takes an Instagram post URL (single post or carousel)\n\u2022 Retrieves media data using the HikerAPI Get Media endpoint\n\u2022 Detects post type (single feed, carousel, or reel)\n\u2022 For single post: sends the image to OCR.Space to extract text\n\u2022 For carousel: loops through each slide, sends each image to OCR.Space, and collects all text results\n\u2022 Merges all parsed text into a single raw-text output\n\n### Set up steps\n\u2022 Prepare your API keys:\n\u2013 HikerAPI (HikerAPI.com) ~ paid, but very affordable\n\u2013 OCR.Space (https://ocr.space/) ~ free\n\u2022 Replace the API keys inside the **Retrieve Media** nodes\n\u2022 Insert the Instagram post URL in the \u201cIGPost URL\u201d node\n\u2022 Run the workflow to extract raw text from Instagram images\n\u2022 Keep detailed explanations in the sticky notes inside this workflow"
      },
      "typeVersion": 1
    },
    {
      "id": "5241a211-38fe-4b17-b87b-bf4887e20645",
      "name": "Sticky Note1",
      "type": "n8n-nodes-base.stickyNote",
      "position": [
        -1264,
        480
      ],
      "parameters": {
        "width": 512,
        "height": 336,
        "content": "## Workflow Creator Profile \u2013 Pake.AI\n\n**Pake.AI** is an AI Enabler from Indonesia, committed to helping creators, entrepreneurs, and businesses automate their operations through practical and accessible AI solutions.\n\nThis workflow is shared **for free** to support the community and accelerate AI adoption.\n\nIf you have any questions about this workflow or want to explore more automation tools, feel free to contact us:\n\n\ud83c\udf10 **https://pake.ai**\n"
      },
      "typeVersion": 1
    },
    {
      "id": "8fa5694c-5338-4ff6-9210-857ca4b9cc1a",
      "name": "Sticky Note2",
      "type": "n8n-nodes-base.stickyNote",
      "position": [
        -528,
        176
      ],
      "parameters": {
        "color": 7,
        "width": 480,
        "height": 240,
        "content": "## 1. Get Media of IG Post"
      },
      "typeVersion": 1
    },
    {
      "id": "968f2ae7-4d80-4ede-bc22-5538e4a2d01d",
      "name": "Sticky Note3",
      "type": "n8n-nodes-base.stickyNote",
      "position": [
        512,
        176
      ],
      "parameters": {
        "color": 7,
        "width": 816,
        "height": 304,
        "content": "## 2b. Extract the Text within the loop of Carousel Post to scan with OCR API\n"
      },
      "typeVersion": 1
    },
    {
      "id": "92516339-7db8-417a-aae6-c63833756bd3",
      "name": "Sticky Note4",
      "type": "n8n-nodes-base.stickyNote",
      "position": [
        144,
        -96
      ],
      "parameters": {
        "color": 7,
        "width": 544,
        "height": 256,
        "content": "## 2a. Extract the Text for Image on Single Post with OCR API\n"
      },
      "typeVersion": 1
    },
    {
      "id": "c061650e-f28e-43d2-9856-e55ff7860c34",
      "name": "Sticky Note5",
      "type": "n8n-nodes-base.stickyNote",
      "position": [
        736,
        -96
      ],
      "parameters": {
        "color": 7,
        "width": 592,
        "height": 256,
        "content": "## 3. The Result\nYou can connect this nodes with your purpose\n"
      },
      "typeVersion": 1
    },
    {
      "id": "7e12f3d9-91db-439c-8ceb-6a0d7b9e07e9",
      "name": "Post Type Selector",
      "type": "n8n-nodes-base.switch",
      "position": [
        0,
        224
      ],
      "parameters": {
        "rules": {
          "values": [
            {
              "outputKey": "single_post",
              "conditions": {
                "options": {
                  "version": 2,
                  "leftValue": "",
                  "caseSensitive": true,
                  "typeValidation": "strict"
                },
                "combinator": "and",
                "conditions": [
                  {
                    "id": "422b2e08-1cb0-41e5-8f4a-e92354e947ed",
                    "operator": {
                      "type": "string",
                      "operation": "equals"
                    },
                    "leftValue": "={{ $json.product_type }}",
                    "rightValue": "feed"
                  }
                ]
              },
              "renameOutput": true
            },
            {
              "outputKey": "carousel",
              "conditions": {
                "options": {
                  "version": 2,
                  "leftValue": "",
                  "caseSensitive": true,
                  "typeValidation": "strict"
                },
                "combinator": "and",
                "conditions": [
                  {
                    "id": "63e1aa00-aba3-460a-b5ef-018e3a0673a3",
                    "operator": {
                      "type": "string",
                      "operation": "equals"
                    },
                    "leftValue": "={{ $json.product_type }}",
                    "rightValue": "carousel_container"
                  }
                ]
              },
              "renameOutput": true
            },
            {
              "outputKey": "reels",
              "conditions": {
                "options": {
                  "version": 2,
                  "leftValue": "",
                  "caseSensitive": true,
                  "typeValidation": "strict"
                },
                "combinator": "and",
                "conditions": [
                  {
                    "id": "5016f778-c1e7-4417-960c-7833fa7e3daa",
                    "operator": {
                      "name": "filter.operator.equals",
                      "type": "string",
                      "operation": "equals"
                    },
                    "leftValue": "={{ $json.product_type }}",
                    "rightValue": "clips"
                  }
                ]
              },
              "renameOutput": true
            }
          ]
        },
        "options": {}
      },
      "typeVersion": 3.3
    }
  ],
  "connections": {
    "OCR_Slide": {
      "main": [
        [
          {
            "node": "getOnlyText",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "IGPost URL": {
      "main": [
        [
          {
            "node": "Retrieve Media",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "OCR_Single": {
      "main": [
        [
          {
            "node": "getSingleText",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "getOnlyText": {
      "main": [
        [
          {
            "node": "Loop Over Items1",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "getSingleText": {
      "main": [
        [
          {
            "node": "Merge All Parsed Text",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "get_all_slide": {
      "main": [
        [
          {
            "node": "Loop Over Items1",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "Retrieve Media": {
      "main": [
        [
          {
            "node": "Post Type Selector",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "Loop Over Items1": {
      "main": [
        [
          {
            "node": "Merge All Parsed Text",
            "type": "main",
            "index": 0
          }
        ],
        [
          {
            "node": "OCR_Slide",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "Post Type Selector": {
      "main": [
        [
          {
            "node": "OCR_Single",
            "type": "main",
            "index": 0
          }
        ],
        [
          {
            "node": "get_all_slide",
            "type": "main",
            "index": 0
          }
        ],
        [
          {
            "node": "No Operation, do nothing",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "Merge All Parsed Text": {
      "main": [
        [
          {
            "node": "Result of Raw Text",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "When clicking \u2018Execute workflow\u2019": {
      "main": [
        [
          {
            "node": "IGPost URL",
            "type": "main",
            "index": 0
          }
        ]
      ]
    }
  }
}