Instagram リード生成

上級

これはLead Generation, AI RAG分野の自動化ワークフローで、18個のノードを含みます。主にSet, Code, Postgres, SplitOut, HttpRequestなどのノードを使用。 Apify、GPT、そして PostgreSQL を使って Instagram インフルエンサーのリード獲得を自動化

前提条件
  • PostgreSQLデータベース接続情報
  • ターゲットAPIの認証情報が必要な場合あり
  • OpenAI API Key
ワークフロープレビュー
ノード接続関係を可視化、ズームとパンをサポート
ワークフローをエクスポート
以下のJSON設定をn8nにインポートして、このワークフローを使用できます
{
  "id": "geEVmbXLYDSA8UGM",
  "meta": {
    "instanceId": "5ca157bf036415a321c9d29eeb986017053989bb83b5b61701e90fe3987ac8b7",
    "templateCredsSetupCompleted": true
  },
  "name": "Instagram Lead Generation",
  "tags": [],
  "nodes": [
    {
      "id": "5f49d3d3-5e81-4b9d-9bc4-687ee97e2e8f",
      "name": "ワークフローをクリックした時",
      "type": "n8n-nodes-base.manualTrigger",
      "position": [
        -256,
        0
      ],
      "parameters": {},
      "typeVersion": 1
    },
    {
      "id": "9990229b-1098-4ff5-8906-c57a260f4d15",
      "name": "フィールド編集",
      "type": "n8n-nodes-base.set",
      "position": [
        -32,
        0
      ],
      "parameters": {
        "options": {},
        "assignments": {
          "assignments": [
            {
              "id": "8b66c6fb-0773-4c66-b088-e35fbb27fd08",
              "name": "site",
              "type": "string",
              "value": "instagram"
            },
            {
              "id": "9dddc30f-b90d-4759-81be-96161bc5dd48",
              "name": "field_of_interest",
              "type": "string",
              "value": "beauty & hair"
            },
            {
              "id": "9fba044b-013f-4ff0-8687-6a6c8954011a",
              "name": "target_country",
              "type": "string",
              "value": "USA"
            }
          ]
        }
      },
      "typeVersion": 3.4
    },
    {
      "id": "a40f44bc-efee-4c89-8fbc-77cd0d09ff3e",
      "name": "AIエージェント",
      "type": "@n8n/n8n-nodes-langchain.agent",
      "position": [
        224,
        0
      ],
      "parameters": {
        "text": "=field of interest: {{ $json.field_of_interest }}\ntarget country: {{ $json.target_country }}",
        "options": {
          "systemMessage": "You are an assistant designed to generate Google search queries based on user instructions. Your sole task is to create queries following a specific format like the one below:\n\nsite:instagram.com/*/ (inurl:\"/beauty\" OR inurl:\"/hair\" OR intitle:\"beauty\" OR intitle:\"hair\") (\"England\" OR \"UK\" OR \"London\" OR \"Manchester\" OR \"Birmingham\" OR \"Liverpool\" OR \"Leeds\") (\"@gmail.com\" OR \"@yahoo.com\" OR \"@hotmail.com\" OR \"@outlook.com\" OR \"@aol.com\" OR \"@icloud.com\") -inurl:\"/p/\" -inurl:\"/reel/\" -inurl:\"/tv/\"\n\nYour output must:\n\n1. Only return the Google search query, no explanation or extra text.\n\n2. Replace the niche-related keywords (e.g., \"beauty\" or \"hair\") with the field of interest specified by the user.\n\n3. Replace the location filters (e.g., \"England\", \"UK\", \"London\") with the target country provided by the user. Add cities related to the target country as well.\n\n4. Always include the email provider filters:\n(\"@gmail.com\" OR \"@yahoo.com\" OR \"@hotmail.com\" OR \"@outlook.com\" OR \"@aol.com\" OR \"@icloud.com\")\n\n5. Always exclude media content using:\n-inurl:\"/p/\" -inurl:\"/reel/\" -inurl:\"/tv/\"\n\n6. Ensure the query remains **clean, optimized, and structurally consistent** with the original format. Do **not explain** the query — return only the **raw search string**.\n"
        },
        "promptType": "define"
      },
      "typeVersion": 1.9
    },
    {
      "id": "79b4c5f6-7fe9-46eb-932b-4d98593c2607",
      "name": "OpenAIチャットモデル",
      "type": "@n8n/n8n-nodes-langchain.lmChatOpenAi",
      "position": [
        224,
        208
      ],
      "parameters": {
        "model": {
          "__rl": true,
          "mode": "list",
          "value": "gpt-4o-mini"
        },
        "options": {}
      },
      "credentials": {
        "openAiApi": {
          "id": "dUQjRoJSrkOznqAl",
          "name": "My OpenAi account "
        }
      },
      "typeVersion": 1.2
    },
    {
      "id": "d2eecb84-b111-401c-9fb2-91722625cb66",
      "name": "HTTPリクエスト",
      "type": "n8n-nodes-base.httpRequest",
      "position": [
        736,
        32
      ],
      "parameters": {
        "url": "https://api.apify.com/v2/acts/apify~google-search-scraper/run-sync-get-dataset-items?token=apify_api_YOUR_TOKEN_HERE",
        "options": {},
        "jsonBody": "={\n    \"focusOnPaidAds\": false,\n    \"forceExactMatch\": false,\n    \"includeIcons\": false,\n    \"includeUnfilteredResults\": false,\n    \"maxPagesPerQuery\": 20,\n    \"mobileResults\": false,\n    \"queries\": \"{{ $json.escapedQuery }}\",\n    \"resultsPerPage\": 100,\n    \"saveHtml\": false,\n    \"saveHtmlToKeyValueStore\": true\n} ",
        "sendBody": true,
        "specifyBody": "json"
      },
      "typeVersion": 4.2
    },
    {
      "id": "ff3a6ff0-f66f-499d-b56f-2ae8f22534ba",
      "name": "コード",
      "type": "n8n-nodes-base.code",
      "position": [
        496,
        0
      ],
      "parameters": {
        "jsCode": "// n8n Function node code\nconst inputQuery = $input.first().json.output;\n\n// Replace all \" with \\\"\nconst escapedQuery = inputQuery.replace(/\"/g, '\\\\\"');\n\n// Return as output\nreturn [\n  {\n    json: {\n      escapedQuery\n    }\n  }\n];"
      },
      "typeVersion": 2
    },
    {
      "id": "dd29f519-c629-4302-ad17-e1a5b0555e46",
      "name": "分割出力",
      "type": "n8n-nodes-base.splitOut",
      "position": [
        896,
        32
      ],
      "parameters": {
        "options": {},
        "fieldToSplitOut": "organicResults"
      },
      "typeVersion": 1
    },
    {
      "id": "32b57f66-c3cd-4a04-a787-3f7662af13c2",
      "name": "HTTPリクエスト1",
      "type": "n8n-nodes-base.httpRequest",
      "position": [
        1456,
        80
      ],
      "parameters": {
        "url": "https://api.apify.com/v2/acts/apify~instagram-scraper/run-sync-get-dataset-items?token=apify_api_YOUR_TOKEN_HERE",
        "options": {},
        "jsonBody": "={\n    \"addParentData\": false,\n    \"directUrls\": [\n        \"{{ $json.cleanedUrl }}\"\n    ],\n    \"enhanceUserSearchWithFacebookPage\": false,\n    \"isUserReelFeedURL\": false,\n    \"isUserTaggedFeedURL\": false,\n    \"resultsLimit\": 2,\n    \"resultsType\": \"details\",\n    \"searchLimit\": 1,\n    \"searchType\": \"hashtag\"\n} ",
        "sendBody": true,
        "specifyBody": "json"
      },
      "typeVersion": 4.2
    },
    {
      "id": "6e52cddd-1cf2-433f-8f78-cd1f0f2d89ad",
      "name": "コード1",
      "type": "n8n-nodes-base.code",
      "position": [
        1312,
        80
      ],
      "parameters": {
        "jsCode": "// n8n Function node code\nconst inputUrl = $input.first().json.url;\n\n// Remove trailing slash if present\nconst cleanedUrl = inputUrl.replace(/\\/$/, \"\");\n\nreturn [\n  {\n    json: {\n      cleanedUrl\n    }\n  }\n];\n"
      },
      "typeVersion": 2
    },
    {
      "id": "28aaf56d-ee27-4a81-9cd7-b0e43d13aeb9",
      "name": "情報抽出器",
      "type": "@n8n/n8n-nodes-langchain.informationExtractor",
      "position": [
        1600,
        80
      ],
      "parameters": {
        "text": "={{ $json.biography }}",
        "options": {
          "systemPromptTemplate": "You are an expert extraction algorithm. Extract relevant information from the given web scraped text data and present it in JSON format with the attribute Email . If email attribute is not found in the text, assign them the value \"N/A\". Always extract email address in small hand."
        },
        "schemaType": "manual",
        "inputSchema": "{\n\t\"type\": \"array\",\n\t\"properties\": {\n\t\t\"Email\": {\n\t\t\t\"type\": \"string\",\n\t\t\t\"format\": \"email\"\n\t\t}\n\t}\n}"
      },
      "typeVersion": 1
    },
    {
      "id": "f2a03fb3-9171-482e-b078-05a5dff93e6a",
      "name": "OpenAIチャットモデル1",
      "type": "@n8n/n8n-nodes-langchain.lmChatOpenAi",
      "position": [
        1600,
        304
      ],
      "parameters": {
        "model": {
          "__rl": true,
          "mode": "list",
          "value": "gpt-3.5-turbo",
          "cachedResultName": "gpt-3.5-turbo"
        },
        "options": {}
      },
      "credentials": {
        "openAiApi": {
          "id": "dUQjRoJSrkOznqAl",
          "name": "My OpenAi account "
        }
      },
      "typeVersion": 1.2
    },
    {
      "id": "9d1fbc5b-538a-4d82-a897-00a03ce4d5cc",
      "name": "アイテムのループ処理",
      "type": "n8n-nodes-base.splitInBatches",
      "position": [
        1152,
        32
      ],
      "parameters": {
        "options": {}
      },
      "typeVersion": 3
    },
    {
      "id": "067b1f22-eb31-4573-80e1-47fac5bddb7b",
      "name": "Postgres",
      "type": "n8n-nodes-base.postgres",
      "position": [
        2032,
        80
      ],
      "parameters": {
        "table": {
          "__rl": true,
          "mode": "list",
          "value": "Instagram_Leads_Beauty&Hair",
          "cachedResultName": "Instagram_Leads_Beauty&Hair"
        },
        "schema": {
          "__rl": true,
          "mode": "list",
          "value": "public"
        },
        "columns": {
          "value": {
            "email": "={{ $('Filter').item.json.output[0].Email }}",
            "user_name": "={{ $('HTTP Request1').item.json.username }}",
            "account_link": "={{ $('HTTP Request1').item.json.inputUrl }}",
            "follower_count": "={{ $('HTTP Request1').item.json.followsCount }}",
            "target_country": "={{ $('Edit Fields').item.json.target_country }}",
            "field_of_interest": "={{ $('Edit Fields').item.json.field_of_interest }}"
          },
          "schema": [
            {
              "id": "user_name",
              "type": "string",
              "display": true,
              "removed": false,
              "required": true,
              "displayName": "user_name",
              "defaultMatch": false,
              "canBeUsedToMatch": true
            },
            {
              "id": "follower_count",
              "type": "number",
              "display": true,
              "required": true,
              "displayName": "follower_count",
              "defaultMatch": false,
              "canBeUsedToMatch": false
            },
            {
              "id": "account_link",
              "type": "string",
              "display": true,
              "required": false,
              "displayName": "account_link",
              "defaultMatch": false,
              "canBeUsedToMatch": false
            },
            {
              "id": "email",
              "type": "string",
              "display": true,
              "required": false,
              "displayName": "email",
              "defaultMatch": false,
              "canBeUsedToMatch": false
            },
            {
              "id": "target_country",
              "type": "string",
              "display": true,
              "required": false,
              "displayName": "target_country",
              "defaultMatch": false,
              "canBeUsedToMatch": false
            },
            {
              "id": "field_of_interest",
              "type": "string",
              "display": true,
              "required": false,
              "displayName": "field_of_interest",
              "defaultMatch": false,
              "canBeUsedToMatch": false
            }
          ],
          "mappingMode": "defineBelow",
          "matchingColumns": [
            "user_name"
          ],
          "attemptToConvertTypes": false,
          "convertFieldsToString": false
        },
        "options": {},
        "operation": "upsert"
      },
      "credentials": {
        "postgres": {
          "id": "sZAvcVeX17fuVXQz",
          "name": "Postgres account"
        }
      },
      "typeVersion": 2.6
    },
    {
      "id": "c8d53921-24d1-4f79-ab40-2f5794f0f057",
      "name": "付箋",
      "type": "n8n-nodes-base.stickyNote",
      "position": [
        -112,
        -128
      ],
      "parameters": {
        "color": 5,
        "width": 256,
        "height": 304,
        "content": "## Specifying Our Target Niche \n"
      },
      "typeVersion": 1
    },
    {
      "id": "a466c89c-8766-4927-871c-474a67a42265",
      "name": "付箋1",
      "type": "n8n-nodes-base.stickyNote",
      "position": [
        176,
        -128
      ],
      "parameters": {
        "width": 464,
        "height": 464,
        "content": "## Generating Custom Optimized Search Engine Query for finding Instagram Accounts\n"
      },
      "typeVersion": 1
    },
    {
      "id": "8d2a5c18-c22b-4773-8890-12fa1e0b7913",
      "name": "付箋2",
      "type": "n8n-nodes-base.stickyNote",
      "position": [
        672,
        -128
      ],
      "parameters": {
        "color": 3,
        "width": 368,
        "height": 336,
        "content": "## Extracting Search Results Using Apify Api"
      },
      "typeVersion": 1
    },
    {
      "id": "6d5711e0-b5d3-43ee-b1f4-b8db6c853d7d",
      "name": "付箋3",
      "type": "n8n-nodes-base.stickyNote",
      "position": [
        1072,
        -128
      ],
      "parameters": {
        "color": 4,
        "width": 848,
        "height": 560,
        "content": "## Going Through Each of the Accounts & Extracting Leads From User's Bio"
      },
      "typeVersion": 1
    },
    {
      "id": "0c298e44-251f-4718-9f58-ba8904cb2708",
      "name": "付箋4",
      "type": "n8n-nodes-base.stickyNote",
      "position": [
        1952,
        -32
      ],
      "parameters": {
        "color": 6,
        "width": 256,
        "height": 272,
        "content": "## Storing Leads In PostgreSQL"
      },
      "typeVersion": 1
    }
  ],
  "active": false,
  "pinData": {},
  "settings": {
    "executionOrder": "v1"
  },
  "versionId": "cd76a0c4-c864-4bb3-906f-57bfb43d2a9e",
  "connections": {
    "ff3a6ff0-f66f-499d-b56f-2ae8f22534ba": {
      "main": [
        [
          {
            "node": "d2eecb84-b111-401c-9fb2-91722625cb66",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "6e52cddd-1cf2-433f-8f78-cd1f0f2d89ad": {
      "main": [
        [
          {
            "node": "32b57f66-c3cd-4a04-a787-3f7662af13c2",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "a40f44bc-efee-4c89-8fbc-77cd0d09ff3e": {
      "main": [
        [
          {
            "node": "ff3a6ff0-f66f-499d-b56f-2ae8f22534ba",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "067b1f22-eb31-4573-80e1-47fac5bddb7b": {
      "main": [
        [
          {
            "node": "9d1fbc5b-538a-4d82-a897-00a03ce4d5cc",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "dd29f519-c629-4302-ad17-e1a5b0555e46": {
      "main": [
        [
          {
            "node": "9d1fbc5b-538a-4d82-a897-00a03ce4d5cc",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "9990229b-1098-4ff5-8906-c57a260f4d15": {
      "main": [
        [
          {
            "node": "a40f44bc-efee-4c89-8fbc-77cd0d09ff3e",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "d2eecb84-b111-401c-9fb2-91722625cb66": {
      "main": [
        [
          {
            "node": "dd29f519-c629-4302-ad17-e1a5b0555e46",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "32b57f66-c3cd-4a04-a787-3f7662af13c2": {
      "main": [
        [
          {
            "node": "28aaf56d-ee27-4a81-9cd7-b0e43d13aeb9",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "9d1fbc5b-538a-4d82-a897-00a03ce4d5cc": {
      "main": [
        [],
        [
          {
            "node": "6e52cddd-1cf2-433f-8f78-cd1f0f2d89ad",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "79b4c5f6-7fe9-46eb-932b-4d98593c2607": {
      "ai_languageModel": [
        [
          {
            "node": "a40f44bc-efee-4c89-8fbc-77cd0d09ff3e",
            "type": "ai_languageModel",
            "index": 0
          }
        ]
      ]
    },
    "f2a03fb3-9171-482e-b078-05a5dff93e6a": {
      "ai_languageModel": [
        [
          {
            "node": "28aaf56d-ee27-4a81-9cd7-b0e43d13aeb9",
            "type": "ai_languageModel",
            "index": 0
          }
        ]
      ]
    },
    "28aaf56d-ee27-4a81-9cd7-b0e43d13aeb9": {
      "main": [
        [
          {
            "node": "067b1f22-eb31-4573-80e1-47fac5bddb7b",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "5f49d3d3-5e81-4b9d-9bc4-687ee97e2e8f": {
      "main": [
        [
          {
            "node": "9990229b-1098-4ff5-8906-c57a260f4d15",
            "type": "main",
            "index": 0
          }
        ]
      ]
    }
  }
}
よくある質問

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

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

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

上級 - リード獲得, AI RAG検索拡張

有料ですか?

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

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

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

外部リンク
n8n.ioで表示

このワークフローを共有

カテゴリー

カテゴリー: 34