AutomationFlowsAI & RAG › Instagram Content & Dm Automation with Gemini, Telegram, and Apify

Instagram Content & Dm Automation with Gemini, Telegram, and Apify

ByMsaid Mohamed el hadi @mohamedgb00714 on n8n.io

This cutting-edge n8n workflow is a comprehensive automation solution designed to streamline various Instagram operations. It combines an intelligent AI chatbot for direct message management, automated user following, and an advanced content generation system, all integrated to…

Cron / scheduled trigger★★★★★ complexityAI-powered47 nodesAgentOpenRouter ChatOutput Parser StructuredTelegramGoogle SheetsTelegram TriggerHTTP Request
AI & RAG Trigger: Cron / scheduled Nodes: 47 Complexity: ★★★★★ AI nodes: yes Added:
Instagram Content & Dm Automation with Gemini, Telegram, and Apify — n8n workflow card showing Agent, OpenRouter Chat, Output Parser Structured integration

This workflow corresponds to n8n.io template #6070 — we link there as the canonical source.

This workflow follows the Agent → Google Sheets recipe pattern — see all workflows that pair these two integrations.

The workflow JSON

Copy or download the full n8n JSON below. Paste it into a new n8n workflow, add your credentials, activate. Full import guide →

Download .json
{
  "id": "YYzDjKpAG0xrnjyf",
  "meta": {
    "templateCredsSetupCompleted": true
  },
  "name": "Ai Instagram Infulancer",
  "tags": [
    {
      "id": "Z0UZqegKEMBA05cu",
      "name": "ai",
      "createdAt": "2025-07-02T23:37:46.198Z",
      "updatedAt": "2025-07-02T23:37:46.198Z"
    }
  ],
  "nodes": [
    {
      "id": "fed71dfe-6164-43a7-8ebb-3be8da1549a9",
      "name": "Schedule Trigger",
      "type": "n8n-nodes-base.scheduleTrigger",
      "position": [
        -660,
        1040
      ],
      "parameters": {
        "rule": {
          "interval": [
            {
              "field": "hours"
            }
          ]
        }
      },
      "typeVersion": 1.2
    },
    {
      "id": "9b7fc94b-b9b9-4d2d-8023-af348d9855f5",
      "name": "Sticky Note",
      "type": "n8n-nodes-base.stickyNote",
      "position": [
        -700,
        900
      ],
      "parameters": {
        "color": 5,
        "width": 901,
        "height": 390,
        "content": "## instagram direct messages Chat Bot\n"
      },
      "typeVersion": 1
    },
    {
      "id": "76fff1ad-fb62-49ca-9e00-113061056c9b",
      "name": "Switch",
      "type": "n8n-nodes-base.switch",
      "position": [
        -200,
        200
      ],
      "parameters": {
        "rules": {
          "values": [
            {
              "conditions": {
                "options": {
                  "version": 2,
                  "leftValue": "",
                  "caseSensitive": true,
                  "typeValidation": "strict"
                },
                "combinator": "and",
                "conditions": [
                  {
                    "id": "b9003ff7-cb12-4573-bd0d-1505f6934a3c",
                    "operator": {
                      "type": "string",
                      "operation": "equals"
                    },
                    "leftValue": "={{ $json.message.from.username }}",
                    "rightValue": "Wolf23000"
                  }
                ]
              }
            },
            {
              "conditions": {
                "options": {
                  "version": 2,
                  "leftValue": "",
                  "caseSensitive": true,
                  "typeValidation": "strict"
                },
                "combinator": "and",
                "conditions": [
                  {
                    "id": "1cd7eca1-330c-4391-abb4-869378c3743f",
                    "operator": {
                      "type": "string",
                      "operation": "exists",
                      "singleValue": true
                    },
                    "leftValue": "={{ $json.message.text }}",
                    "rightValue": ""
                  }
                ]
              }
            }
          ]
        },
        "options": {}
      },
      "typeVersion": 3.2
    },
    {
      "id": "f944fc07-ba80-45c2-89c5-e140d4a78938",
      "name": "Edit Fields",
      "type": "n8n-nodes-base.set",
      "position": [
        300,
        180
      ],
      "parameters": {
        "options": {},
        "assignments": {
          "assignments": [
            {
              "id": "c195d657-f27c-439c-a2c8-f5bb506ac096",
              "name": "message.text",
              "type": "string",
              "value": "={{ $json.message.text }}"
            }
          ]
        }
      },
      "typeVersion": 3.4
    },
    {
      "id": "d33c8cc6-fa2f-417b-8a23-b95ab550967d",
      "name": "AI Agent",
      "type": "@n8n/n8n-nodes-langchain.agent",
      "position": [
        580,
        180
      ],
      "parameters": {
        "text": "={{ $json.message.text }}",
        "options": {
          "systemMessage": "You are a helpful assistant you deside if  this message\n\n it's a run agent order\" when asked you about profile or chat info etc all related to instagram pass it to actionsnot chat\" or not  \noutput should be like that\nschema\n{\n\t\"type\": \"object\",\n\t\"properties\": {\n\t\t\"action\": {\n\t\t\t\"type\": \"string\"\n\t\t},\n\t\t\"inputMsg\": {\n\t\t\t\t\"type\": \"string\"\n\t\t\t\n\t\t},\n\t\t\"outputMsg\": {\n\t\t\t\"type\": \"string\"\n\t\t\t\n\t\t\n\t}\n    }\n}\nexample result \n{\n\"action\":\"run_agent\",\n\"inputMsg\":\"chat with mohamed el hadi and ask him when he will be available for a call\",\n\"outputMsg\":\"comment\"\n}\npossible actions\n\"chat_back\"\n \"run_agent\",\n        \"post_instagram_post\",\n        \"get_instagram_profile\",\n        \"follow_instagram_users\""
        },
        "promptType": "define",
        "hasOutputParser": true
      },
      "typeVersion": 2
    },
    {
      "id": "6bc91a1e-2c1a-403c-a3b1-484e1730bdcc",
      "name": "OpenRouter Chat Model1",
      "type": "@n8n/n8n-nodes-langchain.lmChatOpenRouter",
      "position": [
        920,
        400
      ],
      "parameters": {
        "model": "google/gemini-2.5-flash-preview",
        "options": {}
      },
      "credentials": {
        "openRouterApi": {
          "name": "<your credential>"
        }
      },
      "typeVersion": 1
    },
    {
      "id": "af6ea098-d912-45d9-bafb-9b6ec24caa71",
      "name": "Structured Output Parser",
      "type": "@n8n/n8n-nodes-langchain.outputParserStructured",
      "position": [
        660,
        420
      ],
      "parameters": {
        "schemaType": "manual",
        "inputSchema": "{\n\t\"type\": \"object\",\n\t\"properties\": {\n\t\t\"action\": {\n\t\t\t\"type\": \"string\"\n\t\t},\n\t\t\"inputMsg\": {\n\t\t\t\t\"type\": \"string\"\n\t\t\t\n\t\t},\n\t\t\"outputMsg\": {\n\t\t\t\"type\": \"string\"\n\t\t\t\n\t\t\n\t}\n    }\n}"
      },
      "typeVersion": 1.3
    },
    {
      "id": "aab1895d-80df-4def-8932-5d328508714c",
      "name": "Switch1",
      "type": "n8n-nodes-base.switch",
      "position": [
        1020,
        200
      ],
      "parameters": {
        "rules": {
          "values": [
            {
              "conditions": {
                "options": {
                  "version": 2,
                  "leftValue": "",
                  "caseSensitive": true,
                  "typeValidation": "strict"
                },
                "combinator": "and",
                "conditions": [
                  {
                    "id": "24512c17-6747-4826-b926-0de18abd2f67",
                    "operator": {
                      "type": "string",
                      "operation": "equals"
                    },
                    "leftValue": "={{ $json.output.action }}",
                    "rightValue": "chat_back"
                  }
                ]
              }
            },
            {
              "conditions": {
                "options": {
                  "version": 2,
                  "leftValue": "",
                  "caseSensitive": true,
                  "typeValidation": "strict"
                },
                "combinator": "and",
                "conditions": [
                  {
                    "id": "41d22bb0-3ea9-49b7-8391-e3cd579b294b",
                    "operator": {
                      "name": "filter.operator.equals",
                      "type": "string",
                      "operation": "equals"
                    },
                    "leftValue": "={{ $json.output.action }}",
                    "rightValue": "run_agent"
                  }
                ]
              }
            },
            {
              "conditions": {
                "options": {
                  "version": 2,
                  "leftValue": "",
                  "caseSensitive": true,
                  "typeValidation": "strict"
                },
                "combinator": "and",
                "conditions": [
                  {
                    "id": "c5979b49-5d73-4a22-9661-886a542d2dd3",
                    "operator": {
                      "name": "filter.operator.equals",
                      "type": "string",
                      "operation": "equals"
                    },
                    "leftValue": "={{ $json.output.action }}",
                    "rightValue": "get_instagram_profile"
                  }
                ]
              }
            }
          ]
        },
        "options": {}
      },
      "typeVersion": 3.2
    },
    {
      "id": "2dcd6863-a13e-428c-8b06-072ca54aac1e",
      "name": "Send a text message",
      "type": "n8n-nodes-base.telegram",
      "position": [
        1580,
        280
      ],
      "parameters": {
        "text": "={{ $json.status }}:{{ $json.result }}",
        "chatId": "={{ $('Telegram New Message Trigger').item.json.message.chat.id }}",
        "additionalFields": {}
      },
      "credentials": {
        "telegramApi": {
          "name": "<your credential>"
        }
      },
      "typeVersion": 1.2
    },
    {
      "id": "0ed5b55b-cd1e-4b30-90cc-002ee27c81bd",
      "name": "Send a text message1",
      "type": "n8n-nodes-base.telegram",
      "position": [
        1500,
        80
      ],
      "parameters": {
        "text": "={{ $json.output.outputMsg }}",
        "chatId": "={{ $('Telegram New Message Trigger').item.json.message.chat.id }}",
        "additionalFields": {}
      },
      "credentials": {
        "telegramApi": {
          "name": "<your credential>"
        }
      },
      "typeVersion": 1.2
    },
    {
      "id": "a1adf339-55cd-481d-948a-a6dea105a072",
      "name": "Send a text message2",
      "type": "n8n-nodes-base.telegram",
      "position": [
        1500,
        400
      ],
      "parameters": {
        "text": "={{ $json.status }}:{{ $json.result }}",
        "chatId": "={{ $('Telegram New Message Trigger').item.json.message.chat.id }}",
        "additionalFields": {}
      },
      "credentials": {
        "telegramApi": {
          "name": "<your credential>"
        }
      },
      "typeVersion": 1.2
    },
    {
      "id": "e0db9d40-36aa-4139-a7e8-9fb96fc62b63",
      "name": "Sticky Note1",
      "type": "n8n-nodes-base.stickyNote",
      "position": [
        -700,
        60
      ],
      "parameters": {
        "width": 2700,
        "height": 800,
        "content": "## Telegram integration\n"
      },
      "typeVersion": 1
    },
    {
      "id": "24d27c9e-8eeb-4bf4-9dce-c7405782fe99",
      "name": "Schedule Trigger1",
      "type": "n8n-nodes-base.scheduleTrigger",
      "position": [
        360,
        1040
      ],
      "parameters": {
        "rule": {
          "interval": [
            {}
          ]
        }
      },
      "typeVersion": 1.2
    },
    {
      "id": "6afc03e8-5562-4ffe-b9db-e722ba5037a0",
      "name": "Code",
      "type": "n8n-nodes-base.code",
      "position": [
        880,
        1040
      ],
      "parameters": {
        "jsCode": "const items = $input.all().slice(0,5);\nconst usernames = items.map((item) => item?.json?.usernames);\nreturn { usernames };\n"
      },
      "typeVersion": 2
    },
    {
      "id": "84a56f99-1bb3-409e-b302-34a9088d6b3b",
      "name": "Code1",
      "type": "n8n-nodes-base.code",
      "position": [
        1260,
        1040
      ],
      "parameters": {
        "jsCode": "const items = $input.all();\nconst usernames = items[0].json?.followed_usernames.map((item) => ({\n  usernames: item,\n}));\nreturn usernames;\n"
      },
      "typeVersion": 2
    },
    {
      "id": "bf54ed3b-5095-48e5-9758-83957625bd32",
      "name": "Sticky Note2",
      "type": "n8n-nodes-base.stickyNote",
      "position": [
        260,
        920
      ],
      "parameters": {
        "color": 6,
        "width": 1480,
        "height": 380,
        "content": "## Auto Follow users from sheet\n"
      },
      "typeVersion": 1
    },
    {
      "id": "05e67dbf-b5e7-4fce-b707-6a84911a3aea",
      "name": "Schedule Trigger2",
      "type": "n8n-nodes-base.scheduleTrigger",
      "position": [
        -640,
        1400
      ],
      "parameters": {
        "rule": {
          "interval": [
            {
              "field": "months"
            }
          ]
        }
      },
      "typeVersion": 1.2
    },
    {
      "id": "ed45c5e0-a4be-4492-8a7f-783385d7454d",
      "name": "AI Agent1",
      "type": "@n8n/n8n-nodes-langchain.agent",
      "position": [
        -300,
        1400
      ],
      "parameters": {
        "text": "=Based on the following Instagram personality profile:\n{{ $json.user_personality }}\nGenerate exactly 31 or30 based of number of days on current month  Instagram post ideas for the current month [{{ $json.Month }}-{{ $json.Year }}] \u2014 one for each day.\n\nEach post must include:\n- `imagePrompt`: A short visual description that could be used for image generation (15\u201330 words)\n- `caption`: An engaging Instagram caption matching Sophia\u2019s tone, using emojis\n- `scheduledDate`: A random day and time in the current month (between 09:00 and 18:00)\n\nOutput should be a **valid JSON array** with 31 objects. Do not include explanations or commentary.\n\nExample:\n[\n  {\n    \"imagePrompt\": \"A journal with coffee on a wooden table\",\n    \"caption\": \"\u2615\u2728 Start your day with intention. Journaling clears the mind and centers the soul. #MorningRitual\",\n    \"scheduledDate\": \"2025-08-01\"\n  },\n  ...\n]\n",
        "options": {
          "systemMessage": "You are a content strategist specialized in Instagram marketing.\n\nYour task is to generate exactly 31 Instagram post ideas for the current month. Each post must be creative, diverse, and optimized for engagement.\n\nEach post should include:\n- `imagePrompt`: A short, vivid prompt (15\u201330 words) to generate an image (e.g., \u201cA dog playing in autumn leaves\u201d)\n- `caption`: A catchy Instagram caption (with emojis) that matches the image\n- `scheduledDate`: A date in the current month, spaced out across all 31 days.\n\nOutput everything as a valid JSON array. Do **not** include any explanation or commentary \u2014 only the JSON.\n\nExample:\n[\n  {\n    \"imagePrompt\": \"Sunset over a tropical beach\",\n    \"caption\": \"\ud83c\udf05 Nothing beats sunset vibes! #TropicalEscape\",\n    \"scheduledDate\": \"2025-08-01\"\n  },\n  ...\n]\n"
        },
        "promptType": "define",
        "hasOutputParser": true
      },
      "typeVersion": 2
    },
    {
      "id": "e3820684-1433-4034-92af-381721e5e9ac",
      "name": "OpenRouter Chat Model",
      "type": "@n8n/n8n-nodes-langchain.lmChatOpenRouter",
      "position": [
        -240,
        1640
      ],
      "parameters": {
        "model": "google/gemini-2.5-flash-preview",
        "options": {}
      },
      "credentials": {
        "openRouterApi": {
          "name": "<your credential>"
        }
      },
      "typeVersion": 1
    },
    {
      "id": "38a406a9-ec2b-41ae-af75-b6ae9281e8c6",
      "name": "Code2",
      "type": "n8n-nodes-base.code",
      "position": [
        60,
        1400
      ],
      "parameters": {
        "jsCode": "const items = $input.all();\nconst parsedItems=  JSON.parse(items[0].json.output.replace(/```json|```/g, '').trim());\n \nreturn parsedItems;\n"
      },
      "typeVersion": 2
    },
    {
      "id": "2c26f4d5-f6a4-45c7-b183-622583209fac",
      "name": "Sticky Note3",
      "type": "n8n-nodes-base.stickyNote",
      "position": [
        -700,
        1320
      ],
      "parameters": {
        "width": 1320,
        "height": 440,
        "content": "## Generate posts plain Based on Your personality JSON"
      },
      "typeVersion": 1
    },
    {
      "id": "6d4da745-460b-429f-ac91-572cb48d5e53",
      "name": "Schedule Trigger3",
      "type": "n8n-nodes-base.scheduleTrigger",
      "position": [
        720,
        1460
      ],
      "parameters": {
        "rule": {
          "interval": [
            {
              "triggerAtHour": 9
            }
          ]
        }
      },
      "typeVersion": 1.2
    },
    {
      "id": "f5923cf6-c9da-45e9-98e0-b3f8c7033461",
      "name": "AI Agent2",
      "type": "@n8n/n8n-nodes-langchain.agent",
      "position": [
        1440,
        1460
      ],
      "parameters": {
        "text": "={\nrow_number:{{ $json.row_number }},\nimagePrompt:{{ $json.imagePrompt }},\ncaption:{{ $json.caption }},\nscheduledDate:{{ $json.scheduledDate }}\n}",
        "options": {
          "systemMessage": "You are an expert Instagram content strategist and prompt engineer for AI-generated visuals.\n\nYour task is to process a JSON object representing an Instagram post idea and improve it for publication. This includes:\n\n1. Enhancing the `imagePrompt` to make it much more vivid, descriptive, and suitable for AI image generation (DALL\u00b7E, Midjourney, etc.). Use clear descriptions of:\n   - Environment and background\n   - Characters and their appearance\n   - Actions or mood\n   - Lighting, color tone, and style\n   - Camera angle or composition (optional)\n   - Art style (e.g., photo-realistic, cinematic, flat illustration \u2014 if implied)\n\n2. Refining the `caption` to make it concise, engaging, grammatically polished, and aligned with Instagram best practices (emoji use, tone, and formatting).\n\nReturn your result as a valid JSON object with the following fields:\n- `row_number`: Same as input.\n- `enhancedImagePrompt`: Fully-detailed, visual, AI-ready description (1\u20132 sentences max).\n- `enhancedCaption`: Polished caption with emojis and hashtags (do not make it robotic).\n- `scheduledDate`: Unchanged from input.\n"
        },
        "promptType": "define"
      },
      "typeVersion": 2
    },
    {
      "id": "f8ceed46-423b-4208-9f8e-1e3e6cb717e8",
      "name": "OpenRouter Chat Model2",
      "type": "@n8n/n8n-nodes-langchain.lmChatOpenRouter",
      "position": [
        1440,
        1700
      ],
      "parameters": {
        "model": "google/gemini-2.5-flash-preview",
        "options": {}
      },
      "credentials": {
        "openRouterApi": {
          "name": "<your credential>"
        }
      },
      "typeVersion": 1
    },
    {
      "id": "60faff16-a070-4ba0-bcf9-10466c60a355",
      "name": "Update row in sheet1",
      "type": "n8n-nodes-base.googleSheets",
      "position": [
        760,
        1840
      ],
      "parameters": {
        "columns": {
          "value": {
            "image_url": "={{ $json.output }}",
            "enhancedImagePrompt": "={{ $json.input.prompt }}"
          },
          "schema": [
            {
              "id": "imagePrompt",
              "type": "string",
              "display": true,
              "removed": true,
              "required": false,
              "displayName": "imagePrompt",
              "defaultMatch": false,
              "canBeUsedToMatch": true
            },
            {
              "id": "caption",
              "type": "string",
              "display": true,
              "removed": true,
              "required": false,
              "displayName": "caption",
              "defaultMatch": false,
              "canBeUsedToMatch": true
            },
            {
              "id": "scheduledDate",
              "type": "string",
              "display": true,
              "removed": true,
              "required": false,
              "displayName": "scheduledDate",
              "defaultMatch": false,
              "canBeUsedToMatch": true
            },
            {
              "id": "enhancedImagePrompt",
              "type": "string",
              "display": true,
              "removed": false,
              "required": false,
              "displayName": "enhancedImagePrompt",
              "defaultMatch": false,
              "canBeUsedToMatch": true
            },
            {
              "id": "enhancedCaption",
              "type": "string",
              "display": true,
              "removed": true,
              "required": false,
              "displayName": "enhancedCaption",
              "defaultMatch": false,
              "canBeUsedToMatch": true
            },
            {
              "id": "image_url",
              "type": "string",
              "display": true,
              "removed": false,
              "required": false,
              "displayName": "image_url",
              "defaultMatch": false,
              "canBeUsedToMatch": true
            },
            {
              "id": "row_number",
              "type": "string",
              "display": true,
              "removed": true,
              "readOnly": true,
              "required": false,
              "displayName": "row_number",
              "defaultMatch": false,
              "canBeUsedToMatch": true
            }
          ],
          "mappingMode": "defineBelow",
          "matchingColumns": [
            "enhancedImagePrompt"
          ],
          "attemptToConvertTypes": false,
          "convertFieldsToString": false
        },
        "options": {},
        "operation": "update",
        "sheetName": {
          "__rl": true,
          "mode": "list",
          "value": "gid=0",
          "cachedResultUrl": "https://docs.google.com/spreadsheets/d/1XHNwAXR4USThaAzX1Y6M5PF2P8WqCBU8mi34FBLkV6M/edit#gid=0",
          "cachedResultName": "Sheet1"
        },
        "documentId": {
          "__rl": true,
          "mode": "list",
          "value": "1XHNwAXR4USThaAzX1Y6M5PF2P8WqCBU8mi34FBLkV6M",
          "cachedResultUrl": "https://docs.google.com/spreadsheets/d/1XHNwAXR4USThaAzX1Y6M5PF2P8WqCBU8mi34FBLkV6M/edit?usp=drivesdk",
          "cachedResultName": "posts generation plan"
        }
      },
      "credentials": {
        "googleSheetsOAuth2Api": {
          "name": "<your credential>"
        }
      },
      "typeVersion": 4.6
    },
    {
      "id": "0accecb2-4b7d-439f-937d-91416783fac4",
      "name": "Sticky Note5",
      "type": "n8n-nodes-base.stickyNote",
      "position": [
        660,
        1320
      ],
      "parameters": {
        "color": 4,
        "width": 1860,
        "height": 920,
        "content": "## Generate & auto post Posts"
      },
      "typeVersion": 1
    },
    {
      "id": "2bdac682-a102-4a4c-9a25-769e8bcd3332",
      "name": "Get row(s) in sheet2",
      "type": "n8n-nodes-base.googleSheets",
      "position": [
        1000,
        1840
      ],
      "parameters": {
        "options": {},
        "filtersUI": {
          "values": [
            {
              "lookupValue": "={{ $json.image_url }}",
              "lookupColumn": "image_url"
            }
          ]
        },
        "sheetName": {
          "__rl": true,
          "mode": "list",
          "value": "gid=0",
          "cachedResultUrl": "https://docs.google.com/spreadsheets/d/1XHNwAXR4USThaAzX1Y6M5PF2P8WqCBU8mi34FBLkV6M/edit#gid=0",
          "cachedResultName": "Sheet1"
        },
        "documentId": {
          "__rl": true,
          "mode": "list",
          "value": "1XHNwAXR4USThaAzX1Y6M5PF2P8WqCBU8mi34FBLkV6M",
          "cachedResultUrl": "https://docs.google.com/spreadsheets/d/1XHNwAXR4USThaAzX1Y6M5PF2P8WqCBU8mi34FBLkV6M/edit?usp=drivesdk",
          "cachedResultName": "posts generation plan"
        }
      },
      "credentials": {
        "googleSheetsOAuth2Api": {
          "name": "<your credential>"
        }
      },
      "typeVersion": 4.6
    },
    {
      "id": "ee32e0e5-a868-4917-baf4-ecc448578d3c",
      "name": "Telegram New Message Trigger",
      "type": "n8n-nodes-base.telegramTrigger",
      "position": [
        -640,
        200
      ],
      "parameters": {
        "updates": [
          "message"
        ],
        "additionalFields": {}
      },
      "credentials": {
        "telegramApi": {
          "name": "<your credential>"
        }
      },
      "typeVersion": 1.2
    },
    {
      "id": "948cc068-6918-4e3d-9710-b213b77f26be",
      "name": "Variables",
      "type": "n8n-nodes-base.code",
      "position": [
        -440,
        1040
      ],
      "parameters": {
        "jsCode": "// Loop over input items and add a new field called 'myNewField' to the JSON of each one\nfor (const item of $input.all()) {\n  item.json.openrouterApiKey = \"{{your open router api key }}\";\n   item.json.user_personality= \"{\\n  \\\"user_id\\\": \\\"aethermsaid8\\\",\\n  \\\"username\\\": \\\"aethermsaid8\\\",\\n  \\\"full_name\\\": \\\"Sarah Msaid\\\",\\n  \\\"age\\\": 28,\\n  \\\"location\\\": \\\"Brooklyn, NY\\\",\\n  \\\"bio\\\": \\\"Embracing the beautiful mess. Sharing real life, not just highlight reels. Coffee, cats, and questionable life choices. \u2615\ud83d\udc08\ud83e\udd37\u200d\u2640\ufe0f\\\",\\n  \\\"content_preferences\\\": {\\n    \\\"themes\\\": [\\n      \\\"daily life struggles\\\",\\n      \\\"authentic moments\\\",\\n      \\\"niche hobbies (e.g., vintage board games, obscure indie music)\\\",\\n      \\\"pet antics\\\",\\n      \\\"DIY fails\\\",\\n      \\\"local hidden gems\\\"\\n    ],\\n    \\\"post_frequency_per_week\\\": 3,\\n    \\\"preferred_media_types\\\": [\\n      \\\"photo\\\",\\n      \\\"carousel\\\",\\n      \\\"short-form video (reels)\\\"\\n    ],\\n    \\\"caption_style\\\": \\\"humorous, self-deprecating, relatable, conversational, slightly cynical but ultimately warm\\\",\\n    \\\"hashtag_style\\\": \\\"mix of popular, niche, and ironic hashtags\\\"\\n  },\\n  \\\"personality_traits\\\": {\\n    \\\"values\\\": [\\n      \\\"authenticity\\\",\\n      \\\"humor\\\",\\n      \\\"creativity\\\",\\n      \\\"community\\\",\\n      \\\"self-acceptance\\\"\\n    ],\\n    \\\"interests\\\": [\\n      \\\"independent cinema\\\",\\n      \\\"thrift store finds\\\",\\n      \\\"cooking (badly)\\\",\\n      \\\"reading obscure non-fiction\\\",\\n      \\\"urban exploration\\\",\\n      \\\"cats\\\"\\n    ],\\n    \\\"tone_of_voice_keywords\\\": [\\n      \\\"sarcastic\\\",\\n      \\\"witty\\\", \\\"down-to-earth\\\",\\n      \\\"observational\\\",\\n      \\\"playful\\\"\\n    ]\\n  },\\n  \\\"unfulancer_attributes\\\": {\\n    \\\"reason_for_unfulancing\\\": \\\"prefers genuine connection over chasing virality\\\",\\n    \\\"content_focus\\\": \\\"relatability over perfection\\\",\\n    \\\"niche_appeal\\\": \\\"attracts followers who are tired of curated feeds\\\",\\n    \\\"monetization_approach\\\": \\\"minimal or none, occasional genuine collaborations with small businesses\\\"\\n  }\\n}\"\n  \n\n \n  item.json.instagram_session_id=\"{{ your instagram session ID }}\"\n  \n}\n\nreturn $input.all();"
      },
      "typeVersion": 2
    },
    {
      "id": "cb59f3e3-1443-4910-850e-3ce7db9eb952",
      "name": "Variables1",
      "type": "n8n-nodes-base.code",
      "position": [
        -440,
        200
      ],
      "parameters": {
        "jsCode": "// Loop over input items and add a new field called 'myNewField' to the JSON of each one\nfor (const item of $input.all()) {\n  item.json.openrouterApiKey = \"{{your open router api key }}\";\n   item.json.user_personality= \"{\\n  \\\"user_id\\\": \\\"aethermsaid8\\\",\\n  \\\"username\\\": \\\"aethermsaid8\\\",\\n  \\\"full_name\\\": \\\"Sarah Msaid\\\",\\n  \\\"age\\\": 28,\\n  \\\"location\\\": \\\"Brooklyn, NY\\\",\\n  \\\"bio\\\": \\\"Embracing the beautiful mess. Sharing real life, not just highlight reels. Coffee, cats, and questionable life choices. \u2615\ud83d\udc08\ud83e\udd37\u200d\u2640\ufe0f\\\",\\n  \\\"content_preferences\\\": {\\n    \\\"themes\\\": [\\n      \\\"daily life struggles\\\",\\n      \\\"authentic moments\\\",\\n      \\\"niche hobbies (e.g., vintage board games, obscure indie music)\\\",\\n      \\\"pet antics\\\",\\n      \\\"DIY fails\\\",\\n      \\\"local hidden gems\\\"\\n    ],\\n    \\\"post_frequency_per_week\\\": 3,\\n    \\\"preferred_media_types\\\": [\\n      \\\"photo\\\",\\n      \\\"carousel\\\",\\n      \\\"short-form video (reels)\\\"\\n    ],\\n    \\\"caption_style\\\": \\\"humorous, self-deprecating, relatable, conversational, slightly cynical but ultimately warm\\\",\\n    \\\"hashtag_style\\\": \\\"mix of popular, niche, and ironic hashtags\\\"\\n  },\\n  \\\"personality_traits\\\": {\\n    \\\"values\\\": [\\n      \\\"authenticity\\\",\\n      \\\"humor\\\",\\n      \\\"creativity\\\",\\n      \\\"community\\\",\\n      \\\"self-acceptance\\\"\\n    ],\\n    \\\"interests\\\": [\\n      \\\"independent cinema\\\",\\n      \\\"thrift store finds\\\",\\n      \\\"cooking (badly)\\\",\\n      \\\"reading obscure non-fiction\\\",\\n      \\\"urban exploration\\\",\\n      \\\"cats\\\"\\n    ],\\n    \\\"tone_of_voice_keywords\\\": [\\n      \\\"sarcastic\\\",\\n      \\\"witty\\\", \\\"down-to-earth\\\",\\n      \\\"observational\\\",\\n      \\\"playful\\\"\\n    ]\\n  },\\n  \\\"unfulancer_attributes\\\": {\\n    \\\"reason_for_unfulancing\\\": \\\"prefers genuine connection over chasing virality\\\",\\n    \\\"content_focus\\\": \\\"relatability over perfection\\\",\\n    \\\"niche_appeal\\\": \\\"attracts followers who are tired of curated feeds\\\",\\n    \\\"monetization_approach\\\": \\\"minimal or none, occasional genuine collaborations with small businesses\\\"\\n  }\\n}\"\n  \n\n \n  item.json.instagram_session_id=\"{{ your instagram session ID }}\"\n  \n}\n\nreturn $input.all();"
      },
      "typeVersion": 2
    },
    {
      "id": "ac53bcc1-f7d8-4769-bf1d-bf454b6aedcd",
      "name": "Variables2",
      "type": "n8n-nodes-base.code",
      "position": [
        520,
        1040
      ],
      "parameters": {
        "jsCode": "// Loop over input items and add a new field called 'myNewField' to the JSON of each one\nfor (const item of $input.all()) {\n  item.json.openrouterApiKey = \"{{your open router api key }}\";\n   item.json.user_personality= \"{\\n  \\\"user_id\\\": \\\"aethermsaid8\\\",\\n  \\\"username\\\": \\\"aethermsaid8\\\",\\n  \\\"full_name\\\": \\\"Sarah Msaid\\\",\\n  \\\"age\\\": 28,\\n  \\\"location\\\": \\\"Brooklyn, NY\\\",\\n  \\\"bio\\\": \\\"Embracing the beautiful mess. Sharing real life, not just highlight reels. Coffee, cats, and questionable life choices. \u2615\ud83d\udc08\ud83e\udd37\u200d\u2640\ufe0f\\\",\\n  \\\"content_preferences\\\": {\\n    \\\"themes\\\": [\\n      \\\"daily life struggles\\\",\\n      \\\"authentic moments\\\",\\n      \\\"niche hobbies (e.g., vintage board games, obscure indie music)\\\",\\n      \\\"pet antics\\\",\\n      \\\"DIY fails\\\",\\n      \\\"local hidden gems\\\"\\n    ],\\n    \\\"post_frequency_per_week\\\": 3,\\n    \\\"preferred_media_types\\\": [\\n      \\\"photo\\\",\\n      \\\"carousel\\\",\\n      \\\"short-form video (reels)\\\"\\n    ],\\n    \\\"caption_style\\\": \\\"humorous, self-deprecating, relatable, conversational, slightly cynical but ultimately warm\\\",\\n    \\\"hashtag_style\\\": \\\"mix of popular, niche, and ironic hashtags\\\"\\n  },\\n  \\\"personality_traits\\\": {\\n    \\\"values\\\": [\\n      \\\"authenticity\\\",\\n      \\\"humor\\\",\\n      \\\"creativity\\\",\\n      \\\"community\\\",\\n      \\\"self-acceptance\\\"\\n    ],\\n    \\\"interests\\\": [\\n      \\\"independent cinema\\\",\\n      \\\"thrift store finds\\\",\\n      \\\"cooking (badly)\\\",\\n      \\\"reading obscure non-fiction\\\",\\n      \\\"urban exploration\\\",\\n      \\\"cats\\\"\\n    ],\\n    \\\"tone_of_voice_keywords\\\": [\\n      \\\"sarcastic\\\",\\n      \\\"witty\\\", \\\"down-to-earth\\\",\\n      \\\"observational\\\",\\n      \\\"playful\\\"\\n    ]\\n  },\\n  \\\"unfulancer_attributes\\\": {\\n    \\\"reason_for_unfulancing\\\": \\\"prefers genuine connection over chasing virality\\\",\\n    \\\"content_focus\\\": \\\"relatability over perfection\\\",\\n    \\\"niche_appeal\\\": \\\"attracts followers who are tired of curated feeds\\\",\\n    \\\"monetization_approach\\\": \\\"minimal or none, occasional genuine collaborations with small businesses\\\"\\n  }\\n}\"\n  \n\n \n  item.json.instagram_session_id=\"{{ your instagram session ID }}\"\n  \n}\n\nreturn $input.all();"
      },
      "typeVersion": 2
    },
    {
      "id": "abfb8411-7ba6-451f-8290-d36219378b4f",
      "name": "Variables4",
      "type": "n8n-nodes-base.code",
      "position": [
        -480,
        1400
      ],
      "parameters": {
        "jsCode": "// Loop over input items and add a new field called 'myNewField' to the JSON of each one\nfor (const item of $input.all()) {\n   item.json.user_personality= \"{\\n  \\\"user_id\\\": \\\"aethermsaid8\\\",\\n  \\\"username\\\": \\\"aethermsaid8\\\",\\n  \\\"full_name\\\": \\\"Sarah Msaid\\\",\\n  \\\"age\\\": 28,\\n  \\\"location\\\": \\\"Brooklyn, NY\\\",\\n  \\\"bio\\\": \\\"Embracing the beautiful mess. Sharing real life, not just highlight reels. Coffee, cats, and questionable life choices. \u2615\ud83d\udc08\ud83e\udd37\u200d\u2640\ufe0f\\\",\\n  \\\"content_preferences\\\": {\\n    \\\"themes\\\": [\\n      \\\"daily life struggles\\\",\\n      \\\"authentic moments\\\",\\n      \\\"niche hobbies (e.g., vintage board games, obscure indie music)\\\",\\n      \\\"pet antics\\\",\\n      \\\"DIY fails\\\",\\n      \\\"local hidden gems\\\"\\n    ],\\n    \\\"post_frequency_per_week\\\": 3,\\n    \\\"preferred_media_types\\\": [\\n      \\\"photo\\\",\\n      \\\"carousel\\\",\\n      \\\"short-form video (reels)\\\"\\n    ],\\n    \\\"caption_style\\\": \\\"humorous, self-deprecating, relatable, conversational, slightly cynical but ultimately warm\\\",\\n    \\\"hashtag_style\\\": \\\"mix of popular, niche, and ironic hashtags\\\"\\n  },\\n  \\\"personality_traits\\\": {\\n    \\\"values\\\": [\\n      \\\"authenticity\\\",\\n      \\\"humor\\\",\\n      \\\"creativity\\\",\\n      \\\"community\\\",\\n      \\\"self-acceptance\\\"\\n    ],\\n    \\\"interests\\\": [\\n      \\\"independent cinema\\\",\\n      \\\"thrift store finds\\\",\\n      \\\"cooking (badly)\\\",\\n      \\\"reading obscure non-fiction\\\",\\n      \\\"urban exploration\\\",\\n      \\\"cats\\\"\\n    ],\\n    \\\"tone_of_voice_keywords\\\": [\\n      \\\"sarcastic\\\",\\n      \\\"witty\\\", \\\"down-to-earth\\\",\\n      \\\"observational\\\",\\n      \\\"playful\\\"\\n    ]\\n  },\\n  \\\"unfulancer_attributes\\\": {\\n    \\\"reason_for_unfulancing\\\": \\\"prefers genuine connection over chasing virality\\\",\\n    \\\"content_focus\\\": \\\"relatability over perfection\\\",\\n    \\\"niche_appeal\\\": \\\"attracts followers who are tired of curated feeds\\\",\\n    \\\"monetization_approach\\\": \\\"minimal or none, occasional genuine collaborations with small businesses\\\"\\n  }\\n}\"\n  \n\n \n  \n  \n}\n\nreturn $input.all();"
      },
      "typeVersion": 2
    },
    {
      "id": "556add94-201f-4600-ba1e-6cb00ef86179",
      "name": "Variables3",
      "type": "n8n-nodes-base.code",
      "position": [
        880,
        1460
      ],
      "parameters": {
        "jsCode": "// Loop over input items and add a new field called 'myNewField' to the JSON of each one\nfor (const item of $input.all()) {\n  item.json.openrouterApiKey = \"{{your open router api key }}\";\n   item.json.user_personality= \"{\\n  \\\"user_id\\\": \\\"aethermsaid8\\\",\\n  \\\"username\\\": \\\"aethermsaid8\\\",\\n  \\\"full_name\\\": \\\"Sarah Msaid\\\",\\n  \\\"age\\\": 28,\\n  \\\"location\\\": \\\"Brooklyn, NY\\\",\\n  \\\"bio\\\": \\\"Embracing the beautiful mess. Sharing real life, not just highlight reels. Coffee, cats, and questionable life choices. \u2615\ud83d\udc08\ud83e\udd37\u200d\u2640\ufe0f\\\",\\n  \\\"content_preferences\\\": {\\n    \\\"themes\\\": [\\n      \\\"daily life struggles\\\",\\n      \\\"authentic moments\\\",\\n      \\\"niche hobbies (e.g., vintage board games, obscure indie music)\\\",\\n      \\\"pet antics\\\",\\n      \\\"DIY fails\\\",\\n      \\\"local hidden gems\\\"\\n    ],\\n    \\\"post_frequency_per_week\\\": 3,\\n    \\\"preferred_media_types\\\": [\\n      \\\"photo\\\",\\n      \\\"carousel\\\",\\n      \\\"short-form video (reels)\\\"\\n    ],\\n    \\\"caption_style\\\": \\\"humorous, self-deprecating, relatable, conversational, slightly cynical but ultimately warm\\\",\\n    \\\"hashtag_style\\\": \\\"mix of popular, niche, and ironic hashtags\\\"\\n  },\\n  \\\"personality_traits\\\": {\\n    \\\"values\\\": [\\n      \\\"authenticity\\\",\\n      \\\"humor\\\",\\n      \\\"creativity\\\",\\n      \\\"community\\\",\\n      \\\"self-acceptance\\\"\\n    ],\\n    \\\"interests\\\": [\\n      \\\"independent cinema\\\",\\n      \\\"thrift store finds\\\",\\n      \\\"cooking (badly)\\\",\\n      \\\"reading obscure non-fiction\\\",\\n      \\\"urban exploration\\\",\\n      \\\"cats\\\"\\n    ],\\n    \\\"tone_of_voice_keywords\\\": [\\n      \\\"sarcastic\\\",\\n      \\\"witty\\\", \\\"down-to-earth\\\",\\n      \\\"observational\\\",\\n      \\\"playful\\\"\\n    ]\\n  },\\n  \\\"unfulancer_attributes\\\": {\\n    \\\"reason_for_unfulancing\\\": \\\"prefers genuine connection over chasing virality\\\",\\n    \\\"content_focus\\\": \\\"relatability over perfection\\\",\\n    \\\"niche_appeal\\\": \\\"attracts followers who are tired of curated feeds\\\",\\n    \\\"monetization_approach\\\": \\\"minimal or none, occasional genuine collaborations with small businesses\\\"\\n  }\\n}\"\n  \n\n \n  item.json.instagram_session_id=\"{{ your instagram session ID }}\"\n  \n}\n\nreturn $input.all();"
      },
      "typeVersion": 2
    },
    {
      "id": "0825a41c-0309-4705-88a4-ff5d9a464811",
      "name": "Date Formatter",
      "type": "n8n-nodes-base.code",
      "position": [
        1040,
        1460
      ],
      "parameters": {
        "jsCode": "const currentDate = new Date();\nconst formattedDate = currentDate.toISOString().split(\"T\")[0];\n\nreturn { date: formattedDate };\n"
      },
      "typeVersion": 2
    },
    {
      "id": "49fbb8dd-931b-4687-b677-7dcd96367176",
      "name": "run AI infulancer actor custom run",
      "type": "n8n-nodes-base.httpRequest",
      "position": [
        1320,
        240
      ],
      "parameters": {
        "url": "https://api.apify.com/v2/acts/mohamedgb00714~ai-instagram-influencer/run-sync-get-dataset-items?token=YOUR_TOKEN_HERE your apify token }}",
        "options": {},
        "jsonBody": "={\n  \"action\": \"run_agent\",\n  \"task\":\"{{ $json.output.inputMsg.replaceAll('\\n', ' ').replaceAll('\\\"', '\\\\\\\"').trim()  }}\",\n  \"user_personality\": \"{{ $('Variables1').item.json.user_personality.replaceAll('\\n', ' ').replaceAll('\\\"', '\\\\\\\"').trim()  }}\",\n\n  \"user_name\": \"aethermsaid8\",\n \n  \"model_name\": \"openrouter\",\n  \n \n  \"instagram_session_id\": \"{{ $('Variables1').item.json.instagram_session_id }}\",\n  \"openai_api_key\": \"{{ $('Variables1').item.json.openrouterApiKey }}\"\n} ",
        "sendBody": true,
        "specifyBody": "json"
      },
      "typeVersion": 4.2
    },
    {
      "id": "f5334cba-23c1-433d-a0df-f66a6e8bb27e",
      "name": "run AI infulancer actor get instagram profile",
      "type": "n8n-nodes-base.httpRequest",
      "position": [
        1200,
        360
      ],
      "parameters": {
        "url": "https://api.apify.com/v2/acts/mohamedgb00714~ai-instagram-influencer/run-sync-get-dataset-items?token=YOUR_TOKEN_HERE your apify token }}",
        "options": {},
        "jsonBody": "={\n  \"action\": \"run_agent\",\n  \"task\":\"{{ $json.output.inputMsg.replaceAll('\\n', ' ').replaceAll('\\\"', '\\\\\\\"').trim()  }}\",\n  \n  \"user_personality\": \"{{ $('Variables1').item.json.user_personality.replaceAll('\\n', ' ').replaceAll('\\\"', '\\\\\\\"').trim()  }}\",\n\n  \"user_name\": \"aethermsaid8\",\n \n  \"model_name\": \"openrouter\",\n  \n \n  \n  \"instagram_session_id\": \"{{ $('Variables1').item.json.instagram_session_id }}\",\n  \"openai_api_key\": \"{{ $('Variables1').item.json.openrouterApiKey }}\"\n} ",
        "sendBody": true,
        "specifyBody": "json"
      },
      "typeVersion": 4.2
    },
    {
      "id": "236795d8-4f08-48b0-805e-135a494f5624",
      "name": "monitor instagram DM and notificatios with apify",
      "type": "n8n-nodes-base.httpRequest",
      "position": [
        -180,
        1040
      ],
      "parameters": {
        "url": "https://api.apify.com/v2/acts/mohamedgb00714~ai-instagram-influencer/runs?timeout_secs=600&token=YOUR_TOKEN_HERE your apify token }}",
        "method": "POST",
        "options": {},
        "jsonBody": "={\n  \"action\": \"monitor_instagram\",\n  \"user_personality\": \"{{ $json.user_personality.replaceAll('\\n', ' ').replaceAll('\\\"', '\\\\\\\"').trim()  }}\",\n  \n\"model_name\": \"openrouter\",\n \n  \"instagram_session_id\": \"{{ $json.instagram_session_id }}\",\n  \"openai_api_key\": \"{{ $json.openrouterApiKey }}\"\n} ",
        "sendBody": true,
        "contentType": "=json",
        "specifyBody": "json",
        "bodyParameters": {
          "parameters": [
            {}
          ]
        }
      },
      "typeVersion": 4.2
    },
    {
      "id": "3298846d-7bb3-45bc-a38c-5a59f9b9b7ed",
      "name": "Get Users to follow",
      "type": "n8n-nodes-base.googleSheets",
      "position": [
        700,
        1040
      ],
      "parameters": {
        "options": {},
        "filtersUI": {
          "values": [
            {
              "lookupValue": "=",
              "lookupColumn": "followed"
            }
          ]
        },
        "sheetName": {
          "__rl": true,
          "mode": "list",
          "value": "gid=0",
          "cachedResultUrl": "https://docs.google.com/spreadsheets/d/1Ze5SC1g6Q5VzMAKYx0zmqlT00Db1HOchUth1jrPyM2Y/edit#gid=0",
          "cachedResultName": "Sheet1"
        },
        "documentId": {
          "__rl": true,
          "mode": "list",
          "value": "1Ze5SC1g6Q5VzMAKYx0zmqlT00Db1HOchUth1jrPyM2Y",
          "cachedResultUrl": "https://docs.google.com/spreadsheets/d/1Ze5SC1g6Q5VzMAKYx0zmqlT00Db1HOchUth1jrPyM2Y/edit?usp=drivesdk",
          "cachedResultName": "Usernames to follow"
        }
      },
      "credentials": {
        "googleSheetsOAuth2Api": {
          "name": "<your credential>"
        }
      },
      "typeVersion": 4.6
    },
    {
      "id": "6aa4578c-4733-4cb1-bb1c-38d4070bc3c1",
      "name": "fllow users with apify actor",
      "type": "n8n-nodes-base.httpRequest",
      "position": [
        1060,
        1040
      ],
      "parameters": {
        "url": "https://api.apify.com/v2/acts/mohamedgb00714~ai-instagram-influencer/run-sync-get-dataset-items?token=YOUR_TOKEN_HERE your apify token }}",
        "options": {},
        "jsonBody": "={\n  \"action\": \"follow_instagram_users\",\n  \"usernames\":[{{ $json.usernames.map(item => `\"${item}\"`) }}],\n  \"user_name\": \"aethermsaid8\",\n \n  \"model_name\": \"openrouter\",\n  \n \n  \"instagram_session_id\": \"{{ $('Variables2').item.json.instagram_session_id }}\",\n  \"openai_api_key\": \"{{ $('Variables2').item.json.openrouterApiKey }}\"\n} ",
        "sendBody": true,
        "specifyBody": "json"
      },
      "typeVersion": 4.2
    },
    {
      "id": "9ba77e00-a562-47af-9205-174ce3870873",
      "name": "Update row in sheet to mark followed users",
      "type": "n8n-nodes-base.googleSheets",
      "position": [
        1460,
        1040
      ],
      "parameters": {
        "columns": {
          "value": {
            "followed": "TRUE",
            "usernames": "={{ $json.usernames }}"
          },
          "schema": [
            {
              "id": "usernames",
              "type": "string",
              "display": true,
              "removed": false,
              "required": false,
              "displayName": "usernames",
              "defaultMatch": false,
              "canBeUsedToMatch": true
            },
            {
              "id": "followed",
              "type": "string",
              "display": true,
              "required": false,
              "displayName": "followed",
              "defaultMatch": false,
              "canBeUsedToMatch": true
            },
            {
              "id": "row_number",
              "type": "string",
              "display": true,
              "removed": true,
              "readOnly": true,
              "required": false,
              "displayName": "row_number",
              "defaultMatch": false,
              "canBeUsedToMatch": true
            }
          ],
          "mappingMode": "defineBelow",
          "matchingColumns": [
            "usernames"
          ],
          "attemptToConvertTypes": false,
          "convertFieldsToString": false
        },
        "options": {},
        "operation": "update",
        "sheetName": {
          "__rl": true,
          "mode": "list",
          "value": "gid=0",
          "cachedResultUrl": "https://docs.google.com/spreadsheets/d/1Ze5SC1g6Q5VzMAKYx0zmqlT00Db1HOchUth1jrPyM2Y/edit#gid=0",
          "cachedResultName": "Sheet1"
        },
        "documentId": {
          "__rl": true,
          "mode": "list",
          "value": "1Ze5SC1g6Q5VzMAKYx0zmqlT00Db1HOchUth1jrPyM2Y",
          "cachedResultUrl": "https://docs.google.com/spreadsheets/d/1Ze5SC1g6Q5VzMAKYx0zmqlT00Db1HOchUth1jrPyM2Y/edit?usp=drivesdk",
          "cachedResultName": "Usernames to follow"
        }
      },
      "credentials": {
        "googleSheetsOAuth2Api": {
          "name": "<your credential>"
        }
      },
      "typeVersion": 4.6
    },
    {
      "id": "98311c6d-38e1-4329-8511-97008468ca7c",
      "name": "Append the 30 days post generated to sheet",
      "type": "n8n-nodes-base.googleSheets",
      "position": [
        280,
        1400
      ],
      "parameters": {
        "columns": {
          "value": {},
          "schema": [
            {
              "id": "imagePrompt",
              "type": "string",
              "display": true,
              "removed": false,
              "required": false,
              "displayName": "imagePrompt",
              "defaultMatch": false,
              "canBeUsedToMatch": true
            },
            {
              "id": "caption",
              "type": "string",
              "display": true,
              "removed": false,
              "required": false,
              "displayName": "caption",
              "defaultMatch": false,
              "canBeUsedToMatch": true
            },
            {
              "id": "scheduledDate",
              "type": "string",
              "display": true,
              "removed": false,
              "required": false,
              "displayName": "scheduledDate",
              "defaultMatch": false,
              "canBeUsedToMatch": true
            }
          ],
          "mappingMode": "autoMapInputData",
          "matchingColumns": [
            "scheduledDate"
          ],
          "attemptToConvertTypes": false,
          "convertFieldsToString": false
        },
        "options": {},
        "operation": "appendOrUpdate",
        "sheetName": {
          "__rl": true,
          "mode": "list",
          "value": "gid=0",
          "cachedResultUrl": "https://docs.google.com/spreadsheets/d/1XHNwAXR4USThaAzX1Y6M5PF2P8WqCBU8mi34FBLkV6M/edit#gid=0",
          "cachedResultName": "Sheet1"
        },
        "documentId": {
          "__rl": true,
          "mode": "list",
          "value": "1XHNwAXR4USThaAzX1Y6M5PF2P8WqCBU8mi34FBLkV6M",
          "cachedResultUrl": "https://docs.google.com/spreadsheets/d/1XHNwAXR4USThaAzX1Y6M5PF2P8WqCBU8mi34FBLkV6M/edit?usp=drivesdk",
          "cachedResultName": "posts generation plan"
        }
      },
      "credentials": {
        "googleSheetsOAuth2Api": {
          "name": "<your credential>"
        }
      },
      "typeVersion": 4.6
    },
    {
      "id": "8b01fda4-f4fd-4c1e-9167-fed03c6bebf5",
      "name": "get today post details",
      "type": "n8n-nodes-base.googleSheets",
      "position": [
        1220,
        1460
      ],
      "parameters": {
        "options": {},
        "filtersUI": {
          "values": [
            {
              "lookupValue": "={{ $json.date }}",
              "lookupColumn": "scheduledDate"
            }
          ]
        },
        "sheetName": {
          "__rl": true,
          "mode": "list",
          "value": "gid=0",
          "cachedResultUrl": "https://docs.google.com/spreadsheets/d/1XHNwAXR4USThaAzX1Y6M5PF2P8WqCBU8mi34FBLkV6M/edit#gid=0",
          "cachedResultName": "Sheet1"
        },
        "documentId": {
          "__rl": true,
          "mode": "list",
          "value": "1XHNwAXR4USThaAzX1Y6M5PF2P8WqCBU8mi34FBLkV6M",
          "cachedResultUrl": "https://docs.google.com/spreadsheets/d/1XHNwAXR4USThaAzX1Y6M5PF2P8WqCBU8mi34FBLkV6M/edit?usp=drivesdk",
          "cachedResultName": "posts generation plan"
        }
      },
      "credentials": {
        "googleSheetsOAuth2Api": {
          "name": "<your credential>"
        }
      },
      "typeVersion": 4.6
    },
    {
      "id": "da33e0b3-7227-4e6b-a270-a629357040a0",
      "name": "get the right values from output",
      "type": "n8n-nodes-base.code",
      "position": [
        1840,
        1460
      ],
      "parameters": {
        "jsCode": "const items = $input.all();\nconst parsedItems=  JSON.parse(items[0].json.output.replace(/```json|```/g, '').trim());\n \nreturn parsedItems;\n"
      },
      "typeVersion": 2
    },
    {
      "id": "392b6f2c-e807-4a72-9fb1-0144ff153871",
      "name": "add enhanced prompts to sheet",
      "type": "n8n-nodes-base.googleSheets",
      "position": [
        2100,
        1440
      ],
      "parameters": {
        "columns": {
          "value": {},
          "schema": [
            {
              "id": "imagePrompt",
              "type": "string",
              "display": true,
              "removed": false,
              "required": false,
              "displayName": "imagePrompt",
              "defaultMatch": false,
              "canBeUsedToMatch": true
            },
            {
              "id": "caption",
              "type": "string",
              "display": true,
              "removed": false,
              "required": false,
              "displayName": "caption",
              "defaultMatch": false,
              "canBeUsedToMatch": true
            },
            {
              "id": "scheduledDate",
              "type": "string",
              "display": true,
              "removed": false,
              "required": false,
              "displayName": "scheduledDate",
              "defaultMatch": false,
              "canBeUsedToMatch": true
            },
            {
              "id": "enhancedImagePrompt",
              "type": "string",
              "display": true,
              "removed": false,
              "required": false,
              "displayName": "enhancedImagePrompt",
              "defaultMatch": false,
              "canBeUsedToMatch": true
            },
            {
              "id": "enhancedCaption",
              "type": "string",
              "display": true,
              "removed": false,
              "required": false,
              "displayName": "enhancedCaption",
              "defaultMatch": false,
              "canBeUsedToMatch": true
            }
          ],
          "mappingMode": "autoMapInputData",
          "matchingColumns": [
            "scheduledDate"
          ],
          "attemptToConvertTypes": false,
          "convertFieldsToString": false
        },
        "options": {},
        "operation": "appendOrUpdate",
        "sheetName": {
          "__rl": true,
          "mode": "list",
          "value": "gid=0",
          "cachedResultUrl": "https://docs.google.com/spreadsheets/d/1XHNwAXR4USThaAzX1Y6M5PF2P8WqCBU8mi34FBLkV6M/edit#gid=0",
          "cachedResultName": "Sheet1"
        },
        "documentId": {
          "__rl": true,
          "mode": "list",
          "value": "1XHNwAXR4USThaAzX1Y6M5PF2P8WqCBU8mi34FBLkV6M",
          "cachedResultUrl": "https://docs.google.com/spreadsheets/d/1XHNwAXR4USThaAzX1Y6M5PF2P8WqCBU8mi34FBLkV6M/edit?usp=drivesdk",
          "cachedResultName": "posts generation plan"
        }
      },
      "credentials": {
        "googleSheetsOAuth2Api": {
          "name": "<your credential>"
        }
      },
      "typeVersion": 4.6
    },
    {
      "id": "45eeacea-b586-4a69-8821-89b9b96699e0",
      "name": "generate image with replicate",
      "type": "n8n-nodes-base.httpRequest",
      "position": [
        2320,
        1460
      ],
      "parameters": {
        "url": "https://api.replicate.com/v1/models/google/imagen-4/predictions",
        "method": "POST",
        "options": {},
        "jsonBody": "={\n  \"input\": {\n    \"prompt\": \"{{ $json.enhancedImagePrompt }}\" ,\n    \"aspect_ratio\": \"9:16\",\n    \"safety_filter_level\": \"block_medium_and_above\",\n    \"output_format\":\"jpg\"\n  }\n} ",
        "sendBody": true,
        "sendHeaders": true,
        "specifyBody": "json",
        "headerParameters": {
          "parameters": [
            {
              "name": "Authorization",
              "value": "Bearer YOUR_TOKEN_HERE"
            },
            {
              "name": "Prefer",
              "value": "wait"
            }
          ]
        }
      },
      "typeVersion": 4.2
    },
    {
      "id": "2f31245f-ec9c-476b-b7f4-11639012a1ef",
      "name": "post to instagram with apify",
      "type": "n8n-nodes-base.httpRequest",
      "position": [
        1260,
        1840
      ],
      "parameters": {
        "url": "https://api.apify.com/v2/acts/mohamedgb00714~ai-instagram-influencer/run-sync-get-dataset-items?token=YOUR_TOKEN_HERE your apify token }}",
        "options": {},
        "jsonBody": "={\n  \"action\": \"post_instagram_post\",\n  \"caption\": \"{{ $json.enhancedCaption.replaceAll('\\\"', '\\\\\\\"').replaceAll('\\n', '\\\\n') }}\",\n  \"image_data\": \"{{ $json.image_url }}\",\n  \"model_name\": \"openrouter\",\n  \"instagram_session_id\": \"{{ $('Variables3').item.json.instagram_session_id }}\",\n  \"openai_api_key\": \"{{ $('Variables3').item.json.openrouterApiKey }}\"\n}\n",
        "sendBody": true,
        "specifyBody": "json"
      },
      "typeVersion": 4.2
    },
    {
      "id": "4a070ca3-7680-4c3c-844a-9bd29544173b",
      "name": "Sticky Note4",
      "type": "n8n-nodes-base.stickyNote",
      "position": [
        -2600,
        40
      ],
      "parameters": {
        "color": 4,
        "width": 1740,
        "height": 3000,
        "content": "\n# \ud83e\udd16 Instagram Automation Suite: AI Chatbot & Content Powerhouse\n\n## Workflow Overview\n\nThis cutting-edge n8n workflow is a comprehensive automation solution designed to streamline various Instagram operations. It combines an intelligent AI chatbot for direct message management, automated user following, and an advanced content generation system, all integrated to enhance your Instagram presence and efficiency.\n\nThis workflow automatically:\n\n  * **Manages Instagram Direct Messages via Telegram Chatbot**:\n      * Listens for new messages on **Telegram**.\n      * Routes messages from a specific Instagram user (`Wolf23000`) for processing.\n      * Utilizes an **AI agent (powered by OpenRouter's cutting-edge models)** to determine the intent of the message (e.g., chat back, run an Instagram-related action like getting profile info, posting, or following).\n      * Sends AI-generated responses back to the user via **Telegram**.\n  * **Automates Instagram User Following**:\n      * Scheduled to run at regular intervals (hourly).\n      * Processes a list of usernames (likely from a Google Sheet, though not explicitly shown in the provided JSON, it's a common pattern for \"Auto Follow users from sheet\" sticky note).\n      * Initiates following actions on Instagram for the specified users.\n  * **Generates & Schedules Instagram Posts**:\n      * Scheduled to run monthly.\n      * Leverages an **AI agent (powered by OpenRouter)** to generate **30 or 31 Instagram post ideas** for the current month, based on a predefined \"Instagram personality profile.\"\n      * Each post idea includes an `imagePrompt` (for AI image generation), a `caption` with emojis and hashtags, and a `scheduledDate`.\n      * Refines these post ideas by enhancing the `imagePrompt` to be more vivid and detailed for AI image generation, and polishing the `caption` for optimal engagement.\n      * Updates a Google Sheet (\"posts generation plan\") with the generated content, including the enhanced image prompts and the resulting image URLs (presumably from a separate image generation step not fully detailed in the provided JSON, but implied by `image_url` updates).\n\n-----\n\n## Key Benefits\n\n  * **Intelligent DM Management**: Automate responses and actions for Instagram direct messages, ensuring timely and relevant interactions without manual effort.\n  * **Effortless Audience Growth**: Automatically follow target users, expanding your reach and potential engagement on Instagram.\n  * **AI-Powered Content Creation**: Generate a full month's worth of diverse, engaging Instagram post ideas tailored to a specific personality, complete with image prompts and captions.\n  * **Content Optimization**: Automatically enhance image prompts for better AI image generation and refine captions for maximum impact.\n  * **Time-Saving**: Significantly reduce the manual workload associated with Instagram management, from direct messages to content planning and execution.\n  * **Consistent Brand Voice**: Maintain a consistent and engaging presence on Instagram with AI-generated content aligned with your defined personality.\n\n-----\n\n## Setup Requirements\n\nTo set up and run this workflow, you'll need the following:\n\n  * **n8n Installation**:\n      * Install n8n (cloud or self-hosted). The latest stable version, as of July 2025, is **v1.101.1**.\n      * Import the workflow configuration.\n      * Configure API credentials for all integrated services.\n      * Set up scheduling preferences for continuous operation.\n      * **System Requirements for Self-Hosting**: A modern multi-core processor (2 cores minimum, 4 recommended), 2 GB RAM (4 GB or more recommended), and 20 GB of free SSD storage. Node.js version 16 or later (18.x LTS recommended) is required. PostgreSQL is the recommended database for production.\n  * **Telegram API Access**:\n      * Create a Telegram bot via BotFather and obtain your API token.\n      * Configure the **Telegram Trigger** node with your bot's API credentials to receive messages.\n      * **Pricing**: Telegram's API is free to use.\n  * **OpenRouter API Access**:\n      * Create an OpenRouter account and generate an API key.\n      * This key (`{{your open router api key }}` as seen in the code) is used to access their chat models (e.g., `google/gemini-2.5-flash-preview`) for AI agent operations.\n      * **Pricing**: OpenRouter offers a variety of models with different pricing structures, including some free models like DeepSeek R1. Most models operate on a pay-per-usage basis, with costs clearly displayed for each model and prompt.\n  * **Instagram Session ID**:\n      * You'll need a valid Instagram session ID (`{{ your instagram session ID }}` as seen in the code) for the workflow to interact with Instagram. This usually involves extracting it from your browser's cookies after logging into Instagram.\n      * **Caution**: Instagram's terms of service generally prohibit automated interactions, and using session IDs for scraping or automation can lead to account suspension. Use with extreme caution and at your own risk.\n  * **Google Sheets Credentials**:\n      * A Google Cloud API key with access to Google Sheets.\n      * Set up OAuth2 authentication in n8n for read/write access to your \"posts generation plan\" spreadsheet (Document ID: `1XHNwAXR4USThaAzX1Y6M5PF2P8WqCBU8mi34FBLkV6M`). This sheet is used to store and manage generated post ideas.\n      * **Pricing**: The Google Sheets API is generally free for most common use cases, with generous per-minute quotas (300 read and 300 write requests per mi

Credentials you'll need

Each integration node will prompt for credentials when you import. We strip credential IDs before publishing — you'll add your own.

Pro

For the full experience including quality scoring and batch install features for each workflow upgrade to Pro

About this workflow

This cutting-edge n8n workflow is a comprehensive automation solution designed to streamline various Instagram operations. It combines an intelligent AI chatbot for direct message management, automated user following, and an advanced content generation system, all integrated to…

Source: https://n8n.io/workflows/6070/ — original creator credit. Request a take-down →

More AI & RAG workflows → · Browse all categories →

Related workflows

Workflows that share integrations, category, or trigger type with this one. All free to copy and import.

AI & RAG

This workflow automatically generates stock market insights for selected tickers (e.g. GAZP, SBER, LKOH) using historical data, technical indicators, and an AI model. The results are then sent to Tele

Agent, OpenRouter Chat, Telegram Trigger +5
AI & RAG

Generate AI viral videos with NanoBanana & VEO3, shared on socials via Blotato 2. Uses @blotato/n8n-nodes-blotato, googleSheets, lmChatOpenAi, toolThink. Event-driven trigger; 94 nodes.

@Blotato/N8N Nodes Blotato, Google Sheets, OpenAI Chat +9
AI & RAG

RAG CHATBOT Main. Uses telegram, telegramTrigger, lmChatOpenAi, n8n-nodes-mcp. Event-driven trigger; 87 nodes.

Telegram, Telegram Trigger, OpenAI Chat +8
AI & RAG

Author: Nguyen Thieu Toan Category: Community & Knowledge Automation Tags: Telegram, Reddit, n8n Forum, AI Summarization, Gemini, Groq

Groq Chat, Output Parser Structured, Memory Mongo Db Chat +5
AI & RAG

This workflow transforms your Telegram bot into an intelligent creative assistant. It can chat conversationally, fetch trending image prompts from PromptHero for inspiration, or perform a deep "remix"

Telegram Trigger, Output Parser Structured, Telegram +6