{
  "id": "UQTsOfvLOvCjS4MB",
  "meta": {
    "templateCredsSetupCompleted": true
  },
  "name": "Convert viral videos into AI avatar swaps and publish on TikTok with Blotato OK vide",
  "tags": [],
  "nodes": [
    {
      "id": "b3478644-2e4a-4689-9072-bc553dac162f",
      "name": "Telegram Trigger",
      "type": "n8n-nodes-base.telegramTrigger",
      "position": [
        2192,
        528
      ],
      "parameters": {
        "updates": [
          "message"
        ],
        "additionalFields": {}
      },
      "credentials": {
        "telegramApi": {
          "name": "<your credential>"
        }
      },
      "typeVersion": 1.2
    },
    {
      "id": "4877475f-5ed6-4812-a104-cc66f1854348",
      "name": "Telegram Get File (Avatar)",
      "type": "n8n-nodes-base.telegram",
      "position": [
        2400,
        496
      ],
      "parameters": {
        "fileId": "={{ $json.message.photo[$json.message.photo.length - 1].file_id }}",
        "resource": "file",
        "additionalFields": {}
      },
      "credentials": {
        "telegramApi": {
          "name": "<your credential>"
        }
      },
      "typeVersion": 1.2
    },
    {
      "id": "86b820bc-7f8f-48ac-b652-c2aee001a63b",
      "name": "Extract Video URL",
      "type": "n8n-nodes-base.code",
      "position": [
        2416,
        656
      ],
      "parameters": {
        "jsCode": "const caption = $input.first().json.message.caption || '';\nreturn [{ json: { videoUrl: caption.trim() } }];"
      },
      "typeVersion": 2
    },
    {
      "id": "797e5d1c-0519-4602-8f97-8a99b6c90c3b",
      "name": "Transform Video (FAL WAN Replace)",
      "type": "n8n-nodes-base.httpRequest",
      "position": [
        3760,
        432
      ],
      "parameters": {
        "url": "https://queue.fal.run/fal-ai/wan/v2.2-14b/animate/replace",
        "method": "POST",
        "options": {
          "response": {
            "response": {
              "responseFormat": "json"
            }
          }
        },
        "jsonBody": "={\n  \"video_url\": \"{{ $('Extract Video URL').first().json.videoUrl }}\",\n  \"image_url\": \"{{ $('Build Public Image URL').first().json.data.url.replace(/^http:\\/\\/tmpfiles\\.org\\/(\\d+)\\/(.*)$/i, 'https://tmpfiles.org/dl/$1/$2') }}\"\n}",
        "sendBody": true,
        "sendHeaders": true,
        "specifyBody": "json",
        "headerParameters": {
          "parameters": [
            {
              "name": "Content-Type",
              "value": "application/json"
            },
            {
              "name": "Authorization",
              "value": "={{ 'Key ' + $('Workflow Configuration').first().json.falApiKey }}"
            }
          ]
        }
      },
      "typeVersion": 4.2
    },
    {
      "id": "1dce842e-e571-44bf-87eb-aa5721f3b79c",
      "name": "Wait Video (Job Status - WAN)",
      "type": "n8n-nodes-base.wait",
      "position": [
        3984,
        432
      ],
      "parameters": {},
      "typeVersion": 1.1
    },
    {
      "id": "15a13d40-cdfc-42d0-8ec4-b404019fe506",
      "name": "Get Video (Fetch WAN Output)",
      "type": "n8n-nodes-base.httpRequest",
      "position": [
        4208,
        432
      ],
      "parameters": {
        "url": "={{ $json.response_url }}",
        "options": {
          "response": {
            "response": {
              "responseFormat": "json"
            }
          }
        },
        "sendHeaders": true,
        "headerParameters": {
          "parameters": [
            {
              "name": "Authorization",
              "value": "={{ 'Key ' + $('Workflow Configuration').first().json.replicateApiKey }}"
            }
          ]
        }
      },
      "typeVersion": 4.2
    },
    {
      "id": "693b65bb-e368-4db6-b95b-77cc636b8a9f",
      "name": "Transform Audio (FAL Chatterbox)",
      "type": "n8n-nodes-base.httpRequest",
      "position": [
        3760,
        624
      ],
      "parameters": {
        "url": "https://queue.fal.run/fal-ai/chatterbox/speech-to-speech",
        "method": "POST",
        "options": {
          "response": {
            "response": {
              "responseFormat": "json"
            }
          }
        },
        "jsonBody": "={\n  \"source_audio_url\": \"{{ $json.output }}\",\n  \"target_voice_audio_url\": \"{{ $('Workflow Configuration').first().json.targetVoiceAudioUrl }}\"\n}",
        "sendBody": true,
        "sendHeaders": true,
        "specifyBody": "json",
        "headerParameters": {
          "parameters": [
            {
              "name": "Content-Type",
              "value": "application/json"
            },
            {
              "name": "Authorization",
              "value": "={{ 'Key ' + $('Workflow Configuration').first().json.falApiKey }}"
            }
          ]
        }
      },
      "typeVersion": 4.2
    },
    {
      "id": "6c605e20-84ef-4424-8188-958b663253b9",
      "name": "Wait Audio (Job Status - Chatterbox)",
      "type": "n8n-nodes-base.wait",
      "position": [
        3984,
        624
      ],
      "parameters": {},
      "typeVersion": 1.1
    },
    {
      "id": "4767517b-020d-452b-b95f-ad92f06892d2",
      "name": "Get Audio (Fetch Chatterbox Output)",
      "type": "n8n-nodes-base.httpRequest",
      "position": [
        4208,
        624
      ],
      "parameters": {
        "url": "={{ $json.response_url }}",
        "options": {
          "response": {
            "response": {
              "responseFormat": "json"
            }
          }
        },
        "sendHeaders": true,
        "headerParameters": {
          "parameters": [
            {
              "name": "Authorization",
              "value": "={{ 'Key ' + $('Workflow Configuration').first().json.falApiKey }}"
            }
          ]
        }
      },
      "typeVersion": 4.2
    },
    {
      "id": "ec40f3e7-3274-4997-8729-a5d3bbebabaf",
      "name": "Workflow Configuration",
      "type": "n8n-nodes-base.set",
      "position": [
        2640,
        656
      ],
      "parameters": {
        "options": {},
        "assignments": {
          "assignments": [
            {
              "id": "id-1",
              "name": "targetVoiceAudioUrl",
              "type": "string",
              "value": "targetVoiceAudioUrl"
            },
            {
              "id": "fb17cfbf-c623-4152-828c-2ac73d0f5bb9",
              "name": "falApiKey",
              "type": "string",
              "value": "falApiKey"
            },
            {
              "id": "061c7422-d038-4d42-9cbf-a3fbf05b4f05",
              "name": "replicateApiKey",
              "type": "string",
              "value": "replicateApiKey"
            }
          ]
        },
        "includeOtherFields": true
      },
      "typeVersion": 3.4
    },
    {
      "id": "d3be99a7-629c-4265-81b1-0e79797d18f3",
      "name": "Combine (FAL FFmpeg Merge)",
      "type": "n8n-nodes-base.httpRequest",
      "position": [
        4688,
        528
      ],
      "parameters": {
        "url": "https://queue.fal.run/fal-ai/ffmpeg-api/merge-audio-video",
        "method": "POST",
        "options": {
          "response": {
            "response": {
              "responseFormat": "json"
            }
          }
        },
        "jsonBody": "={\n  \"video_url\": \"{{ $json.video.url }}\",\n  \"audio_url\": \"{{ $json.audio.url }}\"\n}",
        "sendBody": true,
        "sendHeaders": true,
        "specifyBody": "json",
        "headerParameters": {
          "parameters": [
            {
              "name": "Content-Type",
              "value": "application/json"
            },
            {
              "name": "Authorization",
              "value": "={{ 'Key ' + $('Workflow Configuration').first().json.falApiKey }}"
            }
          ]
        }
      },
      "typeVersion": 4.2
    },
    {
      "id": "d69c25f7-c7e4-4092-9a09-1fa7244f494f",
      "name": "Wait Final (Job Status - FFmpeg)",
      "type": "n8n-nodes-base.wait",
      "position": [
        4912,
        528
      ],
      "parameters": {},
      "typeVersion": 1.1
    },
    {
      "id": "d30d8477-5cff-4f94-838a-56abc566039a",
      "name": "Get Final (Fetch Final Video)",
      "type": "n8n-nodes-base.httpRequest",
      "position": [
        5136,
        528
      ],
      "parameters": {
        "url": "={{ $json.response_url }}",
        "options": {
          "response": {
            "response": {
              "responseFormat": "json"
            }
          }
        },
        "sendHeaders": true,
        "headerParameters": {
          "parameters": [
            {
              "name": "Authorization",
              "value": "={{ 'Key ' + $('Workflow Configuration').first().json.falApiKey }}"
            }
          ]
        }
      },
      "typeVersion": 4.2
    },
    {
      "id": "43089646-51ec-485d-91a9-19f846c7ba73",
      "name": "OUTPUT (Google Sheet Write)",
      "type": "n8n-nodes-base.googleSheets",
      "position": [
        5360,
        528
      ],
      "parameters": {
        "columns": {
          "value": {
            "url output": "={{ $json.video.url }}",
            "url original": "={{ $('Extract Video URL').first().json.videoUrl }}"
          },
          "schema": [
            {
              "id": "url original",
              "type": "string",
              "display": true,
              "required": false,
              "displayName": "url original",
              "defaultMatch": false,
              "canBeUsedToMatch": true
            },
            {
              "id": "url output",
              "type": "string",
              "display": true,
              "required": false,
              "displayName": "url output",
              "defaultMatch": false,
              "canBeUsedToMatch": true
            }
          ],
          "mappingMode": "defineBelow",
          "matchingColumns": [],
          "attemptToConvertTypes": false,
          "convertFieldsToString": false
        },
        "options": {},
        "operation": "append",
        "sheetName": {
          "__rl": true,
          "mode": "id",
          "value": "=gid=0"
        },
        "documentId": {
          "__rl": true,
          "mode": "id",
          "value": "="
        }
      },
      "credentials": {
        "googleSheetsOAuth2Api": {
          "name": "<your credential>"
        }
      },
      "typeVersion": 4.7
    },
    {
      "id": "74e47ce5-3f11-46fc-a648-c031afd2bcfa",
      "name": "Build Public Image URL",
      "type": "n8n-nodes-base.httpRequest",
      "position": [
        2640,
        496
      ],
      "parameters": {
        "url": "https://tmpfiles.org/api/v1/upload",
        "method": "POST",
        "options": {
          "response": {
            "response": {
              "responseFormat": "json"
            }
          }
        },
        "sendBody": true,
        "contentType": "multipart-form-data",
        "bodyParameters": {
          "parameters": [
            {
              "name": "file",
              "parameterType": "formBinaryData",
              "inputDataFieldName": "data"
            }
          ]
        }
      },
      "typeVersion": 4.2
    },
    {
      "id": "a06b53e8-f988-4c0f-aa3b-60f503eeea9b",
      "name": "Merge",
      "type": "n8n-nodes-base.merge",
      "position": [
        2864,
        512
      ],
      "parameters": {
        "mode": "chooseBranch",
        "numberInputs": 3,
        "useDataOfInput": 2
      },
      "typeVersion": 3.2
    },
    {
      "id": "7fe5052e-afdc-4dad-95ac-3736537226d6",
      "name": "Wait",
      "type": "n8n-nodes-base.wait",
      "position": [
        3312,
        528
      ],
      "parameters": {},
      "typeVersion": 1.1
    },
    {
      "id": "12f0795e-080f-44e3-af6b-050e6c06df5a",
      "name": "Download Audio",
      "type": "n8n-nodes-base.httpRequest",
      "position": [
        3536,
        528
      ],
      "parameters": {
        "url": "={{ $json.urls.get }}",
        "options": {
          "response": {
            "response": {
              "responseFormat": "json"
            }
          }
        },
        "sendHeaders": true,
        "headerParameters": {
          "parameters": [
            {
              "name": "Content-Type",
              "value": "application/json"
            },
            {
              "name": "Authorization",
              "value": "={{ 'bearer ' + $('Workflow Configuration').first().json.replicateApiKey }}"
            }
          ]
        }
      },
      "typeVersion": 4.2
    },
    {
      "id": "e67e088e-e388-4d46-868d-6353c70e3620",
      "name": "Separate Audio (Video-to-Audio)",
      "type": "n8n-nodes-base.httpRequest",
      "position": [
        3088,
        528
      ],
      "parameters": {
        "url": "https://api.replicate.com/v1/models/lucataco/extract-audio/predictions",
        "method": "POST",
        "options": {
          "response": {
            "response": {
              "responseFormat": "json"
            }
          }
        },
        "jsonBody": "={\n    \"input\": {\n      \"video\": \"{{ $('Extract Video URL').first().json.videoUrl }}\",\n      \"fade_in\": 0,\n      \"fade_out\": 0,\n      \"trim_end\": 0,\n      \"trim_start\": 0,\n      \"volume_boost\": 1,\n      \"audio_quality\": \"high\",\n      \"output_format\": \"mp3\",\n      \"noise_reduction\": false,\n      \"normalize_audio\": false\n    }\n}\n",
        "sendBody": true,
        "sendHeaders": true,
        "specifyBody": "json",
        "headerParameters": {
          "parameters": [
            {
              "name": "Content-Type",
              "value": "application/json"
            },
            {
              "name": "Authorization",
              "value": "={{ 'bearer ' + $('Workflow Configuration').first().json.replicateApiKey }}"
            }
          ]
        }
      },
      "typeVersion": 4.2
    },
    {
      "id": "2ea399dd-ee49-4feb-8aa7-f4954abe2dc9",
      "name": "Merge urls",
      "type": "n8n-nodes-base.merge",
      "position": [
        4464,
        528
      ],
      "parameters": {
        "mode": "combine",
        "options": {},
        "combineBy": "combineByPosition"
      },
      "typeVersion": 3.2
    },
    {
      "id": "6b44da96-73c3-4f75-8b80-0d94564c2fde",
      "name": "Workflow Overview",
      "type": "n8n-nodes-base.stickyNote",
      "position": [
        1584,
        160
      ],
      "parameters": {
        "width": 512,
        "height": 1144,
        "content": "# Convert viral videos into AI avatar swaps and publish on TikTok with Blotato\n\nThis workflow transforms videos by replacing the character's face with a custom avatar and changing the voice, then outputs the final result to Google Sheets.\n\n### How it works\n1. **Receive input via Telegram**: User sends an avatar image (photo) and video URL (in message caption)\n2. **Extract audio**: Separates the audio track from the original video using Replicate API\n3. **Transform in parallel**: Simultaneously replaces the character in the video (FAL WAN API) and transforms the voice (FAL Chatterbox API)\n4. **Merge results**: Combines the transformed video and audio into a single output file (FAL FFmpeg API)\n5. **Save to Google Sheets**: Writes the original and final video URLs to a spreadsheet for tracking\n\n### Setup\n- [ ] Configure Telegram Bot credentials in the Telegram Trigger node\n- [ ] Set your FAL API key in the Workflow Configuration node (falApiKey field)\n- [ ] Set your Replicate API key in the Workflow Configuration node (replicateApiKey field)\n- [ ] Update the target voice audio URL in Workflow Configuration node (targetVoiceAudioUrl field) - this is the voice the output will sound like\n- [ ] Configure Google Sheets credentials in the OUTPUT (Google Sheet Write) node\n- [ ] Select your target Google Sheet and ensure it has columns: url original and url output\n- [ ] Test the workflow by sending a Telegram message with an avatar photo and video URL in the caption"
      },
      "typeVersion": 1
    },
    {
      "id": "947c38b0-11fe-4045-8380-77a80115bfb5",
      "name": "INPUT: TELEGRAM",
      "type": "n8n-nodes-base.stickyNote",
      "position": [
        2144,
        160
      ],
      "parameters": {
        "color": 7,
        "width": 860,
        "height": 660,
        "content": "## INPUT: TELEGRAM\n\nReceives the avatar image and source video URL from a Telegram message to start the transformation pipeline.\n\n### How it works\n1. **Telegram Trigger** listens for incoming messages with photos\n2. **Extract Video URL** parses the message caption to get the source video URL\n3. **Get Avatar File** downloads the highest resolution photo from the message\n4. **Upload to tmpfiles.org** creates a publicly accessible URL for the avatar image\n5. **Merge inputs** combines all data (video URL, avatar URL, config) before processing"
      },
      "typeVersion": 1
    },
    {
      "id": "fc52f567-0dac-489a-863c-01307f01e6ea",
      "name": "STEP 1: SEPARATE AUDIO & VIDEO",
      "type": "n8n-nodes-base.stickyNote",
      "position": [
        3040,
        160
      ],
      "parameters": {
        "color": 7,
        "width": 620,
        "height": 656,
        "content": "## STEP 1: SEPARATE AUDIO & VIDEO\n\nExtracts the audio track from the source video so it can be transformed independently from the video.\n\n### How it works\n1. **Separate Audio** calls Replicate's extract-audio API with the source video URL\n2. **Wait** pauses for 5 seconds to allow the extraction job to process\n3. **Download Audio** fetches the extracted audio file URL from the completed job\n4. The audio URL is then passed to the voice transformation step\n"
      },
      "typeVersion": 1
    },
    {
      "id": "2ae4895a-25b0-4637-9aa4-259bdc744575",
      "name": "STEP 2: TRANSFORM",
      "type": "n8n-nodes-base.stickyNote",
      "position": [
        3696,
        160
      ],
      "parameters": {
        "color": 7,
        "width": 894,
        "height": 660,
        "content": "## STEP 2: TRANSFORM (PARALLEL)\n\nSimultaneously processes video and audio transformations to optimize workflow speed.\n\n### How it works\n1. **Transform Video** (FAL WAN Replace): Replaces the character's face in the video with the uploaded avatar image\n2. **Transform Audio** (FAL Chatterbox): Converts the extracted audio to match the target voice style\n3. Both transformations run in parallel, each with their own wait/fetch cycle\n4. **Wait & Fetch** nodes poll the APIs every 5 seconds until jobs complete\n5. **Merge URLs** combines the transformed video and audio URLs for the final merge step\n"
      },
      "typeVersion": 1
    },
    {
      "id": "bf29c7be-6718-4716-af3a-163db37fc5e3",
      "name": "STEP 3: COMBINE",
      "type": "n8n-nodes-base.stickyNote",
      "position": [
        4624,
        160
      ],
      "parameters": {
        "color": 5,
        "width": 892,
        "height": 660,
        "content": "## STEP 3: COMBINE & OUTPUT\n\nMerges the transformed video and audio into a single file and saves the result to Google Sheets.\n\n### Setup\n- [ ] Verify FAL API key is set in Workflow Configuration node for FFmpeg API access\n- [ ] Configure Google Sheets OAuth2 credentials in the OUTPUT (Google Sheet Write) node\n- [ ] Select your target spreadsheet and sheet (must have url original and url output columns)\n- [ ] The final video URL will be publicly accessible and can be downloaded or shared\n- [ ] Check Google Sheets after execution to verify the URLs were written correctly\n- [ ] If merge fails, verify both video and audio URLs from Step 2 are valid and accessible"
      },
      "typeVersion": 1
    },
    {
      "id": "b0b6fe9c-70a6-4192-a366-47193f27bc1f",
      "name": "Send Video to Telegram",
      "type": "n8n-nodes-base.telegram",
      "position": [
        3088,
        1040
      ],
      "parameters": {
        "file": "={{ $('Extract Video URL').first().json.videoUrl }}",
        "chatId": "={{ $('Telegram Trigger').first().json.message.chat.id }}",
        "operation": "sendVideo",
        "additionalFields": {
          "caption": "=Your video is ready! \ud83c\udfa5  {{ $('Extract Video URL').first().json.videoUrl }}"
        }
      },
      "credentials": {
        "telegramApi": {
          "name": "<your credential>"
        }
      },
      "typeVersion": 1.2
    },
    {
      "id": "3e969439-ebb1-4fda-aee8-39950091a7d9",
      "name": "Step 5 - Publishing",
      "type": "n8n-nodes-base.stickyNote",
      "position": [
        2144,
        896
      ],
      "parameters": {
        "color": 5,
        "width": 3372,
        "height": 404,
        "content": "# STEP 4: PUBLISHING & TRACKING\n\n### Install the Blotato [Blotato](https://blotato.com/?ref=firas) Node in n8n (Community Nodes)\n1. In n8n, open **Settings \u2192 Community Nodes**.  \n2. Click **Install**, then add: `@blotato/n8n-nodes-blotato`.  \n3. Log in to **Blotato**.  \n4. Go to **Settings \u2192 API Keys**.  \n5. In n8n \u2192 **Credentials \u2192 New**.  \n6. Choose **Blotato API** \n(provided by the community node you installed).  \n\n2. TikTok Publishing (Blotato):\n   \u2022 Pre-configured to auto-publish\n   \u2022 Uses caption from GPT-4\n   \u2022 Privacy: Public\n   \u2022 Requires Blotato API key from Step 2"
      },
      "typeVersion": 1
    },
    {
      "id": "538dc72e-fca1-42bd-a67f-13a4cfea5011",
      "name": "Upload Video to BLOTATO",
      "type": "@blotato/n8n-nodes-blotato.blotato",
      "position": [
        4416,
        1040
      ],
      "parameters": {
        "mediaUrl": "={{ $('OUTPUT (Google Sheet Write)').item.json['url output'] }}",
        "resource": "media"
      },
      "credentials": {
        "blotatoApi": {
          "name": "<your credential>"
        }
      },
      "typeVersion": 2
    },
    {
      "id": "4f37cecd-6542-4882-9e27-7e784bca3465",
      "name": "Youtube",
      "type": "@blotato/n8n-nodes-blotato.blotato",
      "position": [
        5200,
        1104
      ],
      "parameters": {
        "options": {},
        "platform": "youtube",
        "accountId": {
          "__rl": true,
          "mode": "list",
          "value": "8047",
          "cachedResultUrl": "https://backend.blotato.com/v2/accounts/8047",
          "cachedResultName": "DR FIRASS (Dr. Firas)"
        },
        "postContentText": "={{ $('Generate Caption with GPT-4').first().json.message.content.caption }}",
        "postContentMediaUrls": "={{ $json.url }}",
        "postCreateYoutubeOptionTitle": "={{ $('Generate Caption with GPT-4').first().json.message.content.title }}",
        "postCreateYoutubeOptionPrivacyStatus": "private",
        "postCreateYoutubeOptionShouldNotifySubscribers": false
      },
      "credentials": {
        "blotatoApi": {
          "name": "<your credential>"
        }
      },
      "typeVersion": 2
    },
    {
      "id": "cb25dc88-f6ff-4953-9542-ce3dbf33dd99",
      "name": "Tiktok",
      "type": "@blotato/n8n-nodes-blotato.blotato",
      "disabled": true,
      "position": [
        4880,
        944
      ],
      "parameters": {
        "options": {},
        "platform": "tiktok",
        "accountId": {
          "__rl": true,
          "mode": "list",
          "value": "2079",
          "cachedResultUrl": "https://backend.blotato.com/v2/accounts/2079",
          "cachedResultName": "elitecybzcs"
        },
        "postContentText": "={{ $('Generate Caption with GPT-4').first().json.message.content.caption }}",
        "postContentMediaUrls": "={{ $json.url }}"
      },
      "credentials": {
        "blotatoApi": {
          "name": "<your credential>"
        }
      },
      "typeVersion": 2
    },
    {
      "id": "77df349e-01d2-4427-8456-a45544ac09e2",
      "name": "Linkedin",
      "type": "@blotato/n8n-nodes-blotato.blotato",
      "disabled": true,
      "position": [
        5040,
        944
      ],
      "parameters": {
        "options": {},
        "platform": "linkedin",
        "accountId": {
          "__rl": true,
          "mode": "list",
          "value": "1446",
          "cachedResultUrl": "https://backend.blotato.com/v2/accounts/1446",
          "cachedResultName": "Samuel Amalric"
        },
        "postContentText": "={{ $('Generate Caption with GPT-4').first().json.message.content.caption }}",
        "postContentMediaUrls": "={{ $json.url }}"
      },
      "credentials": {
        "blotatoApi": {
          "name": "<your credential>"
        }
      },
      "typeVersion": 2
    },
    {
      "id": "041b15b3-117b-4183-afec-91826c50144b",
      "name": "Facebook",
      "type": "@blotato/n8n-nodes-blotato.blotato",
      "disabled": true,
      "position": [
        5200,
        944
      ],
      "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 Caption with GPT-4').first().json.message.content.caption }}",
        "postContentMediaUrls": "={{ $json.url }}"
      },
      "credentials": {
        "blotatoApi": {
          "name": "<your credential>"
        }
      },
      "typeVersion": 2
    },
    {
      "id": "e25c57b2-68fc-4611-92c9-4cdac0d84cc3",
      "name": "Instagram",
      "type": "@blotato/n8n-nodes-blotato.blotato",
      "disabled": true,
      "position": [
        4880,
        1104
      ],
      "parameters": {
        "options": {},
        "accountId": {
          "__rl": true,
          "mode": "list",
          "value": "1687",
          "cachedResultUrl": "https://backend.blotato.com/v2/accounts/1687",
          "cachedResultName": "acces.a.vie"
        },
        "postContentText": "={{ $('Generate Caption with GPT-4').first().json.message.content.caption }}",
        "postContentMediaUrls": "={{ $json.url }}"
      },
      "credentials": {
        "blotatoApi": {
          "name": "<your credential>"
        }
      },
      "typeVersion": 2
    },
    {
      "id": "3c26c540-770a-4ad5-ba9f-58951d3914a2",
      "name": "Twitter (X)",
      "type": "@blotato/n8n-nodes-blotato.blotato",
      "disabled": true,
      "position": [
        5040,
        1104
      ],
      "parameters": {
        "options": {},
        "platform": "twitter",
        "accountId": {
          "__rl": true,
          "mode": "list",
          "value": "1289",
          "cachedResultUrl": "https://backend.blotato.com/v2/accounts/1289",
          "cachedResultName": "Docteur_Firas"
        },
        "postContentText": "={{ $('Generate Caption with GPT-4').first().json.message.content.caption }}",
        "postContentMediaUrls": "={{ $json.url }}"
      },
      "credentials": {
        "blotatoApi": {
          "name": "<your credential>"
        }
      },
      "typeVersion": 2
    },
    {
      "id": "b3a53816-e484-420d-ad3d-c4e6b7222590",
      "name": "Merge1",
      "type": "n8n-nodes-base.merge",
      "position": [
        5408,
        960
      ],
      "parameters": {
        "mode": "chooseBranch",
        "numberInputs": 6
      },
      "typeVersion": 3.2
    },
    {
      "id": "e403db8e-16d0-4183-b576-bb1a2f0a7f17",
      "name": "Send a text message",
      "type": "n8n-nodes-base.telegram",
      "position": [
        5584,
        1024
      ],
      "parameters": {
        "text": "Published",
        "chatId": "={{ $('Telegram Trigger').first().json.message.chat.id }}",
        "additionalFields": {}
      },
      "credentials": {
        "telegramApi": {
          "name": "<your credential>"
        }
      },
      "typeVersion": 1.2
    },
    {
      "id": "7ead4a83-59e6-4a08-b45f-f6e65de5ea98",
      "name": "Generate Caption with GPT-4",
      "type": "@n8n/n8n-nodes-langchain.openAi",
      "position": [
        3968,
        1040
      ],
      "parameters": {
        "modelId": {
          "__rl": true,
          "mode": "id",
          "value": "gpt-4o-mini"
        },
        "options": {},
        "messages": {
          "values": [
            {
              "content": "=Create an engaging TikTok caption for a video:\n\nBased on these Transcription: {{ $json.text }}\n\nRequirements:\n- Catchy hook in first line\n- Include 5-8 relevant trending hashtags\n- Keep it concise and engaging\n- Optimize for TikTok algorithm\n- Return 2 informations : the caption text with hashtags, and the title nothing else"
            }
          ]
        },
        "jsonOutput": true
      },
      "credentials": {
        "openAiApi": {
          "name": "<your credential>"
        }
      },
      "typeVersion": 1.8
    },
    {
      "id": "1d47fe67-9c9b-4b85-9da6-9f7c40ebd17c",
      "name": "Transcribe a recording",
      "type": "@n8n/n8n-nodes-langchain.openAi",
      "position": [
        3520,
        1040
      ],
      "parameters": {
        "options": {},
        "resource": "audio",
        "operation": "transcribe",
        "binaryPropertyName": "=data"
      },
      "credentials": {
        "openAiApi": {
          "name": "<your credential>"
        }
      },
      "typeVersion": 1.8
    },
    {
      "id": "bb045243-5553-42aa-937b-431faf69e1f9",
      "name": "Convert mp3 to data",
      "type": "n8n-nodes-base.httpRequest",
      "position": [
        3296,
        1040
      ],
      "parameters": {
        "url": "={{ $('Get Audio (Fetch Chatterbox Output)').item.json.audio.url }}",
        "options": {
          "response": {
            "response": {
              "responseFormat": "file"
            }
          }
        }
      },
      "typeVersion": 4.2
    }
  ],
  "active": false,
  "settings": {
    "executionOrder": "v1"
  },
  "versionId": "00f45e93-7ea9-4557-9ab1-49d9ef4564f3",
  "connections": {
    "Wait": {
      "main": [
        [
          {
            "node": "Download Audio",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "Merge": {
      "main": [
        [
          {
            "node": "Separate Audio (Video-to-Audio)",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "Merge1": {
      "main": [
        [
          {
            "node": "Send a text message",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "Tiktok": {
      "main": [
        [
          {
            "node": "Merge1",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "Youtube": {
      "main": [
        [
          {
            "node": "Merge1",
            "type": "main",
            "index": 5
          }
        ]
      ]
    },
    "Facebook": {
      "main": [
        [
          {
            "node": "Merge1",
            "type": "main",
            "index": 2
          }
        ]
      ]
    },
    "Linkedin": {
      "main": [
        [
          {
            "node": "Merge1",
            "type": "main",
            "index": 1
          }
        ]
      ]
    },
    "Instagram": {
      "main": [
        [
          {
            "node": "Merge1",
            "type": "main",
            "index": 3
          }
        ]
      ]
    },
    "Merge urls": {
      "main": [
        [
          {
            "node": "Combine (FAL FFmpeg Merge)",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "Twitter (X)": {
      "main": [
        [
          {
            "node": "Merge1",
            "type": "main",
            "index": 4
          }
        ]
      ]
    },
    "Download Audio": {
      "main": [
        [
          {
            "node": "Transform Video (FAL WAN Replace)",
            "type": "main",
            "index": 0
          },
          {
            "node": "Transform Audio (FAL Chatterbox)",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "Telegram Trigger": {
      "main": [
        [
          {
            "node": "Telegram Get File (Avatar)",
            "type": "main",
            "index": 0
          },
          {
            "node": "Extract Video URL",
            "type": "main",
            "index": 0
          },
          {
            "node": "Workflow Configuration",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "Extract Video URL": {
      "main": [
        [
          {
            "node": "Merge",
            "type": "main",
            "index": 1
          }
        ]
      ]
    },
    "Convert mp3 to data": {
      "main": [
        [
          {
            "node": "Transcribe a recording",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "Build Public Image URL": {
      "main": [
        [
          {
            "node": "Merge",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "Send Video to Telegram": {
      "main": [
        [
          {
            "node": "Convert mp3 to data",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "Transcribe a recording": {
      "main": [
        [
          {
            "node": "Generate Caption with GPT-4",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "Workflow Configuration": {
      "main": [
        [
          {
            "node": "Merge",
            "type": "main",
            "index": 2
          }
        ]
      ]
    },
    "Upload Video to BLOTATO": {
      "main": [
        [
          {
            "node": "Tiktok",
            "type": "main",
            "index": 0
          },
          {
            "node": "Linkedin",
            "type": "main",
            "index": 0
          },
          {
            "node": "Facebook",
            "type": "main",
            "index": 0
          },
          {
            "node": "Instagram",
            "type": "main",
            "index": 0
          },
          {
            "node": "Twitter (X)",
            "type": "main",
            "index": 0
          },
          {
            "node": "Youtube",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "Combine (FAL FFmpeg Merge)": {
      "main": [
        [
          {
            "node": "Wait Final (Job Status - FFmpeg)",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "Telegram Get File (Avatar)": {
      "main": [
        [
          {
            "node": "Build Public Image URL",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "Generate Caption with GPT-4": {
      "main": [
        [
          {
            "node": "Upload Video to BLOTATO",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "OUTPUT (Google Sheet Write)": {
      "main": [
        [
          {
            "node": "Send Video to Telegram",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "Get Video (Fetch WAN Output)": {
      "main": [
        [
          {
            "node": "Merge urls",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "Get Final (Fetch Final Video)": {
      "main": [
        [
          {
            "node": "OUTPUT (Google Sheet Write)",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "Wait Video (Job Status - WAN)": {
      "main": [
        [
          {
            "node": "Get Video (Fetch WAN Output)",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "Separate Audio (Video-to-Audio)": {
      "main": [
        [
          {
            "node": "Wait",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "Transform Audio (FAL Chatterbox)": {
      "main": [
        [
          {
            "node": "Wait Audio (Job Status - Chatterbox)",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "Wait Final (Job Status - FFmpeg)": {
      "main": [
        [
          {
            "node": "Get Final (Fetch Final Video)",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "Transform Video (FAL WAN Replace)": {
      "main": [
        [
          {
            "node": "Wait Video (Job Status - WAN)",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "Get Audio (Fetch Chatterbox Output)": {
      "main": [
        [
          {
            "node": "Merge urls",
            "type": "main",
            "index": 1
          }
        ]
      ]
    },
    "Wait Audio (Job Status - Chatterbox)": {
      "main": [
        [
          {
            "node": "Get Audio (Fetch Chatterbox Output)",
            "type": "main",
            "index": 0
          }
        ]
      ]
    }
  }
}