{
  "id": "KGEllGjseD6kDDaS",
  "meta": {
    "templateCredsSetupCompleted": true
  },
  "name": "Video Generation with Telegram Bot and Gemini-Api & Post on TikTok /Instagram &Facebook",
  "tags": [],
  "nodes": [
    {
      "id": "bec6e918-6b77-47a6-b5b1-46fb183731a4",
      "name": "Generate a video",
      "type": "@n8n/n8n-nodes-langchain.googleGemini",
      "position": [
        -800,
        704
      ],
      "parameters": {
        "prompt": "={{ $('Parse AI Output').item.json.videoPrompt }}",
        "modelId": {
          "__rl": true,
          "mode": "list",
          "value": "models/veo-3.0-fast-generate-001",
          "cachedResultName": "models/veo-3.0-fast-generate-001"
        },
        "options": {
          "aspectRatio": "9:16"
        },
        "resource": "video"
      },
      "credentials": {
        "googlePalmApi": {
          "name": "<your credential>"
        }
      },
      "typeVersion": 1,
      "alwaysOutputData": true
    },
    {
      "id": "7ef496db-e09c-4ba0-af5f-a4a1d51fb7b0",
      "name": "AI Agent",
      "type": "@n8n/n8n-nodes-langchain.agent",
      "position": [
        -2048,
        1008
      ],
      "parameters": {
        "text": "={{ $json.text }}",
        "options": {
          "systemMessage": "You are a video prompt assistant for Telegram.\n\nYour task:\n\n1. Analyze the user's message and create a video prompt.\n\n2. Create relevant social media text with hashtags.\n\n3. Present both to the user and ask for feedback.\n\n4. If the user requests changes: Refine based on the feedback and present again.\n\n5. If the user says \"approved\" or \"ok\": Output the final version in JSON format.\n\nJSON format (only for approval):\n\n{\n\n\"videoPrompt\": \"The final video prompt\",\n\n\"socialMediaText\": \"The social media text with hashtags\"\n\n}\n\nImportant: Only output the JSON if the user says \"approved\". Otherwise, provide a regular text response with a suggestion."
        },
        "promptType": "define"
      },
      "typeVersion": 3
    },
    {
      "id": "47b64870-c6a8-4b41-8736-7fee64689367",
      "name": "OpenAI Chat Model",
      "type": "@n8n/n8n-nodes-langchain.lmChatOpenAi",
      "position": [
        -2048,
        1232
      ],
      "parameters": {
        "model": {
          "__rl": true,
          "mode": "list",
          "value": "gpt-4.1-mini"
        },
        "options": {}
      },
      "credentials": {
        "openAiApi": {
          "name": "<your credential>"
        }
      },
      "typeVersion": 1.2
    },
    {
      "id": "1dc31331-39bc-4313-972c-b74154892bee",
      "name": "Listen for incoming events",
      "type": "n8n-nodes-base.telegramTrigger",
      "position": [
        -3168,
        1008
      ],
      "parameters": {
        "updates": [
          "message"
        ],
        "additionalFields": {}
      },
      "credentials": {
        "telegramApi": {
          "name": "<your credential>"
        }
      },
      "typeVersion": 1
    },
    {
      "id": "daeaf123-5b7a-4f9a-9fc9-fa3d8a7f786c",
      "name": "Speech to Text",
      "type": "@n8n/n8n-nodes-langchain.openAi",
      "position": [
        -2272,
        944
      ],
      "parameters": {
        "options": {},
        "resource": "audio",
        "operation": "transcribe"
      },
      "credentials": {
        "openAiApi": {
          "name": "<your credential>"
        }
      },
      "typeVersion": 1.3
    },
    {
      "id": "6ef24d69-fcac-451a-bc53-d83070e9df46",
      "name": "Voice or Text",
      "type": "n8n-nodes-base.set",
      "position": [
        -2944,
        1008
      ],
      "parameters": {
        "fields": {
          "values": [
            {
              "name": "text",
              "stringValue": "={{ $json?.message?.text || \"\" }}"
            }
          ]
        },
        "options": {}
      },
      "typeVersion": 3.2
    },
    {
      "id": "be290fa3-0ac8-42c1-ae67-64005bfda1f7",
      "name": "Get Voice File",
      "type": "n8n-nodes-base.telegram",
      "position": [
        -2496,
        944
      ],
      "parameters": {
        "fileId": "={{ $('Listen for incoming events').item.json.message.voice.file_id }}",
        "resource": "file",
        "additionalFields": {}
      },
      "credentials": {
        "telegramApi": {
          "name": "<your credential>"
        }
      },
      "typeVersion": 1.1
    },
    {
      "id": "e803e148-f8f8-48e5-9bb7-d36822424ca9",
      "name": "Parse AI Output",
      "type": "n8n-nodes-base.code",
      "position": [
        -1472,
        704
      ],
      "parameters": {
        "jsCode": "// Get the output from AI Agent\nconst aiOutput = $input.item.json.output;\n\nif (!aiOutput) {\n  throw new Error('No output found from AI Agent');\n}\n\n// Try to extract JSON from the text\n// The JSON might be wrapped in markdown code blocks or mixed with other text\nlet jsonString = aiOutput;\n\n// Remove markdown code blocks if present\njsonString = jsonString.replace(/```json\\s*/g, '').replace(/```\\s*/g, '');\n\n// Try to find JSON object in the text\nconst jsonMatch = jsonString.match(/\\{[\\s\\S]*\\}/);\nif (jsonMatch) {\n  jsonString = jsonMatch[0];\n}\n\ntry {\n  // Parse the JSON\n  const parsed = JSON.parse(jsonString);\n  \n  // Validate that we have the required fields\n  if (!parsed.videoPrompt || !parsed.socialMediaText) {\n    throw new Error('Missing required fields: videoPrompt or socialMediaText');\n  }\n  \n  // Return the parsed data\n  return {\n    videoPrompt: parsed.videoPrompt,\n    socialMediaText: parsed.socialMediaText\n  };\n  \n} catch (error) {\n  // If parsing fails, try to extract the fields manually\n  const videoPromptMatch = aiOutput.match(/videoPrompt[\"']?\\s*:\\s*[\"']([^\"']+)[\"']/i);\n  const socialMediaTextMatch = aiOutput.match(/socialMediaText[\"']?\\s*:\\s*[\"']([^\"']+)[\"']/i);\n  \n  if (videoPromptMatch && socialMediaTextMatch) {\n    return {\n      videoPrompt: videoPromptMatch[1],\n      socialMediaText: socialMediaTextMatch[1]\n    };\n  }\n  \n  throw new Error(`Failed to parse AI output: ${error.message}. Output was: ${aiOutput}`);\n}"
      },
      "typeVersion": 2
    },
    {
      "id": "ed6b8aa1-f57b-4f8a-a151-9261cb61513b",
      "name": "Window Buffer Memory",
      "type": "@n8n/n8n-nodes-langchain.memoryBufferWindow",
      "position": [
        -1920,
        1232
      ],
      "parameters": {
        "sessionKey": "={{ $('Listen for incoming events').first().json.message.from.id }}",
        "sessionIdType": "customKey",
        "contextWindowLength": 10
      },
      "typeVersion": 1.3
    },
    {
      "id": "fe680f56-e107-4a47-ad9a-62ac54798f2f",
      "name": "Download Video from Drive1",
      "type": "n8n-nodes-base.googleDrive",
      "position": [
        -352,
        704
      ],
      "parameters": {
        "fileId": {
          "__rl": true,
          "mode": "id",
          "value": "={{ $('Upload video').item.json.id }}"
        },
        "options": {
          "googleFileConversion": {}
        },
        "operation": "download"
      },
      "credentials": {
        "googleDriveOAuth2Api": {
          "name": "<your credential>"
        }
      },
      "typeVersion": 3
    },
    {
      "id": "468dcc51-bb2c-437c-aa57-1d5440de528c",
      "name": "Upload media1",
      "type": "@blotato/n8n-nodes-blotato.blotato",
      "position": [
        -128,
        704
      ],
      "parameters": {
        "resource": "media",
        "useBinaryData": true
      },
      "credentials": {
        "blotatoApi": {
          "name": "<your credential>"
        }
      },
      "typeVersion": 2
    },
    {
      "id": "ec315c08-e342-477b-a1fa-3a3c2da4aba0",
      "name": "Create post1",
      "type": "@blotato/n8n-nodes-blotato.blotato",
      "position": [
        96,
        608
      ],
      "parameters": {
        "options": {},
        "accountId": {
          "__rl": true,
          "mode": "list",
          "value": "20724",
          "cachedResultUrl": "https://backend./v2/accounts/20724",
          "cachedResultName": "aimaginate_xx"
        },
        "postContentText": "={{ $('Parse AI Output').item.json.socialMediaText }}",
        "postContentMediaUrls": "={{ $json.url }}"
      },
      "credentials": {
        "blotatoApi": {
          "name": "<your credential>"
        }
      },
      "typeVersion": 2,
      "alwaysOutputData": false
    },
    {
      "id": "bb0cc3cc-923a-46ea-85cc-5ccf8b94a1f5",
      "name": "Get post1",
      "type": "@blotato/n8n-nodes-blotato.blotato",
      "position": [
        544,
        608
      ],
      "parameters": {
        "operation": "get",
        "postSubmissionId": "={{ $json.postSubmissionId }}"
      },
      "credentials": {
        "blotatoApi": {
          "name": "<your credential>"
        }
      },
      "typeVersion": 2
    },
    {
      "id": "c26ec671-ef40-4b46-9ccd-f5068d22583c",
      "name": "Wait",
      "type": "n8n-nodes-base.wait",
      "position": [
        320,
        128
      ],
      "parameters": {
        "amount": 30
      },
      "typeVersion": 1.1
    },
    {
      "id": "28d02717-5402-489e-8c69-0e72b5b90edc",
      "name": "Wait1",
      "type": "n8n-nodes-base.wait",
      "position": [
        320,
        608
      ],
      "parameters": {
        "amount": 30
      },
      "typeVersion": 1.1
    },
    {
      "id": "187c9016-d591-4d41-af72-0424b7b53944",
      "name": "In Progress?",
      "type": "n8n-nodes-base.if",
      "position": [
        992,
        144
      ],
      "parameters": {
        "options": {},
        "conditions": {
          "options": {
            "version": 2,
            "leftValue": "",
            "caseSensitive": true,
            "typeValidation": "strict"
          },
          "combinator": "and",
          "conditions": [
            {
              "id": "e6c403be-3a03-4365-ac18-69d9ffc1770b",
              "operator": {
                "name": "filter.operator.equals",
                "type": "string",
                "operation": "equals"
              },
              "leftValue": "={{ $('Check post status').item.json.status }}",
              "rightValue": "in-progress"
            }
          ]
        }
      },
      "typeVersion": 2.2
    },
    {
      "id": "dacf346f-86ac-4901-8a53-d5a6a4a460d6",
      "name": "Give Blotat other 5s :)",
      "type": "n8n-nodes-base.wait",
      "position": [
        1216,
        320
      ],
      "parameters": {},
      "typeVersion": 1.1
    },
    {
      "id": "82c1fd7d-1183-494a-b93d-1cec1ebcc884",
      "name": "In Progress?1",
      "type": "n8n-nodes-base.if",
      "position": [
        992,
        704
      ],
      "parameters": {
        "options": {},
        "conditions": {
          "options": {
            "version": 2,
            "leftValue": "",
            "caseSensitive": true,
            "typeValidation": "strict"
          },
          "combinator": "and",
          "conditions": [
            {
              "id": "e6c403be-3a03-4365-ac18-69d9ffc1770b",
              "operator": {
                "name": "filter.operator.equals",
                "type": "string",
                "operation": "equals"
              },
              "leftValue": "={{ $json.status }}",
              "rightValue": "in-progress"
            }
          ]
        }
      },
      "typeVersion": 2.2
    },
    {
      "id": "f625b376-9214-4c61-8a6f-856e8b1a0638",
      "name": "Wait2",
      "type": "n8n-nodes-base.wait",
      "position": [
        336,
        1376
      ],
      "parameters": {
        "amount": 30
      },
      "typeVersion": 1.1
    },
    {
      "id": "2044efed-81fd-4dc4-8019-e6bc89f86b91",
      "name": "In Progress?2",
      "type": "n8n-nodes-base.if",
      "position": [
        1008,
        1472
      ],
      "parameters": {
        "options": {},
        "conditions": {
          "options": {
            "version": 2,
            "leftValue": "",
            "caseSensitive": true,
            "typeValidation": "strict"
          },
          "combinator": "and",
          "conditions": [
            {
              "id": "e6c403be-3a03-4365-ac18-69d9ffc1770b",
              "operator": {
                "name": "filter.operator.equals",
                "type": "string",
                "operation": "equals"
              },
              "leftValue": "={{ $('Check post status').item.json.status }}",
              "rightValue": "in-progress"
            }
          ]
        }
      },
      "typeVersion": 2.2
    },
    {
      "id": "eabdf280-22e9-4480-b90f-2c36e52dc7cb",
      "name": "Give Blotat other 5s :)2",
      "type": "n8n-nodes-base.wait",
      "position": [
        1232,
        1648
      ],
      "parameters": {},
      "typeVersion": 1.1
    },
    {
      "id": "ebecb8e8-de8f-4bc5-9356-407e365ddfbf",
      "name": "A Voice?",
      "type": "n8n-nodes-base.if",
      "position": [
        -2720,
        1008
      ],
      "parameters": {
        "options": {},
        "conditions": {
          "options": {
            "version": 2,
            "leftValue": "",
            "caseSensitive": true,
            "typeValidation": "strict"
          },
          "combinator": "and",
          "conditions": [
            {
              "id": "a0bf9719-4272-46f6-ab3b-eda6f7b44fd8",
              "operator": {
                "type": "string",
                "operation": "empty",
                "singleValue": true
              },
              "leftValue": "={{ $json.message.text }}",
              "rightValue": ""
            }
          ]
        }
      },
      "typeVersion": 2.2
    },
    {
      "id": "00718455-b243-474d-9b8b-fa77364d4735",
      "name": "Send questions or proposal to user",
      "type": "n8n-nodes-base.telegram",
      "position": [
        -1472,
        1104
      ],
      "parameters": {
        "text": "={{ $('AI Agent').item.json.output }}",
        "chatId": "={{ $('Listen for incoming events').first().json.message.chat.id }}",
        "additionalFields": {}
      },
      "credentials": {
        "telegramApi": {
          "name": "<your credential>"
        }
      },
      "typeVersion": 1.2
    },
    {
      "id": "ae62698f-d8aa-4f38-8678-0a9224561de6",
      "name": "Approved from user?",
      "type": "n8n-nodes-base.if",
      "position": [
        -1696,
        1008
      ],
      "parameters": {
        "options": {},
        "conditions": {
          "options": {
            "version": 2,
            "leftValue": "",
            "caseSensitive": true,
            "typeValidation": "strict"
          },
          "combinator": "or",
          "conditions": [
            {
              "id": "id-1",
              "operator": {
                "type": "string",
                "operation": "contains"
              },
              "leftValue": "={{ $json.output }}",
              "rightValue": "videoPrompt"
            },
            {
              "id": "id-2",
              "operator": {
                "type": "string",
                "operation": "contains"
              },
              "leftValue": "={{ $json.output }}",
              "rightValue": "socialMediaText"
            },
            {
              "id": "id-3",
              "operator": {
                "type": "string",
                "operation": "startsWith"
              },
              "leftValue": "={{ $json.output }}",
              "rightValue": "{"
            }
          ]
        }
      },
      "typeVersion": 2.2
    },
    {
      "id": "773cbeb3-011f-48db-bb31-7f995d98f902",
      "name": "Inform user about processing",
      "type": "n8n-nodes-base.telegram",
      "position": [
        -1248,
        704
      ],
      "parameters": {
        "text": "Okay. Your video is being prepared now. I'll let you know as soon as it's online.",
        "chatId": "={{ $('Listen for incoming events').item.json.message.chat.id }}",
        "additionalFields": {}
      },
      "credentials": {
        "telegramApi": {
          "name": "<your credential>"
        }
      },
      "typeVersion": 1.2
    },
    {
      "id": "f5c48332-fa51-4bea-81f3-e994c9fc52e2",
      "name": "Save Prompt & Post-Text",
      "type": "n8n-nodes-base.googleSheets",
      "position": [
        -1024,
        704
      ],
      "parameters": {
        "columns": {
          "value": {
            "text": "={{ $('Parse AI Output').item.json.socialMediaText }}",
            "prompt": "={{ $('Parse AI Output').item.json.videoPrompt }}"
          },
          "schema": [
            {
              "id": "prompt",
              "type": "string",
              "display": true,
              "removed": false,
              "required": false,
              "displayName": "prompt",
              "defaultMatch": false,
              "canBeUsedToMatch": true
            },
            {
              "id": "text",
              "type": "string",
              "display": true,
              "removed": false,
              "required": false,
              "displayName": "text",
              "defaultMatch": false,
              "canBeUsedToMatch": true
            }
          ],
          "mappingMode": "defineBelow",
          "matchingColumns": [],
          "attemptToConvertTypes": false,
          "convertFieldsToString": false
        },
        "options": {},
        "operation": "append",
        "sheetName": {
          "__rl": true,
          "mode": "list",
          "value": "gid=0",
          "cachedResultUrl": "https://docs.google.com/spreadsheets/d/1Ex39e1qxhx17NizISKRxrjlGH8VpBbcZ5G_Lis8Xqjw/edit#gid=0",
          "cachedResultName": "Tabellenblatt1"
        },
        "documentId": {
          "__rl": true,
          "mode": "list",
          "value": "1Ex39e1qxhx17NizISKRxrjlGH8VpBbcZ5G_Lis8Xqjw",
          "cachedResultUrl": "https://docs.google.com/spreadsheets/d/1Ex39e1qxhx17NizISKRxrjlGH8VpBbcZ5G_Lis8Xqjw/edit?usp=drivesdk",
          "cachedResultName": "prompts"
        }
      },
      "credentials": {
        "googleSheetsOAuth2Api": {
          "name": "<your credential>"
        }
      },
      "typeVersion": 4.7
    },
    {
      "id": "626f7e89-b91c-4c34-b8e9-d7beb1017498",
      "name": "Upload video",
      "type": "n8n-nodes-base.googleDrive",
      "position": [
        -576,
        704
      ],
      "parameters": {
        "name": "={{$binary.generated_video.fileName || 'video.mp4'}}",
        "driveId": {
          "__rl": true,
          "mode": "list",
          "value": "My Drive"
        },
        "options": {},
        "folderId": {
          "__rl": true,
          "mode": "list",
          "value": "1b96QoVMsH60yfd7RKSJgWkAY6L5tnz_T",
          "cachedResultUrl": "https://drive.google.com/drive/folders/1b96QoVMsH60yfd7RKSJgWkAY6L5tnz_T",
          "cachedResultName": "n8n_videos"
        }
      },
      "credentials": {
        "googleDriveOAuth2Api": {
          "name": "<your credential>"
        }
      },
      "typeVersion": 3
    },
    {
      "id": "d7d34c7c-7be0-4cfd-9927-f9692d80b086",
      "name": "Create TikTok post",
      "type": "@blotato/n8n-nodes-blotato.blotato",
      "position": [
        96,
        128
      ],
      "parameters": {
        "options": {},
        "platform": "tiktok",
        "accountId": {
          "__rl": true,
          "mode": "list",
          "value": "20943",
          "cachedResultUrl": "https://backend./v2/accounts/20943",
          "cachedResultName": "aimaginite"
        },
        "postContentText": "={{ $('Parse AI Output').item.json.socialMediaText }}",
        "postContentMediaUrls": "={{ $json.url }}",
        "postCreateTiktokOptionIsAiGenerated": true
      },
      "credentials": {
        "blotatoApi": {
          "name": "<your credential>"
        }
      },
      "typeVersion": 2,
      "alwaysOutputData": false
    },
    {
      "id": "f96e9f98-1f46-4fe3-ad56-0e3df455b2d3",
      "name": "Check Post Status",
      "type": "@blotato/n8n-nodes-blotato.blotato",
      "position": [
        544,
        128
      ],
      "parameters": {
        "operation": "get",
        "postSubmissionId": "={{ $json.postSubmissionId }}"
      },
      "credentials": {
        "blotatoApi": {
          "name": "<your credential>"
        }
      },
      "typeVersion": 2
    },
    {
      "id": "08f8bff3-3649-4cd5-95e6-bf4cdd5c5a8b",
      "name": "Give Blotat more time",
      "type": "n8n-nodes-base.wait",
      "position": [
        1216,
        864
      ],
      "parameters": {},
      "typeVersion": 1.1
    },
    {
      "id": "95f86964-2fcc-453c-b9ac-0292be85e016",
      "name": "Published to TikTok?",
      "type": "n8n-nodes-base.if",
      "position": [
        768,
        128
      ],
      "parameters": {
        "options": {},
        "conditions": {
          "options": {
            "version": 2,
            "leftValue": "",
            "caseSensitive": true,
            "typeValidation": "strict"
          },
          "combinator": "and",
          "conditions": [
            {
              "id": "1bc619f0-b64a-4487-bbc7-21be7c30f1f1",
              "operator": {
                "name": "filter.operator.equals",
                "type": "string",
                "operation": "equals"
              },
              "leftValue": "={{ $json.status }}",
              "rightValue": "published"
            }
          ]
        }
      },
      "typeVersion": 2.2
    },
    {
      "id": "ad0c5f65-e26e-41aa-b69d-3f51d318091b",
      "name": "Published to Instagram?",
      "type": "n8n-nodes-base.if",
      "position": [
        768,
        608
      ],
      "parameters": {
        "options": {},
        "conditions": {
          "options": {
            "version": 2,
            "leftValue": "",
            "caseSensitive": true,
            "typeValidation": "strict"
          },
          "combinator": "and",
          "conditions": [
            {
              "id": "1bc619f0-b64a-4487-bbc7-21be7c30f1f1",
              "operator": {
                "name": "filter.operator.equals",
                "type": "string",
                "operation": "equals"
              },
              "leftValue": "={{ $json.status }}",
              "rightValue": "=published"
            }
          ]
        }
      },
      "typeVersion": 2.2
    },
    {
      "id": "10af80e4-c0cf-4d06-b388-41608a128af0",
      "name": "Confirm publishing to Instagram",
      "type": "n8n-nodes-base.telegram",
      "position": [
        992,
        512
      ],
      "parameters": {
        "text": "=Dein Video ist jetzt online auf Instagram.\nHier geht es zum Post:\n{{ $json.publicUrl }}",
        "chatId": "={{ $('Listen for incoming events').item.json.message.chat.id }}",
        "additionalFields": {}
      },
      "credentials": {
        "telegramApi": {
          "name": "<your credential>"
        }
      },
      "typeVersion": 1.2
    },
    {
      "id": "c61552a3-2ce5-4226-990f-c07add75d53e",
      "name": "Confirm publishing to Tiktok",
      "type": "n8n-nodes-base.telegram",
      "position": [
        992,
        -48
      ],
      "parameters": {
        "text": "=Your video is now online on TikTok.\n\nHere's the link to the post:\n{{ $json.publicUrl }}",
        "chatId": "={{ $('Listen for incoming events').item.json.message.chat.id }}",
        "additionalFields": {}
      },
      "credentials": {
        "telegramApi": {
          "name": "<your credential>"
        }
      },
      "typeVersion": 1.2
    },
    {
      "id": "bfc99f97-47fe-4483-a374-6116a7d01039",
      "name": "Send TikTok Error Message",
      "type": "n8n-nodes-base.telegram",
      "position": [
        1216,
        96
      ],
      "parameters": {
        "text": "Error while uploading your video to Tiktok",
        "chatId": "={{ $('Listen for incoming events').item.json.message.chat.id }}",
        "additionalFields": {}
      },
      "credentials": {
        "telegramApi": {
          "name": "<your credential>"
        }
      },
      "typeVersion": 1.2
    },
    {
      "id": "f0080a36-4966-4b84-b003-eb0eb813a150",
      "name": "Send Instagram Error Message",
      "type": "n8n-nodes-base.telegram",
      "position": [
        1216,
        624
      ],
      "parameters": {
        "text": "Error while uploading your video to Instagram",
        "chatId": "={{ $('Listen for incoming events').item.json.message.chat.id }}",
        "additionalFields": {}
      },
      "credentials": {
        "telegramApi": {
          "name": "<your credential>"
        }
      },
      "typeVersion": 1.2
    },
    {
      "id": "23c53f26-106a-48a7-8ab4-9e8d137d38bd",
      "name": "Send Facebook Error Message",
      "type": "n8n-nodes-base.telegram",
      "position": [
        1232,
        1408
      ],
      "parameters": {
        "text": "Error while uploading your video to Instagram",
        "chatId": "={{ $('Listen for incoming events').item.json.message.chat.id }}",
        "additionalFields": {}
      },
      "credentials": {
        "telegramApi": {
          "name": "<your credential>"
        }
      },
      "typeVersion": 1.2
    },
    {
      "id": "2af5578b-046e-476a-b3a1-4a957027b827",
      "name": "Published to Facebook?",
      "type": "n8n-nodes-base.if",
      "position": [
        784,
        1376
      ],
      "parameters": {
        "options": {},
        "conditions": {
          "options": {
            "version": 2,
            "leftValue": "",
            "caseSensitive": true,
            "typeValidation": "strict"
          },
          "combinator": "and",
          "conditions": [
            {
              "id": "1bc619f0-b64a-4487-bbc7-21be7c30f1f1",
              "operator": {
                "name": "filter.operator.equals",
                "type": "string",
                "operation": "equals"
              },
              "leftValue": "={{ $json.status }}",
              "rightValue": "published"
            }
          ]
        }
      },
      "typeVersion": 2.2
    },
    {
      "id": "e38c5639-d8aa-424b-bbf9-7df4a2fe30e0",
      "name": "Create Facebook post",
      "type": "@blotato/n8n-nodes-blotato.blotato",
      "position": [
        112,
        1376
      ],
      "parameters": {
        "options": {},
        "platform": "facebook",
        "accountId": {
          "__rl": true,
          "mode": "list",
          "value": "13555",
          "cachedResultUrl": "https://backend./v2/accounts/13555",
          "cachedResultName": "Feras Dabour"
        },
        "facebookPageId": {
          "__rl": true,
          "mode": "list",
          "value": "892271760628464",
          "cachedResultUrl": "https://backend./v2/accounts/13555/subaccounts/892271760628464",
          "cachedResultName": "AImaginate"
        },
        "postContentText": "={{ $('Parse AI Output').item.json.socialMediaText }}",
        "postContentMediaUrls": "={{ $json.url }}"
      },
      "credentials": {
        "blotatoApi": {
          "name": "<your credential>"
        }
      },
      "typeVersion": 2,
      "alwaysOutputData": false
    },
    {
      "id": "248dfa8f-9acf-4876-8575-d4555bcb505e",
      "name": "Get Facebook post",
      "type": "@blotato/n8n-nodes-blotato.blotato",
      "position": [
        560,
        1376
      ],
      "parameters": {
        "operation": "get",
        "postSubmissionId": "={{ $json.postSubmissionId }}"
      },
      "credentials": {
        "blotatoApi": {
          "name": "<your credential>"
        }
      },
      "typeVersion": 2
    },
    {
      "id": "fab70339-ee41-402d-815e-7523caf86489",
      "name": "Confirm publishing to Facebook",
      "type": "n8n-nodes-base.telegram",
      "position": [
        1008,
        1280
      ],
      "parameters": {
        "text": "=Dein Video ist jetzt online auf Facebook.\nHier geht es zum Post:\n{{ $json.publicUrl }}",
        "chatId": "={{ $('Listen for incoming events').item.json.message.chat.id }}",
        "additionalFields": {}
      },
      "credentials": {
        "telegramApi": {
          "name": "<your credential>"
        }
      },
      "typeVersion": 1.2
    },
    {
      "id": "465e8982-d3cf-45b8-928e-8e1725f1eb44",
      "name": "Sticky Note",
      "type": "n8n-nodes-base.stickyNote",
      "position": [
        -4080,
        784
      ],
      "parameters": {
        "width": 736,
        "height": 896,
        "content": "## \ud83e\udd16 AI LinkedIn Content Bot with Approval Loop\n\nTransform your Telegram into a **LinkedIn Content Assistant**. Send ideas via text or voice, collaborate with AI to refine posts, and publish directly to LinkedIn with a simple \"ok\".\n\n---\n\n### How the Workflow Works\n\nThe bot automates the entire process from idea to publication:\n\n* **1. Send your idea:** Message your Telegram bot with text or voice notes.\n* **2. AI drafts content:** **GPT** analyzes your input and creates a LinkedIn-optimized post, including hashtags.\n* **3. Iterative refinement:** Request changes (e.g., tone, length, style) until you are satisfied with the draft.\n* **4. Approve & publish:** Simply say \"ok\" or \"approved\" to trigger the automatic LinkedIn posting via **Blotato**.\n* **5. Get confirmation:** Receive a direct link via Telegram once your post is live.\n\n---\n\n### \ud83d\udee0\ufe0f Setup Steps\n\nThe following credentials and configurations are required for the bot to function correctly:\n\n1.  **Telegram Bot:**\n    * Create a bot via `@BotFather`.\n    * Add the API token to your credentials.\n2.  **OpenAI API:**\n    * Add your **OpenAI key** for AI generation and voice transcription.\n3.  **Blotato Account:**\n    * Connect your LinkedIn profile at [Blotato](https:///).\n    * Add the corresponding API credentials.\n4.  **Customize the AI:**\n    * Edit the **System Prompt** in the \"AI: Draft & Revise Post\" node to match your brand voice and content style.\n\n---\n\n"
      },
      "typeVersion": 1
    },
    {
      "id": "cdd6c6e9-5f28-4643-a6ee-dcc4958e0645",
      "name": "Sticky Note1",
      "type": "n8n-nodes-base.stickyNote",
      "position": [
        -3216,
        592
      ],
      "parameters": {
        "color": 7,
        "width": 1088,
        "height": 800,
        "content": "## 1. Capture Input\n\nReceives Telegram messages and converts voice notes to text using OpenAI Whisper"
      },
      "typeVersion": 1
    },
    {
      "id": "627e3ce9-db47-454f-a25f-f7a154ced94a",
      "name": "Sticky Note2",
      "type": "n8n-nodes-base.stickyNote",
      "position": [
        -2112,
        592
      ],
      "parameters": {
        "color": 7,
        "width": 368,
        "height": 800,
        "content": "## 2. AI Content Creation\n\nGenerates LinkedIn posts and handles revision requests through conversational memory"
      },
      "typeVersion": 1
    },
    {
      "id": "2ec13747-c9ac-4d2c-bc19-48a092560a03",
      "name": "Sticky Note3",
      "type": "n8n-nodes-base.stickyNote",
      "position": [
        -864,
        592
      ],
      "parameters": {
        "color": 7,
        "width": 848,
        "height": 800,
        "content": "## 4. Video Generation and upload to [Blotato](https:///) \n\nGenerate your video mit Gemini-API, save it to your google drive and uploadd it to [Blotato](https:///) "
      },
      "typeVersion": 1
    },
    {
      "id": "7d994451-d7f9-4b7d-b6cd-15f7bb552cdd",
      "name": "Sticky Note7",
      "type": "n8n-nodes-base.stickyNote",
      "position": [
        32,
        -80
      ],
      "parameters": {
        "color": 7,
        "width": 1536,
        "height": 592,
        "content": "## 5. Post the video on TikTok and monitor the status"
      },
      "typeVersion": 1
    },
    {
      "id": "f62fe30d-0a88-46e2-824e-219cad81cf2f",
      "name": "Sticky Note8",
      "type": "n8n-nodes-base.stickyNote",
      "position": [
        -1728,
        592
      ],
      "parameters": {
        "color": 7,
        "width": 848,
        "height": 800,
        "content": "## 3. Approval & Publishing\n\nDetects approval keywords, extracts final content, save the output in your google sheet and inform the user"
      },
      "typeVersion": 1
    },
    {
      "id": "1f4a6e8b-2a5a-464a-8182-fc8e8f8532e1",
      "name": "Sticky Note9",
      "type": "n8n-nodes-base.stickyNote",
      "position": [
        32,
        528
      ],
      "parameters": {
        "color": 7,
        "width": 1536,
        "height": 592,
        "content": "## 6. Post the video on Instagram and monitor the status"
      },
      "typeVersion": 1
    },
    {
      "id": "d2d9f40d-0504-41c1-a85d-0001e0c1ef87",
      "name": "Sticky Note10",
      "type": "n8n-nodes-base.stickyNote",
      "position": [
        16,
        1248
      ],
      "parameters": {
        "color": 7,
        "width": 1536,
        "height": 592,
        "content": "## 7. Post the video on Facebook and monitor the status"
      },
      "typeVersion": 1
    }
  ],
  "active": false,
  "settings": {
    "executionOrder": "v1"
  },
  "versionId": "29f8a26e-7154-4a60-b0c1-b02d685a77d1",
  "connections": {
    "Wait": {
      "main": [
        [
          {
            "node": "Check Post Status",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "Wait1": {
      "main": [
        [
          {
            "node": "Get post1",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "Wait2": {
      "main": [
        [
          {
            "node": "Get Facebook post",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "A Voice?": {
      "main": [
        [
          {
            "node": "Get Voice File",
            "type": "main",
            "index": 0
          }
        ],
        [
          {
            "node": "AI Agent",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "AI Agent": {
      "main": [
        [
          {
            "node": "Approved from user?",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "Get post1": {
      "main": [
        [
          {
            "node": "Published to Instagram?",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "Create post1": {
      "main": [
        [
          {
            "node": "Wait1",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "In Progress?": {
      "main": [
        [
          {
            "node": "Give Blotat other 5s :)",
            "type": "main",
            "index": 0
          }
        ],
        [
          {
            "node": "Send TikTok Error Message",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "Upload video": {
      "main": [
        [
          {
            "node": "Download Video from Drive1",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "In Progress?1": {
      "main": [
        [
          {
            "node": "Give Blotat more time",
            "type": "main",
            "index": 0
          }
        ],
        [
          {
            "node": "Send Instagram Error Message",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "In Progress?2": {
      "main": [
        [
          {
            "node": "Give Blotat other 5s :)2",
            "type": "main",
            "index": 0
          }
        ],
        [
          {
            "node": "Send Facebook Error Message",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "Upload media1": {
      "main": [
        [
          {
            "node": "Create post1",
            "type": "main",
            "index": 0
          },
          {
            "node": "Create TikTok post",
            "type": "main",
            "index": 0
          },
          {
            "node": "Create Facebook post",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "Voice or Text": {
      "main": [
        [
          {
            "node": "A Voice?",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "Get Voice File": {
      "main": [
        [
          {
            "node": "Speech to Text",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "Speech to Text": {
      "main": [
        [
          {
            "node": "AI Agent",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "Parse AI Output": {
      "main": [
        [
          {
            "node": "Inform user about processing",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "Generate a video": {
      "main": [
        [
          {
            "node": "Upload video",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "Check Post Status": {
      "main": [
        [
          {
            "node": "Published to TikTok?",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "Get Facebook post": {
      "main": [
        [
          {
            "node": "Published to Facebook?",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "OpenAI Chat Model": {
      "ai_languageModel": [
        [
          {
            "node": "AI Agent",
            "type": "ai_languageModel",
            "index": 0
          }
        ]
      ]
    },
    "Create TikTok post": {
      "main": [
        [
          {
            "node": "Wait",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "Approved from user?": {
      "main": [
        [
          {
            "node": "Parse AI Output",
            "type": "main",
            "index": 0
          }
        ],
        [
          {
            "node": "Send questions or proposal to user",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "Create Facebook post": {
      "main": [
        [
          {
            "node": "Wait2",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "Published to TikTok?": {
      "main": [
        [
          {
            "node": "Confirm publishing to Tiktok",
            "type": "main",
            "index": 0
          }
        ],
        [
          {
            "node": "In Progress?",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "Window Buffer Memory": {
      "ai_memory": [
        [
          {
            "node": "AI Agent",
            "type": "ai_memory",
            "index": 0
          }
        ]
      ]
    },
    "Give Blotat more time": {
      "main": [
        [
          {
            "node": "Published to Instagram?",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "Published to Facebook?": {
      "main": [
        [
          {
            "node": "Confirm publishing to Facebook",
            "type": "main",
            "index": 0
          }
        ],
        [
          {
            "node": "In Progress?2",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "Give Blotat other 5s :)": {
      "main": [
        [
          {
            "node": "Published to TikTok?",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "Published to Instagram?": {
      "main": [
        [
          {
            "node": "Confirm publishing to Instagram",
            "type": "main",
            "index": 0
          }
        ],
        [
          {
            "node": "In Progress?1",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "Save Prompt & Post-Text": {
      "main": [
        [
          {
            "node": "Generate a video",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "Give Blotat other 5s :)2": {
      "main": [
        [
          {
            "node": "Published to Facebook?",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "Download Video from Drive1": {
      "main": [
        [
          {
            "node": "Upload media1",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "Listen for incoming events": {
      "main": [
        [
          {
            "node": "Voice or Text",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "Confirm publishing to Tiktok": {
      "main": [
        []
      ]
    },
    "Inform user about processing": {
      "main": [
        [
          {
            "node": "Save Prompt & Post-Text",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "Send questions or proposal to user": {
      "main": [
        []
      ]
    }
  }
}