{
  "id": "HhPHMKuMuDwgwsot",
  "name": "Publish AI video reels to Instagram from Telegram messages",
  "tags": [],
  "nodes": [
    {
      "id": "198b0742-7ffc-4e8a-aa23-3448f4e59a0f",
      "name": "Telegram Trigger",
      "type": "n8n-nodes-base.telegramTrigger",
      "position": [
        608,
        304
      ],
      "parameters": {
        "updates": [
          "message"
        ],
        "additionalFields": {}
      },
      "typeVersion": 1.3
    },
    {
      "id": "fcf9f974-a967-4648-ac36-f2ca1569c1ae",
      "name": "Configuration",
      "type": "n8n-nodes-base.set",
      "position": [
        784,
        304
      ],
      "parameters": {
        "options": {},
        "assignments": {
          "assignments": [
            {
              "id": "a1",
              "name": "user_idea",
              "type": "string",
              "value": "={{ $('Telegram Trigger').item.json.message.text }}"
            },
            {
              "id": "a2",
              "name": "telegram_chat_id",
              "type": "string",
              "value": "={{ $('Telegram Trigger').item.json.message.chat.id }}"
            },
            {
              "id": "a3",
              "name": "openai_model",
              "type": "string",
              "value": "gpt-4o-mini"
            },
            {
              "id": "a4",
              "name": "atlas_generate_url",
              "type": "string",
              "value": "https://api.atlascloud.ai/api/v1/model/generateVideo"
            },
            {
              "id": "a5",
              "name": "atlas_status_url",
              "type": "string",
              "value": "https://api.atlascloud.ai/api/v1/model/prediction/"
            },
            {
              "id": "a6",
              "name": "atlas_model",
              "type": "string",
              "value": "bytedance/seedance-2.0/text-to-video"
            },
            {
              "id": "a7",
              "name": "video_width",
              "type": "number",
              "value": 720
            },
            {
              "id": "a8",
              "name": "video_height",
              "type": "number",
              "value": 1280
            },
            {
              "id": "a9",
              "name": "video_duration",
              "type": "number",
              "value": 8
            },
            {
              "id": "a10",
              "name": "video_fps",
              "type": "number",
              "value": 24
            },
            {
              "id": "a11",
              "name": "poll_wait_seconds",
              "type": "number",
              "value": 15
            },
            {
              "id": "a12",
              "name": "instagram_media_type",
              "type": "string",
              "value": "reel"
            }
          ]
        },
        "includeOtherFields": true
      },
      "typeVersion": 3.4
    },
    {
      "id": "6c0f8e28-ef40-48ad-9ebf-b700cb2a8aa3",
      "name": "Generate Video Prompt",
      "type": "@n8n/n8n-nodes-langchain.agent",
      "position": [
        944,
        304
      ],
      "parameters": {
        "text": "={{ $('Configuration').item.json.user_idea }}",
        "options": {
          "systemMessage": "You are a creative video prompt generator for short-form vertical reels (Instagram, TikTok). Based on the user's idea, craft one elaborate, visually descriptive video generation prompt for a text-to-video model. Output ONLY the prompt, with no explanation or commentary. The prompt must: be under 100 words, describe visual elements, tone, lighting and motion clearly, and suit a 9:16 vertical format."
        },
        "promptType": "define"
      },
      "typeVersion": 3.1
    },
    {
      "id": "ed7a274e-384b-4edb-b461-85d27753ff05",
      "name": "OpenAI Model (Prompt)",
      "type": "@n8n/n8n-nodes-langchain.lmChatOpenAi",
      "position": [
        944,
        544
      ],
      "parameters": {
        "model": {
          "__rl": true,
          "mode": "id",
          "value": "={{ $('Configuration').item.json.openai_model }}"
        },
        "options": {},
        "builtInTools": {}
      },
      "typeVersion": 1.3
    },
    {
      "id": "d9df10b3-3eb8-4d27-bb24-74dabe7b60d1",
      "name": "Generate Video with Seedance",
      "type": "n8n-nodes-base.httpRequest",
      "position": [
        1232,
        304
      ],
      "parameters": {
        "url": "={{ $('Configuration').item.json.atlas_generate_url }}",
        "method": "POST",
        "options": {},
        "jsonBody": "={ \"model\": \"{{ $('Configuration').item.json.atlas_model }}\", \"prompt\": {{ JSON.stringify($('Generate Video Prompt').item.json.output) }}, \"width\": {{ $('Configuration').item.json.video_width }}, \"height\": {{ $('Configuration').item.json.video_height }}, \"duration\": {{ $('Configuration').item.json.video_duration }}, \"fps\": {{ $('Configuration').item.json.video_fps }} }",
        "sendBody": true,
        "specifyBody": "json",
        "authentication": "genericCredentialType",
        "genericAuthType": "httpHeaderAuth"
      },
      "typeVersion": 4.4
    },
    {
      "id": "caa58509-a15b-4f86-aa79-35d10b71eaa8",
      "name": "Wait Before Polling",
      "type": "n8n-nodes-base.wait",
      "position": [
        1408,
        304
      ],
      "parameters": {
        "amount": "={{ $('Configuration').item.json.poll_wait_seconds }}"
      },
      "typeVersion": 1.1
    },
    {
      "id": "3b982b24-53f4-4220-b943-6a18c0332300",
      "name": "Get Video Status",
      "type": "n8n-nodes-base.httpRequest",
      "position": [
        1552,
        304
      ],
      "parameters": {
        "url": "={{ $('Configuration').item.json.atlas_status_url }}{{ $json.data.id }}",
        "options": {},
        "authentication": "genericCredentialType",
        "genericAuthType": "httpHeaderAuth"
      },
      "typeVersion": 4.4
    },
    {
      "id": "ee52d3f3-8020-4a4c-b587-dc0a919dc84c",
      "name": "Is Video Ready?",
      "type": "n8n-nodes-base.if",
      "position": [
        1712,
        304
      ],
      "parameters": {
        "options": {},
        "conditions": {
          "options": {
            "version": 2,
            "leftValue": "",
            "caseSensitive": true,
            "typeValidation": "loose"
          },
          "combinator": "or",
          "conditions": [
            {
              "id": "c1",
              "operator": {
                "type": "string",
                "operation": "equals"
              },
              "leftValue": "={{ $json.data.status }}",
              "rightValue": "completed"
            },
            {
              "id": "c2",
              "operator": {
                "type": "string",
                "operation": "equals"
              },
              "leftValue": "={{ $json.data.status }}",
              "rightValue": "succeeded"
            }
          ]
        }
      },
      "typeVersion": 2.3
    },
    {
      "id": "c14d24a0-9743-4837-b932-591022f9493a",
      "name": "Generate Caption",
      "type": "@n8n/n8n-nodes-langchain.agent",
      "position": [
        1952,
        288
      ],
      "parameters": {
        "text": "=Based on this video generation prompt, write an engaging Instagram caption:\n\n{{ $('Generate Video Prompt').item.json.output }}",
        "options": {
          "systemMessage": "You are an Instagram caption copywriter. You receive a video generation prompt used to create a short vertical reel. Write one engaging, playful caption for the Instagram post. Keep it punchy, add relevant emojis, and include 3 to 5 hashtags."
        },
        "promptType": "define"
      },
      "typeVersion": 3.1
    },
    {
      "id": "55aa4419-535c-419b-bef5-aa1ff655a43f",
      "name": "OpenAI Model (Caption)",
      "type": "@n8n/n8n-nodes-langchain.lmChatOpenAi",
      "position": [
        2000,
        576
      ],
      "parameters": {
        "model": {
          "__rl": true,
          "mode": "id",
          "value": "={{ $('Configuration').item.json.openai_model }}"
        },
        "options": {},
        "builtInTools": {}
      },
      "typeVersion": 1.3
    },
    {
      "id": "1a067ed8-f064-460c-a944-e60a65e3c1a0",
      "name": "Publish Reel to Instagram",
      "type": "@blotato/n8n-nodes-blotato.blotato",
      "position": [
        2480,
        288
      ],
      "parameters": {
        "options": {
          "instagramMediaType": "={{ $('Configuration').item.json.instagram_media_type }}"
        },
        "accountId": {
          "__rl": true,
          "mode": "list",
          "value": "11892",
          "cachedResultUrl": "https://backend.blotato.com/v2/accounts/11892",
          "cachedResultName": "doc.firass"
        },
        "postContentText": "={{ $('Generate Caption').item.json.output }}",
        "postContentMediaUrls": "={{ $('Get Video Status').item.json.data.outputs[0] }}"
      },
      "typeVersion": 2
    },
    {
      "id": "2563060a-c087-47fe-9564-b46639e2af79",
      "name": "Notify on Telegram",
      "type": "n8n-nodes-base.telegram",
      "position": [
        2752,
        288
      ],
      "parameters": {
        "text": "=Your Instagram Reel has been published!\n\nVideo: {{ $('Get Video Status').item.json.data.outputs[0] }}",
        "chatId": "={{ $('Configuration').item.json.telegram_chat_id }}",
        "additionalFields": {
          "appendAttribution": false
        }
      },
      "typeVersion": 1.2
    },
    {
      "id": "033872e3-2a0a-4fe5-b83d-53c89b8f98ff",
      "name": "Sticky Note 6cf9bdf2",
      "type": "n8n-nodes-base.stickyNote",
      "position": [
        0,
        0
      ],
      "parameters": {
        "width": 560,
        "height": 1208,
        "content": "# Publish AI video reels to Instagram from Telegram messages\n\n# \ud83d\udce5  [Open full documentation on Notion](https://automatisation.notion.site/Publish-AI-video-reels-to-Instagram-from-Telegram-Seedance-2-0-3963d6550fd981a19f30d9b037a51915)\n\n## How it works\nTurn a short idea sent on Telegram into a finished vertical reel, then publish it to Instagram automatically.\n\n1. You send a one-line idea to your Telegram bot (e.g. \"a luxury minimalist candle brand, calm aesthetic\").\n2. An AI agent expands it into a rich, cinematic video prompt.\n3. [AtlasCloud](https://www.atlascloud.ai/?ref=8QKPJE) generates a 9:16 video with the Seedance 2.0 Text-to-Video model by ByteDance (native audio).\n4. The workflow polls until the video is ready.\n5. A second AI agent writes an Instagram caption.\n6. [Blotato](https://blotato.com/?ref=firas) publishes the video as an Instagram Reel.\n7. You get a Telegram confirmation with the final video URL.\n\n## Setup\n1. Add your Telegram bot credential on \"Telegram Trigger\" and \"Notify on Telegram\".\n2. On both AtlasCloud HTTP nodes, select your [AtlasCloud](https://www.atlascloud.ai/?ref=8QKPJE) header-auth credential (Authorization: Bearer YOUR_KEY).\n3. On the two OpenAI model nodes, select your OpenAI credential.\n4. On the Blotato node, select your Blotato credential and pick your Instagram account.\n5. Open \"Configuration\" and adjust video size, duration and defaults.\n6. Send a message to your Telegram bot to run it.\n\n## Requirements\n- Telegram bot token\n- OpenAI API key\n- [AtlasCloud](https://www.atlascloud.ai/?ref=8QKPJE) API key (Seedance 2.0, from about $0.11 per second)\n- [Blotato](https://blotato.com/?ref=firas) account with a connected Instagram account. Blotato is a community node: requires n8n self-hosted, or n8n Cloud with Verified Community Nodes enabled. Add a workflow screenshot when submitting to the catalog, since community nodes do not render in the preview.\n\n## Customization\n- Change the model, size, duration or FPS in \"Configuration\".\n- Swap Instagram for another platform in the Blotato node.\n- Edit the two system prompts to change video style or caption tone."
      },
      "typeVersion": 1
    },
    {
      "id": "19f6fa74-98a0-4ccc-80d6-092f6011cac0",
      "name": "Sticky Note a9fe2312",
      "type": "n8n-nodes-base.stickyNote",
      "position": [
        592,
        32
      ],
      "parameters": {
        "color": 7,
        "width": 300,
        "height": 424,
        "content": "## Configuration\nCentralized settings: video size, duration, FPS, model and defaults. A beginner only edits this node."
      },
      "typeVersion": 1
    },
    {
      "id": "c3b56c3f-314c-4da4-9f6d-29f1fd435e56",
      "name": "Sticky Note 680864ed",
      "type": "n8n-nodes-base.stickyNote",
      "position": [
        896,
        32
      ],
      "parameters": {
        "color": 7,
        "width": 300,
        "height": 420,
        "content": "## 1. Prompt generation\nAn AI agent turns your short idea into a rich cinematic prompt for Seedance."
      },
      "typeVersion": 1
    },
    {
      "id": "74a3a9a6-0f9e-406f-be7e-9ee1b96076ef",
      "name": "Sticky Note 22711f2b",
      "type": "n8n-nodes-base.stickyNote",
      "position": [
        1200,
        32
      ],
      "parameters": {
        "color": 7,
        "width": 652,
        "height": 424,
        "content": "## 2. Video generation (Seedance 2.0)\nSubmit to AtlasCloud, then poll every few seconds until the video is ready."
      },
      "typeVersion": 1
    },
    {
      "id": "5ad3a851-2f5d-4f0e-a0dd-0c6eb95987ac",
      "name": "Sticky Note 9be5bcb0",
      "type": "n8n-nodes-base.stickyNote",
      "position": [
        1856,
        32
      ],
      "parameters": {
        "color": 7,
        "width": 560,
        "height": 424,
        "content": "## 3. Caption and publish\nAn AI agent writes the caption, then Blotato publishes the Reel to Instagram."
      },
      "typeVersion": 1
    },
    {
      "id": "bc6ca04b-e3c7-4e62-8b51-c6a6b694e779",
      "name": "Sticky Note b171e2e1",
      "type": "n8n-nodes-base.stickyNote",
      "position": [
        2432,
        32
      ],
      "parameters": {
        "color": 7,
        "width": 540,
        "height": 424,
        "content": "## 4. Telegram confirmation\nSends you a Telegram message with the published video URL."
      },
      "typeVersion": 1
    }
  ],
  "active": false,
  "settings": {
    "binaryMode": "separate",
    "executionOrder": "v1"
  },
  "versionId": "e0295013-fc5c-4a7c-bddc-2af58338786a",
  "nodeGroups": [],
  "connections": {
    "Configuration": {
      "main": [
        [
          {
            "node": "Generate Video Prompt",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "Is Video Ready?": {
      "main": [
        [
          {
            "node": "Generate Caption",
            "type": "main",
            "index": 0
          }
        ],
        [
          {
            "node": "Wait Before Polling",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "Generate Caption": {
      "main": [
        [
          {
            "node": "Publish Reel to Instagram",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "Get Video Status": {
      "main": [
        [
          {
            "node": "Is Video Ready?",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "Telegram Trigger": {
      "main": [
        [
          {
            "node": "Configuration",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "Wait Before Polling": {
      "main": [
        [
          {
            "node": "Get Video Status",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "Generate Video Prompt": {
      "main": [
        [
          {
            "node": "Generate Video with Seedance",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "OpenAI Model (Prompt)": {
      "ai_languageModel": [
        [
          {
            "node": "Generate Video Prompt",
            "type": "ai_languageModel",
            "index": 0
          }
        ]
      ]
    },
    "OpenAI Model (Caption)": {
      "ai_languageModel": [
        [
          {
            "node": "Generate Caption",
            "type": "ai_languageModel",
            "index": 0
          }
        ]
      ]
    },
    "Publish Reel to Instagram": {
      "main": [
        [
          {
            "node": "Notify on Telegram",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "Generate Video with Seedance": {
      "main": [
        [
          {
            "node": "Wait Before Polling",
            "type": "main",
            "index": 0
          }
        ]
      ]
    }
  }
}