{
  "id": "t4TgsT2Vt4iqmDbH",
  "meta": {
    "builderVariant": "mcp",
    "aiBuilderAssisted": true
  },
  "name": "Publish AI social posts from a Telegram message to LinkedIn, Instagram, Facebook and Threads",
  "tags": [],
  "nodes": [
    {
      "id": "a164e2a6-3e90-4824-a9e1-804c7d6a11ee",
      "name": "Telegram Trigger",
      "type": "n8n-nodes-base.telegramTrigger",
      "position": [
        992,
        -1008
      ],
      "parameters": {
        "updates": [
          "message"
        ],
        "additionalFields": {}
      },
      "credentials": {
        "telegramApi": {
          "name": "<your credential>"
        }
      },
      "typeVersion": 1.3
    },
    {
      "id": "e4123da3-f2db-485b-be34-b1a472ff7ec1",
      "name": "Configuration",
      "type": "n8n-nodes-base.set",
      "position": [
        1168,
        -1008
      ],
      "parameters": {
        "options": {},
        "assignments": {
          "assignments": [
            {
              "id": "cfg-chat-model",
              "name": "chat_model",
              "type": "string",
              "value": "gpt-5.4"
            },
            {
              "id": "cfg-output-language",
              "name": "output_language",
              "type": "string",
              "value": "auto"
            },
            {
              "id": "cfg-image-size",
              "name": "image_size",
              "type": "string",
              "value": "1024x1024"
            },
            {
              "id": "cfg-image-quality",
              "name": "image_quality",
              "type": "string",
              "value": "high"
            }
          ]
        },
        "includeOtherFields": true
      },
      "typeVersion": 3.4
    },
    {
      "id": "475495c1-d72c-4429-8264-303c0872944f",
      "name": "Route by input type",
      "type": "n8n-nodes-base.switch",
      "position": [
        1376,
        -1008
      ],
      "parameters": {
        "rules": {
          "values": [
            {
              "outputKey": "Voice",
              "conditions": {
                "options": {
                  "version": 1,
                  "leftValue": "",
                  "caseSensitive": true,
                  "typeValidation": "loose"
                },
                "combinator": "and",
                "conditions": [
                  {
                    "operator": {
                      "type": "string",
                      "operation": "exists",
                      "singleValue": true
                    },
                    "leftValue": "={{ $json.message.voice.file_id }}",
                    "rightValue": ""
                  }
                ]
              },
              "renameOutput": true
            },
            {
              "outputKey": "Text",
              "conditions": {
                "options": {
                  "version": 1,
                  "leftValue": "",
                  "caseSensitive": true,
                  "typeValidation": "loose"
                },
                "combinator": "and",
                "conditions": [
                  {
                    "operator": {
                      "type": "string",
                      "operation": "exists",
                      "singleValue": true
                    },
                    "leftValue": "={{ $json.message.text }}",
                    "rightValue": ""
                  }
                ]
              },
              "renameOutput": true
            }
          ]
        },
        "options": {}
      },
      "typeVersion": 3.4
    },
    {
      "id": "a42b1bc3-4318-4d29-938a-301f01e85499",
      "name": "Download voice file",
      "type": "n8n-nodes-base.telegram",
      "position": [
        1568,
        -1024
      ],
      "parameters": {
        "fileId": "={{ $json.message.voice.file_id }}",
        "resource": "file",
        "additionalFields": {}
      },
      "credentials": {
        "telegramApi": {
          "name": "<your credential>"
        }
      },
      "typeVersion": 1.2
    },
    {
      "id": "216f891a-6639-40c3-a900-c0c1464818e4",
      "name": "Transcribe voice",
      "type": "@n8n/n8n-nodes-langchain.openAi",
      "position": [
        1760,
        -1024
      ],
      "parameters": {
        "options": {},
        "resource": "audio",
        "operation": "transcribe"
      },
      "credentials": {
        "openAiApi": {
          "name": "<your credential>"
        }
      },
      "typeVersion": 2.3
    },
    {
      "id": "d3988434-e887-4928-a0b1-53e6fac97d12",
      "name": "Set message (voice)",
      "type": "n8n-nodes-base.set",
      "position": [
        1920,
        -1024
      ],
      "parameters": {
        "options": {},
        "assignments": {
          "assignments": [
            {
              "id": "msg-voice",
              "name": "user_message",
              "type": "string",
              "value": "={{ $json.text }}"
            }
          ]
        }
      },
      "typeVersion": 3.4
    },
    {
      "id": "b13ad7c1-f07b-4ee0-931f-a891f3961714",
      "name": "Set message (text)",
      "type": "n8n-nodes-base.set",
      "position": [
        2112,
        -992
      ],
      "parameters": {
        "options": {},
        "assignments": {
          "assignments": [
            {
              "id": "msg-text",
              "name": "user_message",
              "type": "string",
              "value": "={{ $('Telegram Trigger').item.json.message.text }}"
            }
          ]
        }
      },
      "typeVersion": 3.4
    },
    {
      "id": "7fe08b81-efea-4838-b449-55fcb2bc4531",
      "name": "Generate social post",
      "type": "@n8n/n8n-nodes-langchain.agent",
      "position": [
        976,
        -336
      ],
      "parameters": {
        "text": "={{ $json.user_message }}",
        "options": {
          "systemMessage": "=You are a senior social media ghostwriter and art director for a personal brand. You receive a raw idea (from a Telegram voice note or text) and turn it into ONE polished, ready-to-publish social media caption that works across LinkedIn, Instagram, Facebook and Threads, plus a matching image prompt.\n\nLANGUAGE: Write the caption in {{ $('Configuration').item.json.output_language }}. If that value is \"auto\", write it in the SAME language as the user's message.\n\nCAPTION RULES:\n- Open with a strong scroll-stopping hook (max ~10 words) on its own line.\n- 3-6 short paragraphs, 1-2 sentences each, with line breaks for readability.\n- Conversational, authentic, first person. No corporate buzzwords.\n- Use ONLY the information in the user's message. Never invent facts.\n- End with one clear question or call to action.\n- Plain text only: NO markdown, NO bold, NO headings.\n- Max 3 relevant hashtags on the last line (optional).\n- Max 2 emojis in the whole caption.\n- Keep it under 2200 characters so it fits every platform.\n\nIMAGE PROMPT RULES:\n- Describe ONE clean, modern, professional image that visually represents the main idea (use a metaphor, not literal text).\n- No text, words, logos, or identifiable real people in the image.\n- Mention subject, setting, style, lighting, colors and composition.\n\nReturn ONLY the structured object with 'caption' and 'image_prompt'."
        },
        "promptType": "define",
        "hasOutputParser": true
      },
      "typeVersion": 3.1
    },
    {
      "id": "b1bd1453-59a9-45dc-8a3d-a4cf526d8e8f",
      "name": "OpenAI Chat Model",
      "type": "@n8n/n8n-nodes-langchain.lmChatOpenAi",
      "position": [
        976,
        -96
      ],
      "parameters": {
        "model": {
          "__rl": true,
          "mode": "id",
          "value": "={{ $('Configuration').item.json.chat_model }}"
        },
        "options": {},
        "builtInTools": {}
      },
      "credentials": {
        "openAiApi": {
          "name": "<your credential>"
        }
      },
      "typeVersion": 1.3
    },
    {
      "id": "22fcf25c-7fff-4155-ae3e-d1fada5dcdc8",
      "name": "Caption + image prompt",
      "type": "@n8n/n8n-nodes-langchain.outputParserStructured",
      "position": [
        1120,
        -80
      ],
      "parameters": {
        "jsonSchemaExample": "{\n  \"caption\": \"Ready-to-post caption text here\",\n  \"image_prompt\": \"A detailed visual description for the AI image generator\"\n}"
      },
      "typeVersion": 1.3
    },
    {
      "id": "532839d0-5756-4fef-925e-edeab7b5ad9d",
      "name": "Create image",
      "type": "@n8n/n8n-nodes-langchain.openAi",
      "position": [
        1312,
        -336
      ],
      "parameters": {
        "prompt": "={{ $('Generate social post').item.json.output.image_prompt }}",
        "modelId": {
          "__rl": true,
          "mode": "list",
          "value": "gpt-image-1",
          "cachedResultName": "gpt-image-1"
        },
        "options": {
          "size": "={{ $('Configuration').item.json.image_size }}",
          "quality": "={{ $('Configuration').item.json.image_quality }}"
        },
        "resource": "image"
      },
      "credentials": {
        "openAiApi": {
          "name": "<your credential>"
        }
      },
      "typeVersion": 2.3
    },
    {
      "id": "1b964732-1e99-4139-9551-9cfe3812f5d3",
      "name": "Upload image to Blotato",
      "type": "@blotato/n8n-nodes-blotato.blotato",
      "position": [
        1600,
        -336
      ],
      "parameters": {
        "resource": "media",
        "useBinaryData": true
      },
      "credentials": {
        "blotatoApi": {
          "name": "<your credential>"
        }
      },
      "typeVersion": 2
    },
    {
      "id": "06154ece-1100-411a-a1fb-e8e541ba02af",
      "name": "Post to LinkedIn",
      "type": "@blotato/n8n-nodes-blotato.blotato",
      "onError": "continueRegularOutput",
      "position": [
        1776,
        -336
      ],
      "parameters": {
        "options": {},
        "platform": "linkedin",
        "accountId": {
          "__rl": true,
          "mode": "list",
          "value": "1446",
          "cachedResultUrl": "https://backend.blotato.com/v2/accounts/1446",
          "cachedResultName": "Samuel Amalric"
        },
        "postContentText": "={{ $('Generate social post').item.json.output.caption }}",
        "postContentMediaUrls": "={{ $('Upload image to Blotato').item.json.url }}"
      },
      "credentials": {
        "blotatoApi": {
          "name": "<your credential>"
        }
      },
      "typeVersion": 2
    },
    {
      "id": "6815826a-ef64-4da6-abac-3fa8974b8373",
      "name": "Post to Instagram",
      "type": "@blotato/n8n-nodes-blotato.blotato",
      "onError": "continueRegularOutput",
      "position": [
        1936,
        -336
      ],
      "parameters": {
        "options": {},
        "accountId": {
          "__rl": true,
          "mode": "list",
          "value": "11892",
          "cachedResultUrl": "https://backend.blotato.com/v2/accounts/11892",
          "cachedResultName": "doc.firass"
        },
        "postContentText": "={{ $('Generate social post').item.json.output.caption }}",
        "postContentMediaUrls": "={{ $('Upload image to Blotato').item.json.url }}"
      },
      "credentials": {
        "blotatoApi": {
          "name": "<your credential>"
        }
      },
      "typeVersion": 2
    },
    {
      "id": "84816d9d-6354-4575-ba3b-8994416ab0ca",
      "name": "Post to Facebook",
      "type": "@blotato/n8n-nodes-blotato.blotato",
      "onError": "continueRegularOutput",
      "position": [
        2144,
        -336
      ],
      "parameters": {
        "options": {},
        "platform": "facebook",
        "accountId": {
          "__rl": true,
          "mode": "list",
          "value": "1759",
          "cachedResultUrl": "https://backend.blotato.com/v2/accounts/1759",
          "cachedResultName": "Firass Ben"
        },
        "facebookPageId": {
          "__rl": true,
          "mode": "list",
          "value": "101603614680195",
          "cachedResultUrl": "https://backend.blotato.com/v2/accounts/1759/subaccounts/101603614680195",
          "cachedResultName": "Dr. Firas"
        },
        "postContentText": "={{ $('Generate social post').item.json.output.caption }}",
        "postContentMediaUrls": "={{ $('Upload image to Blotato').item.json.url }}"
      },
      "credentials": {
        "blotatoApi": {
          "name": "<your credential>"
        }
      },
      "typeVersion": 2
    },
    {
      "id": "88e676a3-679c-47bd-a71a-c301b5275bf0",
      "name": "Post to Threads",
      "type": "@blotato/n8n-nodes-blotato.blotato",
      "onError": "continueRegularOutput",
      "position": [
        2352,
        -336
      ],
      "parameters": {
        "options": {},
        "platform": "threads",
        "accountId": {
          "__rl": true,
          "mode": "list",
          "value": "2280",
          "cachedResultUrl": "https://backend.blotato.com/v2/accounts/2280",
          "cachedResultName": "doc.firass"
        },
        "postContentText": "={{ $('Generate social post').item.json.output.caption }}",
        "postContentMediaUrls": "={{ $('Upload image to Blotato').item.json.url }}"
      },
      "credentials": {
        "blotatoApi": {
          "name": "<your credential>"
        }
      },
      "typeVersion": 2
    },
    {
      "id": "143f5eb1-391e-4034-a447-8bf4b98928b2",
      "name": "Notify on Telegram",
      "type": "n8n-nodes-base.telegram",
      "position": [
        2800,
        -336
      ],
      "parameters": {
        "text": "=\u2705 Your post has been published to LinkedIn, Instagram, Facebook and Threads.\n\n\u2014\u2014\u2014\n{{ $('Generate social post').item.json.output.caption }}",
        "chatId": "={{ $('Telegram Trigger').item.json.message.chat.id }}",
        "additionalFields": {
          "appendAttribution": false
        }
      },
      "credentials": {
        "telegramApi": {
          "name": "<your credential>"
        }
      },
      "typeVersion": 1.2
    },
    {
      "id": "4065fb0d-d0a0-4be9-99b6-583cf602cddc",
      "name": "Overview",
      "type": "n8n-nodes-base.stickyNote",
      "position": [
        0,
        -1376
      ],
      "parameters": {
        "width": 860,
        "height": 2156,
        "content": "# Publish AI social posts from a Telegram message to LinkedIn, Instagram, Facebook and Threads\n\n# \ud83d\udce5  [Open full documentation on Notion](https://automatisation.notion.site/Course-Publish-AI-social-posts-from-a-Telegram-message-to-LinkedIn-Instagram-Facebook-and-Thread-39b3d6550fd981aab729c41790b2dc63)\n\nSend a quick **voice note or text** to your Telegram bot. An AI turns it into one polished, ready-to-publish caption, generates a matching image, and publishes everything to **LinkedIn, Instagram, Facebook and Threads** through [Blotato](https://blotato.com/?ref=firas) \u2014 then confirms back on Telegram.\n\nOne idea in. Four posts + one image out. No copy-pasting, no reformatting per network.\n\n## How it works\n1. **Telegram Trigger** receives your voice note or text.\n2. **Configuration** centralises every setting a beginner might change.\n3. **Route by input type** sends voice to transcription, text straight through.\n4. **Transcribe voice** (OpenAI Whisper) turns speech into text.\n5. **Generate social post** (AI agent) writes one caption + an image prompt.\n6. **Create image** (OpenAI gpt-image-1) generates the visual.\n7. **Upload image to Blotato** hosts the image and returns a URL.\n8. **Post to LinkedIn / Instagram / Facebook / Threads** publishes caption + image.\n9. **Notify on Telegram** confirms and shows the caption that went out.\n\n## Setup\n1. Create a Telegram bot with **@BotFather**, put the token in a Telegram credential, and select it on the 3 Telegram nodes.\n2. Add your **OpenAI** API key and select it on *Transcribe voice*, *OpenAI Chat Model* and *Create image*.\n3. Connect your **[Blotato](https://blotato.com/?ref=firas)** account, then on each *Post to \u2026* node pick the matching social account in the **Account** dropdown (Facebook also needs a Page).\n4. Open **Configuration** and adjust the 4 variables if needed.\n5. **Activate** the workflow, then send a voice note or a message to your bot.\n\n## Requirements\n- **Self-hosted n8n** (or n8n Cloud with Verified Community Nodes) \u2014 Blotato is a community node.\n- Telegram Bot token\n- OpenAI API key (Whisper + gpt-image-1)\n- A [Blotato](https://blotato.com/?ref=firas) account with LinkedIn, Instagram, Facebook and Threads connected\n\n## Customization\n- Change the writing style, language or length in the **Generate social post** system prompt.\n- Set `output_language` to `auto` (match the message), `English`, `French`, \u2026\n- Swap `image_size` / `image_quality` in **Configuration**.\n- Add or remove a network: disable the *Post to \u2026* node you don't want.\n- Want a human check first? Add a Telegram approval step before the *Post* nodes.\n\n---\nNeed help customizing?\nContact me for consulting and support : [Linkedin](https://www.linkedin.com/in/doctor-firass/)\n\n# MY NEW YOUTUBE CHANNEL\n\ud83d\udc49 [Subscribe to my new YouTube channel](https://www.youtube.com/@DrFiras_AI). Here I'll share videos and Shorts with practical tutorials and FREE templates for n8n.\n\n[![The AI Doctor](https://www.dr-firas.com/the-ai-doctor.png)](https://www.youtube.com/@DrFiras_AI)"
      },
      "typeVersion": 1
    },
    {
      "id": "3fc6ea6a-f2e5-4f80-a2fd-93153c472177",
      "name": "Section - Input",
      "type": "n8n-nodes-base.stickyNote",
      "position": [
        944,
        -1248
      ],
      "parameters": {
        "color": 7,
        "width": 1360,
        "height": 514,
        "content": "## 1 \u00b7 Input & configuration\nTelegram voice or text comes in. **Configuration** is the single place to edit settings: `chat_model`, `output_language` (`auto` = match the message), `image_size`, `image_quality`. Voice notes are transcribed by Whisper; text passes straight through."
      },
      "typeVersion": 1
    },
    {
      "id": "3b0b9850-ba8b-44a5-83b3-bf565986892a",
      "name": "Section - AI",
      "type": "n8n-nodes-base.stickyNote",
      "position": [
        928,
        -640
      ],
      "parameters": {
        "color": 7,
        "width": 560,
        "height": 520,
        "content": "## 2 \u00b7 AI: caption + image\nThe agent writes ONE caption + an image prompt (structured output), using the model set in Configuration. gpt-image-1 turns the prompt into the visual.\n\nThe AI drafts \u2014 you keep control of quality before it goes out."
      },
      "typeVersion": 1
    },
    {
      "id": "e6ab6efd-15b0-4238-8a87-5694be68b58e",
      "name": "Section - Publish",
      "type": "n8n-nodes-base.stickyNote",
      "position": [
        1536,
        -640
      ],
      "parameters": {
        "color": 7,
        "width": 1120,
        "height": 530,
        "content": "## 3 \u00b7 Publish everywhere via Blotato\nThe image is uploaded to Blotato (\u2192 URL), then posted to LinkedIn, Instagram, Facebook and Threads. Pick the account in each node's **Account** dropdown. One node per network \u2014 disable any you don't want.\n\nNeeds self-hosted n8n (Blotato community node)."
      },
      "typeVersion": 1
    },
    {
      "id": "c3426359-5ae5-4c53-a817-738ba54b5a98",
      "name": "Section - Confirm",
      "type": "n8n-nodes-base.stickyNote",
      "position": [
        2720,
        -640
      ],
      "parameters": {
        "color": 7,
        "width": 250,
        "height": 530,
        "content": "## 4 \u00b7 Confirmation\nSends the published caption back to you on Telegram."
      },
      "typeVersion": 1
    }
  ],
  "active": false,
  "settings": {
    "binaryMode": "separate",
    "availableInMCP": true,
    "executionOrder": "v1"
  },
  "versionId": "235b7bf3-269d-471a-a4a9-9f856b30ccae",
  "nodeGroups": [],
  "connections": {
    "Create image": {
      "main": [
        [
          {
            "node": "Upload image to Blotato",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "Configuration": {
      "main": [
        [
          {
            "node": "Route by input type",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "Post to Threads": {
      "main": [
        [
          {
            "node": "Notify on Telegram",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "Post to Facebook": {
      "main": [
        [
          {
            "node": "Post to Threads",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "Post to LinkedIn": {
      "main": [
        [
          {
            "node": "Post to Instagram",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "Telegram Trigger": {
      "main": [
        [
          {
            "node": "Configuration",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "Transcribe voice": {
      "main": [
        [
          {
            "node": "Set message (voice)",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "OpenAI Chat Model": {
      "ai_languageModel": [
        [
          {
            "node": "Generate social post",
            "type": "ai_languageModel",
            "index": 0
          }
        ]
      ]
    },
    "Post to Instagram": {
      "main": [
        [
          {
            "node": "Post to Facebook",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "Set message (text)": {
      "main": [
        [
          {
            "node": "Generate social post",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "Download voice file": {
      "main": [
        [
          {
            "node": "Transcribe voice",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "Route by input type": {
      "main": [
        [
          {
            "node": "Download voice file",
            "type": "main",
            "index": 0
          }
        ],
        [
          {
            "node": "Set message (text)",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "Set message (voice)": {
      "main": [
        [
          {
            "node": "Generate social post",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "Generate social post": {
      "main": [
        [
          {
            "node": "Create image",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "Caption + image prompt": {
      "ai_outputParser": [
        [
          {
            "node": "Generate social post",
            "type": "ai_outputParser",
            "index": 0
          }
        ]
      ]
    },
    "Upload image to Blotato": {
      "main": [
        [
          {
            "node": "Post to LinkedIn",
            "type": "main",
            "index": 0
          }
        ]
      ]
    }
  }
}