{
  "id": "R7O2A5FSBtw4L5Ff",
  "name": "Create and publish AI social posts to LinkedIn, X and Instagram",
  "tags": [],
  "nodes": [
    {
      "id": "b850d252-23b2-4edb-8d30-d30a63aa34ca",
      "name": "Receive request on Telegram",
      "type": "n8n-nodes-base.telegramTrigger",
      "position": [
        784,
        256
      ],
      "parameters": {
        "updates": [
          "message"
        ],
        "additionalFields": {}
      },
      "credentials": {
        "telegramApi": {
          "name": "<your credential>"
        }
      },
      "typeVersion": 1.3
    },
    {
      "id": "881a8031-462c-428b-aa0d-caeb7b350dff",
      "name": "Workflow settings",
      "type": "n8n-nodes-base.set",
      "position": [
        1120,
        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": "49d96cf0-9fb2-4ca2-a971-fcf8c5d7b516",
      "name": "AI content agent",
      "type": "@n8n/n8n-nodes-langchain.agent",
      "position": [
        1392,
        256
      ],
      "parameters": {
        "text": "={{ $('Receive request on Telegram').item.json.message.text }}",
        "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 (article or YouTube). 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, FIRST use the \"Read a web link\" tool to read it, then base the content on 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": "75c11cbb-db97-4db3-a02f-1dd744e5681e",
      "name": "OpenAI Chat Model",
      "type": "@n8n/n8n-nodes-langchain.lmChatOpenAi",
      "position": [
        1200,
        480
      ],
      "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": "01c07cca-ec9d-451b-9990-3e8b502537f9",
      "name": "Conversation memory",
      "type": "@n8n/n8n-nodes-langchain.memoryBufferWindow",
      "position": [
        1360,
        464
      ],
      "parameters": {
        "sessionKey": "={{ $('Receive request on Telegram').item.json.message.chat.id }}",
        "sessionIdType": "customKey"
      },
      "typeVersion": 1.4
    },
    {
      "id": "efef5fd6-4790-4f3c-9d6d-41e188b07a05",
      "name": "Read a web link",
      "type": "@n8n/n8n-nodes-langchain.toolHttpRequest",
      "position": [
        1536,
        464
      ],
      "parameters": {
        "url": "={{ /*n8n-auto-generated-fromAI-override*/ $fromAI('url', 'The full URL including https:// to fetch and read') }}",
        "maxLength": 3000,
        "onlyContent": true,
        "responseType": "html",
        "toolDescription": "Fetch and read the main text of a web page, article, blog post or YouTube page. Use this ONLY when the user message contains a URL to repurpose. Pass the full URL including https://.",
        "optimizeResponse": true,
        "truncateResponse": true
      },
      "typeVersion": 1.1
    },
    {
      "id": "d9343c7e-a972-4521-aebf-5e10ccc1a833",
      "name": "Format the content",
      "type": "@n8n/n8n-nodes-langchain.outputParserStructured",
      "position": [
        1712,
        448
      ],
      "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": "06cf9c2b-6edb-431d-a489-f68e406de939",
      "name": "Generate image (Grok)",
      "type": "n8n-nodes-base.httpRequest",
      "position": [
        1952,
        256
      ],
      "parameters": {
        "url": "https://api.atlascloud.ai/api/v1/model/generateImage",
        "method": "POST",
        "options": {},
        "sendBody": true,
        "authentication": "genericCredentialType",
        "bodyParameters": {
          "parameters": [
            {
              "name": "model",
              "value": "={{ $('Workflow settings').item.json.atlas_model }}"
            },
            {
              "name": "num_images",
              "value": "={{ 1 }}"
            },
            {
              "name": "aspect_ratio",
              "value": "={{ $('Workflow settings').item.json.aspect_ratio }}"
            },
            {
              "name": "resolution",
              "value": "={{ $('Workflow 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": "761ebace-8de8-450b-be47-8ac9d6519c19",
      "name": "Wait for image",
      "type": "n8n-nodes-base.wait",
      "position": [
        2144,
        256
      ],
      "parameters": {},
      "typeVersion": 1.1
    },
    {
      "id": "f3533970-1c0d-4e75-a7bc-402aa6c684f8",
      "name": "Poll image result",
      "type": "n8n-nodes-base.httpRequest",
      "position": [
        2336,
        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": "7697003c-a6c1-46ba-924a-2402f3cacdc6",
      "name": "Check image status",
      "type": "n8n-nodes-base.switch",
      "position": [
        2544,
        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": "8012ffde-513f-4ced-8748-5be54d079bf0",
      "name": "Extract image URL",
      "type": "n8n-nodes-base.set",
      "position": [
        2768,
        144
      ],
      "parameters": {
        "options": {},
        "assignments": {
          "assignments": [
            {
              "id": "u1",
              "name": "image_url",
              "type": "string",
              "value": "={{ $json.data.outputs[0] }}"
            }
          ]
        }
      },
      "typeVersion": 3.4
    },
    {
      "id": "72eae9e1-5c43-4bd1-b56d-fd1262c3a778",
      "name": "Publish to LinkedIn",
      "type": "@blotato/n8n-nodes-blotato.blotato",
      "position": [
        3056,
        144
      ],
      "parameters": {
        "options": {},
        "platform": "linkedin",
        "accountId": {
          "__rl": true,
          "mode": "list",
          "value": "1446",
          "cachedResultUrl": "https://backend.blotato.com/v2/accounts/1446",
          "cachedResultName": "Samuel Amalric"
        },
        "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": "3af5d058-e1c7-431c-822e-08fe7f44a978",
      "name": "Publish to X",
      "type": "@blotato/n8n-nodes-blotato.blotato",
      "position": [
        3056,
        320
      ],
      "parameters": {
        "options": {},
        "platform": "twitter",
        "accountId": {
          "__rl": true,
          "mode": "list",
          "value": "1289",
          "cachedResultUrl": "https://backend.blotato.com/v2/accounts/1289",
          "cachedResultName": "Docteur_Firas"
        },
        "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": "c2683cf2-3029-4c3c-a006-bb1683e09827",
      "name": "Publish to Instagram",
      "type": "@blotato/n8n-nodes-blotato.blotato",
      "position": [
        3056,
        480
      ],
      "parameters": {
        "options": {},
        "accountId": {
          "__rl": true,
          "mode": "list",
          "value": "1687",
          "cachedResultUrl": "https://backend.blotato.com/v2/accounts/1687",
          "cachedResultName": "acces.a.vie"
        },
        "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": "a752b911-cf3b-4341-a32b-9513a4918eaf",
      "name": "Confirm on Telegram",
      "type": "n8n-nodes-base.telegram",
      "position": [
        3056,
        704
      ],
      "parameters": {
        "text": "=Done. Your post was published to LinkedIn, X and Instagram.\n\nImage: {{ $('Extract image URL').item.json.image_url }}",
        "chatId": "={{ $('Receive request on Telegram').item.json.message.chat.id }}",
        "additionalFields": {
          "appendAttribution": false
        }
      },
      "credentials": {
        "telegramApi": {
          "name": "<your credential>"
        }
      },
      "typeVersion": 1.2
    },
    {
      "id": "c3fdb2ff-6412-4168-aa3c-b092059e0506",
      "name": "Stop and error",
      "type": "n8n-nodes-base.stopAndError",
      "position": [
        2768,
        384
      ],
      "parameters": {
        "errorMessage": "Image generation failed on AtlasCloud. Check your AtlasCloud credits and the prompt."
      },
      "typeVersion": 1
    },
    {
      "id": "d9f8ed1f-9d27-41e1-a3c6-56ded29bd287",
      "name": "Sticky Note 0701ff85",
      "type": "n8n-nodes-base.stickyNote",
      "position": [
        0,
        0
      ],
      "parameters": {
        "width": 632,
        "height": 1148,
        "content": "## Create and publish AI social posts to LinkedIn, X and Instagram from Telegram\n\nSend one idea (or a link) to your Telegram bot and an AI agent turns it into ready-to-publish posts, with a matching AI-generated image, across LinkedIn, X and Instagram.\n\n## How it works\n1. You message your Telegram bot with a topic, an idea, or a URL to repurpose.\n2. The AI agent (OpenAI) reads your request and, if you sent a link, fetches the page with its web tool.\n3. It returns 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 \"Workflow 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.\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 \"Workflow settings\".\n- Add more platforms in [Blotato](https://blotato.com/?ref=firas) (Facebook, Threads, TikTok).\n- Want live trend research? Add a Perplexity or SerpAPI search tool to the agent."
      },
      "typeVersion": 1
    },
    {
      "id": "d3db0050-37c4-4253-9e4b-1b6b5dd4cb53",
      "name": "Sticky Note ca2083cf",
      "type": "n8n-nodes-base.stickyNote",
      "position": [
        688,
        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": "56d666be-077b-45f5-b7ba-4652557f8c9d",
      "name": "Sticky Note c3072499",
      "type": "n8n-nodes-base.stickyNote",
      "position": [
        1040,
        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": "ec696313-cd59-4c0f-8f15-e57ba6f9641a",
      "name": "Sticky Note 04d44c93",
      "type": "n8n-nodes-base.stickyNote",
      "position": [
        1904,
        0
      ],
      "parameters": {
        "color": 7,
        "width": 992,
        "height": 632,
        "content": "## 3. Generate image with a polling loop\nCreate the image on AtlasCloud, wait and poll until it is ready, then extract the URL (or stop on error)."
      },
      "typeVersion": 1
    },
    {
      "id": "de5840e0-d2c0-4d07-946b-579d7ea33de0",
      "name": "Sticky Note 4c951f3f",
      "type": "n8n-nodes-base.stickyNote",
      "position": [
        2912,
        0
      ],
      "parameters": {
        "color": 7,
        "width": 372,
        "height": 904,
        "content": "## 4. Publish to your socials\nPublish the image and captions to LinkedIn, X and Instagram, then confirm in Telegram."
      },
      "typeVersion": 1
    }
  ],
  "active": false,
  "settings": {
    "binaryMode": "separate",
    "availableInMCP": false,
    "executionOrder": "v1"
  },
  "versionId": "7fbf6994-bfc5-403b-98b9-13d5c3339c6f",
  "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
          }
        ]
      ]
    },
    "Read a web link": {
      "ai_tool": [
        [
          {
            "node": "AI content agent",
            "type": "ai_tool",
            "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 content",
            "type": "ai_languageModel",
            "index": 0
          }
        ]
      ]
    },
    "Poll image result": {
      "main": [
        [
          {
            "node": "Check image status",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "Workflow settings": {
      "main": [
        [
          {
            "node": "AI content agent",
            "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 and error",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "Format the content": {
      "ai_outputParser": [
        [
          {
            "node": "AI content agent",
            "type": "ai_outputParser",
            "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
          }
        ]
      ]
    },
    "Publish to Instagram": {
      "main": [
        [
          {
            "node": "Confirm on Telegram",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "Generate image (Grok)": {
      "main": [
        [
          {
            "node": "Wait for image",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "Receive request on Telegram": {
      "main": [
        [
          {
            "node": "Workflow settings",
            "type": "main",
            "index": 0
          }
        ]
      ]
    }
  }
}