{
  "id": "6iOC1ApXN0RZOWGN",
  "name": "Repurpose web links into AI social posts and publish to LinkedIn, X and Instagram from Telegram",
  "tags": [],
  "nodes": [
    {
      "id": "ee56a7d8-e29b-4589-a22d-1e2d13aac0ba",
      "name": "Receive idea or link on Telegram",
      "type": "n8n-nodes-base.telegramTrigger",
      "position": [
        752,
        256
      ],
      "parameters": {
        "updates": [
          "message"
        ],
        "additionalFields": {}
      },
      "credentials": {
        "telegramApi": {
          "name": "<your credential>"
        }
      },
      "typeVersion": 1.3
    },
    {
      "id": "27aedabe-f517-474d-bf40-5f2bb3082436",
      "name": "Brand and image settings",
      "type": "n8n-nodes-base.set",
      "position": [
        1088,
        256
      ],
      "parameters": {
        "options": {},
        "assignments": {
          "assignments": [
            {
              "id": "a1",
              "name": "language",
              "type": "string",
              "value": "English"
            },
            {
              "id": "a2",
              "name": "brand_voice",
              "type": "string",
              "value": "Clear, friendly and practical. Confident but never hype."
            },
            {
              "id": "a3",
              "name": "image_style",
              "type": "string",
              "value": "modern, clean, vibrant professional illustration, high detail, soft lighting"
            },
            {
              "id": "a4",
              "name": "atlas_model",
              "type": "string",
              "value": "xai/grok-imagine-image/text-to-image"
            },
            {
              "id": "a5",
              "name": "aspect_ratio",
              "type": "string",
              "value": "1:1"
            },
            {
              "id": "a6",
              "name": "resolution",
              "type": "string",
              "value": "1k"
            }
          ]
        },
        "includeOtherFields": true
      },
      "typeVersion": 3.4
    },
    {
      "id": "edb31d8e-b18d-4b33-9a49-6cd7d07bdf75",
      "name": "AI content agent",
      "type": "@n8n/n8n-nodes-langchain.agent",
      "position": [
        1360,
        256
      ],
      "parameters": {
        "text": "={{ $('Receive idea or link on Telegram').item.json.message.text }}{{ $json.page_content ? '\\n\\n---\\nReference content extracted from the link:\\n' + $json.page_content : '' }}",
        "options": {
          "systemMessage": "=You are a senior social media content strategist for creators and small businesses.\n\nThe user sends an idea, a topic, or a URL to repurpose. Produce ready-to-publish content for three platforms plus one image-generation prompt.\n\nRules:\n- Write all captions in {{ $json.language }}.\n- Brand voice: {{ $json.brand_voice }}.\n- If the user message contains a URL, treat it as the topic to repurpose and write content around it.\n- linkedin_post: a strong hook line, 3 to 6 short paragraphs, a clear takeaway, 2 to 3 relevant hashtags.\n- x_caption: under 280 characters, punchy, 1 to 2 hashtags.\n- instagram_caption: engaging, a few tasteful emojis, a short call to action, 5 hashtags maximum. (Instagram allows a maximum of 5 hashtags per post)\n- image_prompt: a vivid, detailed text-to-image prompt (subject, style, mood, lighting, composition) in this visual style: {{ $json.image_style }}. No text or logos in the image.\n\nReturn only the structured output."
        },
        "promptType": "define",
        "hasOutputParser": true
      },
      "typeVersion": 3.1
    },
    {
      "id": "5b5ef099-0b83-4644-afce-7ce26ad0f27e",
      "name": "OpenAI Chat Model",
      "type": "@n8n/n8n-nodes-langchain.lmChatOpenAi",
      "position": [
        1072,
        464
      ],
      "parameters": {
        "model": {
          "__rl": true,
          "mode": "list",
          "value": "gpt-4.1-mini",
          "cachedResultName": "gpt-4.1-mini"
        },
        "options": {},
        "responsesApiEnabled": false
      },
      "credentials": {
        "openAiApi": {
          "name": "<your credential>"
        }
      },
      "typeVersion": 1.3
    },
    {
      "id": "5c093031-1095-4ae6-852e-5e0660fdb934",
      "name": "Conversation memory",
      "type": "@n8n/n8n-nodes-langchain.memoryBufferWindow",
      "position": [
        1264,
        464
      ],
      "parameters": {
        "sessionKey": "={{ $('Receive idea or link on Telegram').item.json.message.chat.id }}",
        "sessionIdType": "customKey"
      },
      "typeVersion": 1.4
    },
    {
      "id": "5c4dad82-f68f-480b-80aa-ba537f1ddf52",
      "name": "Format the AI output",
      "type": "@n8n/n8n-nodes-langchain.outputParserStructured",
      "position": [
        1600,
        464
      ],
      "parameters": {
        "autoFix": true,
        "jsonSchemaExample": "{\n  \"image_prompt\": \"A vivid flat-style illustration of a sunrise over a calm city skyline, warm tones, soft morning light\",\n  \"linkedin_post\": \"Hook line.\\n\\nParagraph one.\\n\\nParagraph two.\\n\\nTakeaway.\\n\\n#hashtag1 #hashtag2\",\n  \"x_caption\": \"Punchy one-liner that fits in 280 characters #hashtag\",\n  \"instagram_caption\": \"Engaging caption with a few emojis and a short CTA.\\n\\n#tag1 #tag2 #tag3 #tag4 #tag5\"\n}"
      },
      "typeVersion": 1.3
    },
    {
      "id": "a9f72617-13b6-46b5-b271-ee0fa18f32d2",
      "name": "Generate image (Grok)",
      "type": "n8n-nodes-base.httpRequest",
      "position": [
        1920,
        256
      ],
      "parameters": {
        "url": "https://api.atlascloud.ai/api/v1/model/generateImage",
        "method": "POST",
        "options": {},
        "sendBody": true,
        "authentication": "genericCredentialType",
        "bodyParameters": {
          "parameters": [
            {
              "name": "model",
              "value": "={{ $('Brand and image settings').item.json.atlas_model }}"
            },
            {
              "name": "num_images",
              "value": "={{ 1 }}"
            },
            {
              "name": "aspect_ratio",
              "value": "={{ $('Brand and image settings').item.json.aspect_ratio }}"
            },
            {
              "name": "resolution",
              "value": "={{ $('Brand and image settings').item.json.resolution }}"
            },
            {
              "name": "enable_base64_output",
              "value": "={{ false }}"
            },
            {
              "name": "prompt",
              "value": "={{ $('AI content agent').item.json.output.image_prompt }}"
            }
          ]
        },
        "genericAuthType": "httpHeaderAuth"
      },
      "credentials": {
        "httpHeaderAuth": {
          "name": "<your credential>"
        }
      },
      "typeVersion": 4.4
    },
    {
      "id": "03418430-9529-487f-a164-ed90f082bfcd",
      "name": "Wait for image",
      "type": "n8n-nodes-base.wait",
      "position": [
        2112,
        256
      ],
      "parameters": {},
      "typeVersion": 1.1
    },
    {
      "id": "4b26e34f-489f-4a14-9b8f-135ae9125241",
      "name": "Poll image result",
      "type": "n8n-nodes-base.httpRequest",
      "position": [
        2304,
        256
      ],
      "parameters": {
        "url": "=https://api.atlascloud.ai/api/v1/model/prediction/{{ $('Generate image (Grok)').item.json.data.id }}",
        "options": {},
        "authentication": "genericCredentialType",
        "genericAuthType": "httpHeaderAuth"
      },
      "credentials": {
        "httpHeaderAuth": {
          "name": "<your credential>"
        }
      },
      "typeVersion": 4.4
    },
    {
      "id": "a64647fa-24d9-495f-ba6e-f9078364d2cd",
      "name": "Check image status",
      "type": "n8n-nodes-base.switch",
      "position": [
        2512,
        240
      ],
      "parameters": {
        "rules": {
          "values": [
            {
              "conditions": {
                "options": {
                  "version": 1,
                  "leftValue": "",
                  "caseSensitive": false,
                  "typeValidation": "loose"
                },
                "combinator": "or",
                "conditions": [
                  {
                    "operator": {
                      "type": "string",
                      "operation": "equals"
                    },
                    "leftValue": "={{ $json.data.status }}",
                    "rightValue": "completed"
                  },
                  {
                    "operator": {
                      "type": "string",
                      "operation": "equals"
                    },
                    "leftValue": "={{ $json.data.status }}",
                    "rightValue": "succeeded"
                  }
                ]
              }
            },
            {
              "conditions": {
                "options": {
                  "version": 1,
                  "leftValue": "",
                  "caseSensitive": false,
                  "typeValidation": "loose"
                },
                "combinator": "and",
                "conditions": [
                  {
                    "operator": {
                      "type": "string",
                      "operation": "equals"
                    },
                    "leftValue": "={{ $json.data.status }}",
                    "rightValue": "processing"
                  }
                ]
              }
            }
          ]
        },
        "options": {
          "fallbackOutput": "extra",
          "renameFallbackOutput": "error"
        }
      },
      "typeVersion": 3.4
    },
    {
      "id": "6f1e3fa8-bdfd-42f7-aa17-a5941ccffe17",
      "name": "Extract image URL",
      "type": "n8n-nodes-base.set",
      "position": [
        2736,
        144
      ],
      "parameters": {
        "options": {},
        "assignments": {
          "assignments": [
            {
              "id": "u1",
              "name": "image_url",
              "type": "string",
              "value": "={{ $json.data.outputs[0] }}"
            }
          ]
        }
      },
      "typeVersion": 3.4
    },
    {
      "id": "84f763e0-b24d-426d-b53a-6acbe6e0ede4",
      "name": "Publish to LinkedIn",
      "type": "@blotato/n8n-nodes-blotato.blotato",
      "position": [
        3024,
        144
      ],
      "parameters": {
        "options": {},
        "platform": "linkedin",
        "accountId": {
          "__rl": true,
          "mode": "id",
          "value": "=YOUR_blotato_linkedin_ID"
        },
        "postContentText": "={{ $('AI content agent').item.json.output.linkedin_post }}",
        "postContentMediaUrls": "={{ $('Extract image URL').item.json.image_url }}"
      },
      "credentials": {
        "blotatoApi": {
          "name": "<your credential>"
        }
      },
      "typeVersion": 2
    },
    {
      "id": "94357e7d-a785-444c-b31b-7451ff94adbd",
      "name": "Publish to X",
      "type": "@blotato/n8n-nodes-blotato.blotato",
      "position": [
        3024,
        320
      ],
      "parameters": {
        "options": {},
        "platform": "twitter",
        "accountId": {
          "__rl": true,
          "mode": "id",
          "value": "=YOUR_blotato_twitter_ID"
        },
        "postContentText": "={{ $('AI content agent').item.json.output.x_caption }}",
        "postContentMediaUrls": "={{ $('Extract image URL').item.json.image_url }}"
      },
      "credentials": {
        "blotatoApi": {
          "name": "<your credential>"
        }
      },
      "typeVersion": 2
    },
    {
      "id": "2d32be96-240e-4430-8066-5f673de56185",
      "name": "Publish to Instagram",
      "type": "@blotato/n8n-nodes-blotato.blotato",
      "position": [
        3024,
        480
      ],
      "parameters": {
        "options": {},
        "accountId": {
          "__rl": true,
          "mode": "id",
          "value": "=YOUR_blotato_Instagram_ID"
        },
        "postContentText": "={{ $('AI content agent').item.json.output.instagram_caption }}",
        "postContentMediaUrls": "={{ $('Extract image URL').item.json.image_url }}"
      },
      "credentials": {
        "blotatoApi": {
          "name": "<your credential>"
        }
      },
      "typeVersion": 2
    },
    {
      "id": "aa29dfc8-da45-4bd7-9f61-4fb9b5b42bab",
      "name": "Confirm on Telegram",
      "type": "n8n-nodes-base.telegram",
      "position": [
        3024,
        704
      ],
      "parameters": {
        "text": "=Done. Your post was published to LinkedIn, X and Instagram.\n\nImage: {{ $('Extract image URL').item.json.image_url }}",
        "chatId": "={{ $('Receive idea or link on Telegram').item.json.message.chat.id }}",
        "additionalFields": {
          "appendAttribution": false
        }
      },
      "credentials": {
        "telegramApi": {
          "name": "<your credential>"
        }
      },
      "typeVersion": 1.2
    },
    {
      "id": "f8491599-c5eb-491f-aad0-99a0fecdb1b9",
      "name": "Stop on image error",
      "type": "n8n-nodes-base.stopAndError",
      "position": [
        2736,
        384
      ],
      "parameters": {
        "errorMessage": "Image generation failed on AtlasCloud. Check your AtlasCloud credits and the prompt."
      },
      "typeVersion": 1
    },
    {
      "id": "2ae9140b-af24-4b14-a80c-3d8a18794c57",
      "name": "Sticky Note 0701ff85",
      "type": "n8n-nodes-base.stickyNote",
      "position": [
        0,
        0
      ],
      "parameters": {
        "width": 632,
        "height": 1020,
        "content": "## Repurpose web links into AI social posts and publish to LinkedIn, X and Instagram from Telegram\n\nSend a Telegram message with a topic or a link, and this workflow reads the page content, turns it into ready-to-publish posts with a matching AI image, and publishes them to LinkedIn, X and Instagram.\n\n## How it works\n1. You message your Telegram bot with an idea, a topic, or a URL to repurpose.\n2. A web-capture step detects any link in your message, fetches the page and cleans the text.\n3. The AI agent (OpenAI) reads your request plus the captured page content, then writes four things: an image prompt, a LinkedIn post, an X caption and an Instagram caption.\n4. The image is generated with Grok Imagine (via [AtlasCloud](https://www.atlascloud.ai/?ref=8QKPJE)). A small Wait then Poll then Switch loop runs until the image is ready.\n5. The image is published with each caption to LinkedIn, X and Instagram via [Blotato](https://blotato.com/?ref=firas).\n6. You get a confirmation back in Telegram.\n\n## Setup\n1. Open the \"Brand and image settings\" node and set language, brand voice and image style.\n2. Connect the credentials listed below.\n3. In each [Blotato](https://blotato.com/?ref=firas) node, pick your connected account from the list.\n4. Activate the workflow and message your bot (add a link to repurpose its content).\n\n## Requirements\n- A Telegram bot token (free, via @BotFather).\n- An OpenAI API key.\n- An [AtlasCloud](https://www.atlascloud.ai/?ref=8QKPJE) API key for Grok image generation (Header Auth).\n- A paid [Blotato](https://blotato.com/?ref=firas) account with LinkedIn, X and Instagram connected.\n- **Community node:** this template uses the [Blotato](https://blotato.com/?ref=firas) community node, so it runs on self-hosted n8n (or n8n Cloud with Verified Community Nodes enabled).\n\n## Customization\n- Swap the image model, aspect ratio or resolution in \"Brand and image settings\".\n- Add more platforms in [Blotato](https://blotato.com/?ref=firas) (Facebook, Threads, TikTok).\n- The link reader handles articles and blog posts well; for YouTube, paste a few key points in your message (the watch page has no transcript in its HTML)."
      },
      "typeVersion": 1
    },
    {
      "id": "b37a7b6d-ff72-4f62-8082-faf360007652",
      "name": "Sticky Note ca2083cf",
      "type": "n8n-nodes-base.stickyNote",
      "position": [
        656,
        0
      ],
      "parameters": {
        "color": 7,
        "width": 328,
        "height": 632,
        "content": "## 1. Trigger and settings\nReceive the request from Telegram, then set the language, brand voice and image style."
      },
      "typeVersion": 1
    },
    {
      "id": "a81d1b99-0d18-4e8c-b878-8ad433d4512c",
      "name": "Sticky Note c3072499",
      "type": "n8n-nodes-base.stickyNote",
      "position": [
        1008,
        0
      ],
      "parameters": {
        "color": 7,
        "width": 848,
        "height": 632,
        "content": "## 2. AI content agent\nThe brain: reads your request (and any link), then writes the image prompt and the three captions."
      },
      "typeVersion": 1
    },
    {
      "id": "2c53aa29-42fe-4acf-817e-fc40f10e4312",
      "name": "Sticky Note 04d44c93",
      "type": "n8n-nodes-base.stickyNote",
      "position": [
        1872,
        0
      ],
      "parameters": {
        "color": 7,
        "width": 992,
        "height": 632,
        "content": "## 3. Generate image with a polling loop\nCreate the image on [AtlasCloud](https://www.atlascloud.ai/?ref=8QKPJE), wait and poll until it is ready, then extract the URL (or stop on error)."
      },
      "typeVersion": 1
    },
    {
      "id": "4ece9b7f-adab-4180-a7de-da13ec8a51d8",
      "name": "Sticky Note 4c951f3f",
      "type": "n8n-nodes-base.stickyNote",
      "position": [
        2880,
        0
      ],
      "parameters": {
        "color": 7,
        "width": 372,
        "height": 904,
        "content": "## 4. Publish to your socials\nPublish the image and captions to LinkedIn, X and Instagram via [Blotato](https://blotato.com/?ref=firas), then confirm in Telegram."
      },
      "typeVersion": 1
    },
    {
      "id": "8766c32e-372f-45de-8a69-818a57ad3c44",
      "name": "Read web link content",
      "type": "n8n-nodes-base.code",
      "position": [
        1232,
        256
      ],
      "parameters": {
        "jsCode": "const item = $input.first().json;\nconst text = (item.message && item.message.text) ? item.message.text : '';\nconst match = text.match(/https?:\\/\\/[^\\s)]+/);\nlet source_url = match ? match[0] : '';\nlet page_content = '';\nif (source_url) {\n  try {\n    const res = await this.helpers.httpRequest({ url: source_url, method: 'GET', headers: { 'User-Agent': 'Mozilla/5.0 (compatible; n8n)' }, timeout: 15000 });\n    const raw = typeof res === 'string' ? res : JSON.stringify(res);\n    page_content = raw\n      .replace(/<script[\\s\\S]*?<\\/script>/gi, ' ')\n      .replace(/<style[\\s\\S]*?<\\/style>/gi, ' ')\n      .replace(/<[^>]+>/g, ' ')\n      .replace(/&nbsp;/gi, ' ')\n      .replace(/\\s+/g, ' ')\n      .trim()\n      .slice(0, 3000);\n  } catch (e) {\n    page_content = '';\n  }\n}\nreturn [{ json: Object.assign({}, item, { source_url, page_content }) }];"
      },
      "typeVersion": 2
    }
  ],
  "active": false,
  "settings": {
    "binaryMode": "separate",
    "executionOrder": "v1"
  },
  "versionId": "40174ce6-77df-488c-888e-b596c9dd0878",
  "nodeGroups": [],
  "connections": {
    "Publish to X": {
      "main": [
        [
          {
            "node": "Publish to Instagram",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "Wait for image": {
      "main": [
        [
          {
            "node": "Poll image result",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "AI content agent": {
      "main": [
        [
          {
            "node": "Generate image (Grok)",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "Extract image URL": {
      "main": [
        [
          {
            "node": "Publish to LinkedIn",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "OpenAI Chat Model": {
      "ai_languageModel": [
        [
          {
            "node": "AI content agent",
            "type": "ai_languageModel",
            "index": 0
          },
          {
            "node": "Format the AI output",
            "type": "ai_languageModel",
            "index": 0
          }
        ]
      ]
    },
    "Poll image result": {
      "main": [
        [
          {
            "node": "Check image status",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "Check image status": {
      "main": [
        [
          {
            "node": "Extract image URL",
            "type": "main",
            "index": 0
          }
        ],
        [
          {
            "node": "Wait for image",
            "type": "main",
            "index": 0
          }
        ],
        [
          {
            "node": "Stop on image error",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "Conversation memory": {
      "ai_memory": [
        [
          {
            "node": "AI content agent",
            "type": "ai_memory",
            "index": 0
          }
        ]
      ]
    },
    "Publish to LinkedIn": {
      "main": [
        [
          {
            "node": "Publish to X",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "Format the AI output": {
      "ai_outputParser": [
        [
          {
            "node": "AI content agent",
            "type": "ai_outputParser",
            "index": 0
          }
        ]
      ]
    },
    "Publish to Instagram": {
      "main": [
        [
          {
            "node": "Confirm on Telegram",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "Generate image (Grok)": {
      "main": [
        [
          {
            "node": "Wait for image",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "Read web link content": {
      "main": [
        [
          {
            "node": "AI content agent",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "Brand and image settings": {
      "main": [
        [
          {
            "node": "Read web link content",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "Receive idea or link on Telegram": {
      "main": [
        [
          {
            "node": "Brand and image settings",
            "type": "main",
            "index": 0
          }
        ]
      ]
    }
  }
}