Apify + GPT-4o-mini を使ってタグ分析から Instagram キャプションを生成

上級

これはContent Creation, Multimodal AI分野の自動化ワークフローで、17個のノードを含みます。主にSet, Code, Merge, SplitOut, Aggregateなどのノードを使用。 Apify + GPT-4o-mini を使ってタグ分析から Instagram キャプションを生成

前提条件
  • ターゲットAPIの認証情報が必要な場合あり
  • OpenAI API Key
ワークフロープレビュー
ノード接続関係を可視化、ズームとパンをサポート
ワークフローをエクスポート
以下のJSON設定をn8nにインポートして、このワークフローを使用できます
{
  "meta": {
    "instanceId": "efb474b59b0341d7791932605bd9ff04a6c7ed9941fdd53dc4a2e4b99a6f9439"
  },
  "nodes": [
    {
      "id": "2ea0c49a-6706-4272-8990-06f578c5c5a7",
      "name": "ワークフロー実行時",
      "type": "n8n-nodes-base.manualTrigger",
      "position": [
        -360,
        1080
      ],
      "parameters": {},
      "typeVersion": 1
    },
    {
      "id": "a889197b-b78d-4808-948c-6d57883ee34f",
      "name": "AIエージェント",
      "type": "@n8n/n8n-nodes-langchain.agent",
      "position": [
        920,
        1060
      ],
      "parameters": {
        "text": "=posts: {{ $json.text }}",
        "options": {
          "systemMessage": "=I'm looking for ideas for posts about  {{ $('Create Search Term').item.json.Search_Term }}\n\nHere's the last 5 posts on instagram about the topic. Use those to help me generate a list of relevent captions to post on my instagram. \n\ndo not make up ideas that are not like the others in the list. \n\noutput like this. \n\n{\n\t\"Post Idea\": [\"Idea1\", \"Idea2\"], \n  \"Most Common Post\":  [\"common post 1\", \"common post 2\"]\n}"
        },
        "promptType": "define",
        "hasOutputParser": true
      },
      "typeVersion": 2
    },
    {
      "id": "47f4b1cb-9361-4aff-a439-2c8979fe93f4",
      "name": "OpenAI チャットモデル",
      "type": "@n8n/n8n-nodes-langchain.lmChatOpenAi",
      "position": [
        960,
        1280
      ],
      "parameters": {
        "model": {
          "__rl": true,
          "mode": "list",
          "value": "gpt-4o-mini"
        },
        "options": {}
      },
      "credentials": {
        "openAiApi": {
          "id": "ghJTvay8CvwXDsXz",
          "name": "OpenAi account"
        }
      },
      "typeVersion": 1.2
    },
    {
      "id": "2b0f574d-7976-469a-bf84-00a37ef15def",
      "name": "構造化出力パーサー",
      "type": "@n8n/n8n-nodes-langchain.outputParserStructured",
      "position": [
        1140,
        1280
      ],
      "parameters": {
        "jsonSchemaExample": "{\n\t\"Post Idea\": [\"Idea1\", \"Idea2\"], \n  \"Most Common Post\":  [\"common post 1\", \"common post 2\"]\n}"
      },
      "typeVersion": 1.2
    },
    {
      "id": "00910de9-80ba-41c9-8200-81fcb6d15f45",
      "name": "最近の投稿を検索",
      "type": "n8n-nodes-base.httpRequest",
      "position": [
        140,
        1120
      ],
      "parameters": {
        "url": "=https://api.apify.com/v2/acts/apify~instagram-hashtag-scraper/run-sync-get-dataset-items\n",
        "method": "POST",
        "options": {},
        "jsonBody": "={\n    \"hashtags\": [\n        \"{{ $json.Search_Term }}\"\n    ],\n    \"resultsLimit\": 20,\n    \"resultsType\": \"posts\"\n}",
        "sendBody": true,
        "specifyBody": "json",
        "authentication": "genericCredentialType",
        "genericAuthType": "httpQueryAuth"
      },
      "credentials": {
        "httpQueryAuth": {
          "id": "yLUXsSPePLOGnHmf",
          "name": "Query Auth account"
        }
      },
      "typeVersion": 4.2
    },
    {
      "id": "5a62f897-74a6-4899-a8c9-a51a6d011373",
      "name": "検索用語を作成",
      "type": "n8n-nodes-base.set",
      "position": [
        -140,
        1000
      ],
      "parameters": {
        "options": {},
        "assignments": {
          "assignments": [
            {
              "id": "ad5c9a23-7fe0-4ed4-b1e7-d3da417bcb86",
              "name": "Search_Term",
              "type": "string",
              "value": "n8n"
            }
          ]
        }
      },
      "typeVersion": 3.4
    },
    {
      "id": "33a01e12-8820-4184-92fb-6682470940b1",
      "name": "プロフィールとフォロワー数を設定",
      "type": "n8n-nodes-base.set",
      "position": [
        440,
        920
      ],
      "parameters": {
        "options": {},
        "assignments": {
          "assignments": [
            {
              "id": "ac638d8c-fa83-4cf6-92af-e0489d7349dd",
              "name": "caption",
              "type": "string",
              "value": "={{ $json.caption }}"
            }
          ]
        }
      },
      "typeVersion": 3.4
    },
    {
      "id": "7275daae-bf7a-4c06-928a-16f0bfdc0a3b",
      "name": "付箋",
      "type": "n8n-nodes-base.stickyNote",
      "position": [
        -400,
        100
      ],
      "parameters": {
        "color": 3,
        "width": 780,
        "height": 1380,
        "content": "### 1️⃣ Manual Trigger\n\n#### 🧩 Node: `When clicking ‘Execute workflow’`\n- Manually starts the workflow for testing or single-run execution.\n\n---\n\n### 2️⃣ Define the Hashtag\n\n#### 🧩 Node: `Create Search Term`\n- Sets the value of the hashtag you'd like to scan.\n- Default is `n8n`, but you can modify it to anything.\n\n```json\n{\n  \"Search_Term\": \"yourCustomHashtag\"\n}\n```\n\n---\n\n### 3️⃣ Scrape Instagram Posts\n\n#### 🧩 Node: `Find Recent Posts`\n- **API**: [Apify Instagram Hashtag Scraper](https://console.apify.com/actors/apify/instagram-hashtag-scraper)\n- **Setup**:\n  - Visit [Apify Console](https://console.apify.com/)\n  - Create an API token\n  - In n8n, go to Credentials and add `HTTP Query Auth`\n  - Use `?token=yourTokenHere` as the query string\n\n**JSON Body:**\n```json\n{\n  \"hashtags\": [\"{{ $json.Search_Term }}\"],\n  \"resultsLimit\": 20,\n  \"resultsType\": \"posts\"\n}\n```\n\n---\n\n"
      },
      "typeVersion": 1
    },
    {
      "id": "09a04fbd-a16b-4166-a623-555770c81605",
      "name": "付箋1",
      "type": "n8n-nodes-base.stickyNote",
      "position": [
        400,
        100
      ],
      "parameters": {
        "color": 4,
        "width": 440,
        "height": 1380,
        "content": "\n### 4️⃣ Extract Captions\n\n#### 🧩 Node: `Set bio and follower count`\n- Extracts just the `caption` from each post and stores it in a clean variable for the AI agent to use.\n\n---\n\n### 5️⃣ Aggregate Captions\n\n#### 🧩 Node: `Aggregate`\n- Gathers all captions into one list before processing.\n- Useful for passing a large text block into the AI.\n\n---\n\n### 6️⃣ Convert to Single Text Block\n\n#### 🧩 Node: `Convert table names and columns into single text for agent`\n- Uses a `Code` node to combine all captions into a single string for OpenAI to read:\n```javascript\nreturn [\n  {\n    json: {\n      text: items\n        .map(item => `- ${JSON.stringify(item.json)}`)\n        .join('\\n\\n'),\n    },\n  },\n];\n```\n\n---"
      },
      "typeVersion": 1
    },
    {
      "id": "6a88d748-9563-49b8-9398-9d2032413f94",
      "name": "付箋2",
      "type": "n8n-nodes-base.stickyNote",
      "position": [
        860,
        100
      ],
      "parameters": {
        "color": 6,
        "width": 420,
        "height": 1380,
        "content": "### 7️⃣ Generate Caption Ideas with AI\n\n#### 🧩 Node: `AI Agent`\n- Takes the combined post text and sends it to GPT-4o-mini.\n- Includes this system message:\n```text\nI'm looking for ideas for posts about {{ $('Create Search Term').item.json.Search_Term }}.\nHere’s the last 5 posts on Instagram about the topic. Use those to help me generate a list of relevant captions.\n\nDo not make up ideas that are not like the others in the list.\n\nOutput like this:\n{\n  \"Post Idea\": [\"Idea1\", \"Idea2\"],\n  \"Most Common Post\": [\"common post 1\", \"common post 2\"]\n}\n```\n\n---\n\n### 8️⃣ Choose Language Model\n\n#### 🧩 Node: `OpenAI Chat Model`\n- **Model**: `gpt-4o-mini`\n- **Credential**: Use your OpenAI API key.\n  - Get it from: [OpenAI API Keys](https://platform.openai.com/account/api-keys)\n  - Add it in n8n under OpenAI credentials.\n\n---\n\n### 9️⃣ Parse the AI Output\n\n#### 🧩 Node: `Structured Output Parser`\n- Parses the GPT response into structured JSON:\n```json\n{\n  \"Post Idea\": [\"Idea1\", \"Idea2\"],\n  \"Most Common Post\": [\"common post 1\", \"common post 2\"]\n}\n```\n\n---\n"
      },
      "typeVersion": 1
    },
    {
      "id": "812c1007-ba56-4934-b88f-fcfe1f0bcf01",
      "name": "付箋3",
      "type": "n8n-nodes-base.stickyNote",
      "position": [
        -400,
        -80
      ],
      "parameters": {
        "width": 2320,
        "content": "## 📬 Need More Help?\n\n**👤 Robert Breen**  \nAutomation Consultant | AI Workflow Designer | n8n Expert  \n📧 [robert@ynteractive.com](mailto:robert@ynteractive.com)  \n🔗 [LinkedIn](https://www.linkedin.com/in/robert-breen-29429625/)\n"
      },
      "typeVersion": 1
    },
    {
      "id": "5fee94d6-f796-4785-a806-07714c2f0d64",
      "name": "集約",
      "type": "n8n-nodes-base.aggregate",
      "position": [
        600,
        1100
      ],
      "parameters": {
        "options": {},
        "fieldsToAggregate": {
          "fieldToAggregate": [
            {
              "fieldToAggregate": "caption"
            }
          ]
        }
      },
      "typeVersion": 1
    },
    {
      "id": "0381aa63-dfa9-4e94-9991-6b266325d8ad",
      "name": "テーブル名と列をエージェント用単一テキストに変換",
      "type": "n8n-nodes-base.code",
      "position": [
        700,
        880
      ],
      "parameters": {
        "jsCode": "return [\n  {\n    json: {\n      text: items\n        .map(item => `- ${JSON.stringify(item.json)}`)\n        .join('\\n\\n'),\n    },\n  },\n];\n"
      },
      "typeVersion": 2
    },
    {
      "id": "1d2af5fa-b9ef-401d-8b29-b0376d1317b4",
      "name": "分割",
      "type": "n8n-nodes-base.splitOut",
      "position": [
        1400,
        1020
      ],
      "parameters": {
        "options": {},
        "fieldToSplitOut": "output['Post Idea']"
      },
      "typeVersion": 1
    },
    {
      "id": "12b8c5e9-3448-4459-ad9b-d6e1af7a7c84",
      "name": "分割1",
      "type": "n8n-nodes-base.splitOut",
      "position": [
        1420,
        1260
      ],
      "parameters": {
        "options": {},
        "fieldToSplitOut": "output['Most Common Post']"
      },
      "typeVersion": 1
    },
    {
      "id": "73fd8217-6eae-4ce5-a2b5-f0325ea9154e",
      "name": "マージ",
      "type": "n8n-nodes-base.merge",
      "position": [
        1660,
        1140
      ],
      "parameters": {
        "mode": "combine",
        "options": {},
        "combineBy": "combineByPosition"
      },
      "typeVersion": 3.2
    },
    {
      "id": "a25480f7-c832-4f8c-80e7-5e1ebd486305",
      "name": "付箋4",
      "type": "n8n-nodes-base.stickyNote",
      "position": [
        1300,
        100
      ],
      "parameters": {
        "width": 620,
        "height": 1380,
        "content": "### 🔟 Split the Outputs\n\n#### 🧩 Nodes: `Split Out`, `Split Out1`\n- Separates the `Post Idea` list and `Most Common Post` list into individual items.\n\n---\n\n### 🔁 Merge for Final Output\n\n#### 🧩 Node: `Merge`\n- Combines the two split lists into one output stream.\n\n---"
      },
      "typeVersion": 1
    }
  ],
  "pinData": {
    "AI Agent": [
      {
        "output": {
          "Post Idea": [
            "What are the top 3 automations you've implemented with n8n? Share your experiences!",
            "Ever wondered how n8n can streamline your daily tasks? Let’s discuss the best workflows!",
            "How can n8n transform your business processes? Share your thoughts!",
            "Join our n8n community and learn from others’ automation journeys! What tips do you have to share?",
            "Post about how you used n8n to solve a particular challenge—encourage followers to share their experiences!"
          ],
          "Most Common Post": [
            "Automate your business processes with n8n and focus on what truly matters!",
            "Join our free webinar on using n8n for efficient workflow automation!",
            "Discover how n8n connects different tools to save you time!",
            "Share your favorite tools and how n8n helps you integrate them!",
            "Tag a friend who needs to explore automation with n8n!"
          ]
        }
      }
    ]
  },
  "connections": {
    "a889197b-b78d-4808-948c-6d57883ee34f": {
      "main": [
        [
          {
            "node": "1d2af5fa-b9ef-401d-8b29-b0376d1317b4",
            "type": "main",
            "index": 0
          },
          {
            "node": "12b8c5e9-3448-4459-ad9b-d6e1af7a7c84",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "5fee94d6-f796-4785-a806-07714c2f0d64": {
      "main": [
        [
          {
            "node": "0381aa63-dfa9-4e94-9991-6b266325d8ad",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "1d2af5fa-b9ef-401d-8b29-b0376d1317b4": {
      "main": [
        [
          {
            "node": "73fd8217-6eae-4ce5-a2b5-f0325ea9154e",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "12b8c5e9-3448-4459-ad9b-d6e1af7a7c84": {
      "main": [
        [
          {
            "node": "73fd8217-6eae-4ce5-a2b5-f0325ea9154e",
            "type": "main",
            "index": 1
          }
        ]
      ]
    },
    "00910de9-80ba-41c9-8200-81fcb6d15f45": {
      "main": [
        [
          {
            "node": "33a01e12-8820-4184-92fb-6682470940b1",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "47f4b1cb-9361-4aff-a439-2c8979fe93f4": {
      "ai_languageModel": [
        [
          {
            "node": "a889197b-b78d-4808-948c-6d57883ee34f",
            "type": "ai_languageModel",
            "index": 0
          }
        ]
      ]
    },
    "5a62f897-74a6-4899-a8c9-a51a6d011373": {
      "main": [
        [
          {
            "node": "00910de9-80ba-41c9-8200-81fcb6d15f45",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "2b0f574d-7976-469a-bf84-00a37ef15def": {
      "ai_outputParser": [
        [
          {
            "node": "a889197b-b78d-4808-948c-6d57883ee34f",
            "type": "ai_outputParser",
            "index": 0
          }
        ]
      ]
    },
    "33a01e12-8820-4184-92fb-6682470940b1": {
      "main": [
        [
          {
            "node": "5fee94d6-f796-4785-a806-07714c2f0d64",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "2ea0c49a-6706-4272-8990-06f578c5c5a7": {
      "main": [
        [
          {
            "node": "5a62f897-74a6-4899-a8c9-a51a6d011373",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "0381aa63-dfa9-4e94-9991-6b266325d8ad": {
      "main": [
        [
          {
            "node": "a889197b-b78d-4808-948c-6d57883ee34f",
            "type": "main",
            "index": 0
          }
        ]
      ]
    }
  }
}
よくある質問

このワークフローの使い方は?

上記のJSON設定コードをコピーし、n8nインスタンスで新しいワークフローを作成して「JSONからインポート」を選択、設定を貼り付けて認証情報を必要に応じて変更してください。

このワークフローはどんな場面に適していますか?

上級 - コンテンツ作成, マルチモーダルAI

有料ですか?

このワークフローは完全無料です。ただし、ワークフローで使用するサードパーティサービス(OpenAI APIなど)は別途料金が発生する場合があります。

ワークフロー情報
難易度
上級
ノード数17
カテゴリー2
ノードタイプ11
難易度説明

上級者向け、16ノード以上の複雑なワークフロー

作成者
Robert Breen

Robert Breen

@rbreen

Professional services consultant with over 10 years of experience solving complex business problems across industries. I specialize in n8n and process automation—designing custom workflows that integrate tools like Google Calendar, Airtable, GPT, and internal systems. Whether you need to automate scheduling, sync data, or streamline operations, I build solutions that save time and drive results.

外部リンク
n8n.ioで表示

このワークフローを共有

カテゴリー

カテゴリー: 34