{
  "name": "Generate AI images via Telegram with WaveSpeed, credit system, PIX and S3",
  "nodes": [
    {
      "id": "2b1c4af2-f022-4378-83ae-804c4c50a075",
      "name": "Main Overview",
      "type": "n8n-nodes-base.stickyNote",
      "position": [
        -1536,
        1280
      ],
      "parameters": {
        "width": 784,
        "height": 620,
        "content": "## How it works\n\nThis Telegram bot enables AI-powered image generation and editing with a built-in credit system:\n\n1. **Text-to-Image**: Users send text prompts and receive AI-generated images via Wav"
      }
    },
    {
      "id": "56bc826e-cdfa-4cbe-8ef4-5f8e47bbf579",
      "name": "WaveSpeed text-to-image submit",
      "type": "n8n-nodes-wavespeed.waveSpeedTaskSubmit",
      "position": [
        3776,
        1840
      ]
    },
    {
      "id": "87715306-eb44-404b-8eba-991a40a526ce",
      "name": "newOptionAfterConfig",
      "type": "n8n-nodes-base.telegram",
      "position": [
        4624,
        1328
      ]
    },
    {
      "id": "28080a0c-a502-46f6-b60f-2dc25800f1e2",
      "name": "sendOptionsWelcome",
      "type": "n8n-nodes-base.telegram",
      "position": [
        3888,
        1632
      ]
    },
    {
      "id": "6597915a-b50f-4e85-afdb-496f2f4e2418",
      "name": "welcomeMessage",
      "type": "n8n-nodes-base.telegram",
      "position": [
        3504,
        1632
      ]
    },
    {
      "id": "459129da-ecd1-4b4d-844d-0581fe54ab24",
      "name": "resolutionConfig",
      "type": "n8n-nodes-base.telegram",
      "position": [
        3504,
        720
      ]
    },
    {
      "id": "5bef06df-1345-4c98-baae-e19eaaf14c4e",
      "name": "aspectRatioConfig",
      "type": "n8n-nodes-base.telegram",
      "position": [
        3504,
        544
      ]
    },
    {
      "id": "41f12d55-018b-42c6-981e-bde38d18f988",
      "name": "upsertStatusReturn",
      "type": "n8n-nodes-base.dataTable",
      "position": [
        2864,
        384
      ]
    },
    {
      "id": "97e65b5d-643a-4687-90af-1045afbbc5a0",
      "name": "upsertStatusConfig",
      "type": "n8n-nodes-base.dataTable",
      "position": [
        2864,
        544
      ]
    },
    {
      "id": "5bf92236-5a20-4743-9391-410be86c5b35",
      "name": "switchReturn/Config",
      "type": "n8n-nodes-base.switch",
      "position": [
        1584,
        1296
      ]
    },
    {
      "id": "cc14b083-4a14-4bf3-911c-9108376ff804",
      "name": "switchMaster",
      "type": "n8n-nodes-base.switch",
      "position": [
        2416,
        1360
      ]
    },
    {
      "id": "94fb7f83-68ab-4cd2-bd89-ab5368de6351",
      "name": "getUser",
      "type": "n8n-nodes-base.dataTable",
      "position": [
        16,
        1488
      ]
    },
    {
      "id": "1198f205-dda6-4e4a-9d62-b1ed013c882f",
      "name": "updateUserFirstAccess",
      "type": "n8n-nodes-base.dataTable",
      "position": [
        3696,
        1632
      ]
    },
    {
      "id": "2836e6cf-a5e4-4496-97a8-5687c1c6ffad",
      "name": "welcomeGenerateImage",
      "type": "n8n-nodes-base.telegram",
      "position": [
        3568,
        2064
      ]
    },
    {
      "id": "a56003eb-981a-41fa-a47f-4f11b9eba77d",
      "name": "sendForceReply",
      "type": "n8n-nodes-base.telegram",
      "position": [
        3744,
        2064
      ]
    },
    {
      "id": "43631000-3f95-4414-badb-0e5f11c896a6",
      "name": "editImageOnReply",
      "type": "n8n-nodes-wavespeed.waveSpeedTaskSubmit",
      "position": [
        3968,
        2560
      ]
    },
    {
      "id": "831ae13f-35e6-4bd7-a512-6a30d18372ba",
      "name": "editFields",
      "type": "n8n-nodes-base.set",
      "position": [
        3808,
        2560
      ]
    },
    {
      "id": "a5de6b2f-e73e-4732-b36b-9ab64d927c3d",
      "name": "messageType",
      "type": "n8n-nodes-base.switch",
      "position": [
        192,
        1472
      ]
    },
    {
      "id": "85f8a46f-497a-4270-b3b5-b72ef2bb0420",
      "name": "getFilePath",
      "type": "n8n-nodes-base.httpRequest",
      "position": [
        576,
        1408
      ]
    },
    {
      "id": "6da6b769-4605-447b-be30-430a6d913f8e",
      "name": "downloadImage",
      "type": "n8n-nodes-base.httpRequest",
      "position": [
        752,
        1408
      ]
    },
    {
      "id": "4a714f2d-88f9-4701-a3c6-1dd3e5058e92",
      "name": "uploadS3",
      "type": "n8n-nodes-base.s3",
      "position": [
        944,
        1408
      ]
    },
    {
      "id": "1439660e-9eed-4318-a165-a9369d0b2168",
      "name": "swtichW/WOCallback",
      "type": "n8n-nodes-base.switch",
      "position": [
        1232,
        1504
      ]
    },
    {
      "id": "eb4fa5c0-1936-4415-8e01-d704c2223d78",
      "name": "upsertUserStatus",
      "type": "n8n-nodes-base.dataTable",
      "position": [
        1584,
        1536
      ]
    },
    {
      "id": "38462bcc-770e-4ed6-8083-21fe05e1f82b",
      "name": "messageTypeGenerateImage",
      "type": "n8n-nodes-base.switch",
      "position": [
        3200,
        2032
      ]
    },
    {
      "id": "ae77ab85-73bf-4c4b-a48e-2ab590873315",
      "name": "ifImage+Caption",
      "type": "n8n-nodes-base.if",
      "position": [
        3296,
        2912
      ]
    },
    {
      "id": "69c12a5e-fa8e-4567-a24b-42b5a1857f0f",
      "name": "ifCreditsEnough",
      "type": "n8n-nodes-base.if",
      "position": [
        3568,
        2256
      ]
    },
    {
      "id": "e48fc944-5ff5-47f9-987b-4915a4fd88a6",
      "name": "ifCreditsEnough1",
      "type": "n8n-nodes-base.if",
      "position": [
        3568,
        1904
      ]
    },
    {
      "id": "a10ec164-c1d4-4b39-af37-0c01a3c1265d",
      "name": "ifCreditsEnough2",
      "type": "n8n-nodes-base.if",
      "position": [
        3520,
        2800
      ]
    },
    {
      "id": "40c0f57f-6b3f-44f4-8481-83326f257d5f",
      "name": "welcomeImageEdit",
      "type": "n8n-nodes-base.telegram",
      "position": [
        3520,
        2992
      ]
    },
    {
      "id": "5bf442a7-52ae-4fb1-9917-8dd2b854c20f",
      "name": "promptConfig",
      "type": "n8n-nodes-base.telegram",
      "position": [
        3504,
        896
      ]
    },
    {
      "id": "0982447c-cadf-420f-a3f8-2ebea3f3047b",
      "name": "switchPromptAction",
      "type": "n8n-nodes-base.switch",
      "position": [
        3696,
        880
      ]
    },
    {
      "id": "2bc86d67-a373-405f-8bd7-080091a72234",
      "name": "upsertStatusWaitingPrompt",
      "type": "n8n-nodes-base.dataTable",
      "position": [
        3904,
        720
      ]
    },
    {
      "id": "c13adfad-21b1-4fb6-a0b2-c1b1597d5e0a",
      "name": "upsertClearPrompt",
      "type": "n8n-nodes-base.dataTable",
      "position": [
        3904,
        896
      ]
    },
    {
      "id": "dbc8e5f1-cb22-4bc5-9196-416f0a8bc0e4",
      "name": "upsertSkipPrompt",
      "type": "n8n-nodes-base.dataTable",
      "position": [
        3904,
        1040
      ]
    },
    {
      "id": "9e87c754-9fb8-48a8-a25b-bdb7d0726a02",
      "name": "askPromptInput1",
      "type": "n8n-nodes-base.telegram",
      "position": [
        4080,
        720
      ]
    },
    {
      "id": "d864a052-7088-4b07-b0a4-bf5952e83772",
      "name": "upsertSavePrompt1",
      "type": "n8n-nodes-base.dataTable",
      "position": [
        3504,
        1168
      ]
    },
    {
      "id": "51179467-d4b3-4e80-9217-1daae48b7a7f",
      "name": "confirmPromptSaved1",
      "type": "n8n-nodes-base.telegram",
      "position": [
        3680,
        1168
      ]
    },
    {
      "id": "e50ab3cf-67fe-4f94-a8f1-125c1542db48",
      "name": "menuOptions",
      "type": "n8n-nodes-base.telegram",
      "position": [
        3504,
        384
      ]
    },
    {
      "id": "4ab2222d-185d-4cbf-bbf3-e435c5e92ec6",
      "name": "sendDepositOptions",
      "type": "n8n-nodes-base.telegram",
      "position": [
        3520,
        3264
      ]
    },
    {
      "id": "876b1dde-9f37-4c40-ac7b-d297bcc03b87",
      "name": "switchDeposit",
      "type": "n8n-nodes-base.switch",
      "position": [
        3232,
        3616
      ]
    },
    {
      "id": "06a9d328-6d1e-4ade-b345-c2e75e1845b8",
      "name": "getPaymentStatus",
      "type": "n8n-nodes-base.httpRequest",
      "position": [
        3632,
        4368
      ]
    },
    {
      "id": "69573f42-bb8a-4c64-838b-da505002ab87",
      "name": "paymentStatus",
      "type": "n8n-nodes-base.webhook",
      "position": [
        3152,
        4368
      ]
    },
    {
      "id": "0603e82c-ff45-4d11-940a-851ec41e6910",
      "name": "sendOptionsAfterPayment",
      "type": "n8n-nodes-base.telegram",
      "position": [
        5440,
        4288
      ]
    },
    {
      "id": "5e2d51ff-9a72-4138-9245-497f3f8d9eff",
      "name": "Credit System",
      "type": "n8n-nodes-base.stickyNote",
      "position": [
        5872,
        1664
      ],
      "parameters": {
        "width": 400,
        "height": 196,
        "content": "💳 **Credit System**\n\nUsers get initial credits, deducted on generation. Failed tasks refund credits automatically."
      }
    },
    {
      "id": "d50f4328-d259-4bf1-8679-d5342e4077a3",
      "name": "Payment Integration",
      "type": "n8n-nodes-base.stickyNote",
      "position": [
        2672,
        4320
      ],
      "parameters": {
        "width": 400,
        "height": 180,
        "content": "💰 **PIX Payment**\n\nBrazilian instant payment via Mercado Pago API. Handles QR code generation and webhook confirmations."
      }
    },
    {
      "id": "9f9087d6-a185-4e77-a4f8-7365daad9d7a",
      "name": "S3 Storage",
      "type": "n8n-nodes-base.stickyNote",
      "position": [
        512,
        1216
      ],
      "parameters": {
        "width": 590,
        "height": 342,
        "content": "📦 **S3 Storage**\n\nStores uploaded images for AI editing. Compatible with AWS S3 or MinIO."
      }
    },
    {
      "id": "28ec08ce-a14f-41e3-9067-c91b66091b13",
      "name": "WaveSpeed API",
      "type": "n8n-nodes-base.stickyNote",
      "position": [
        4640,
        1824
      ],
      "parameters": {
        "width": 350,
        "height": null,
        "content": "🎨 **WaveSpeed API**\n\nAI image generation and editing. Models: nano-banana-pro for text-to-image and edit-ultra."
      }
    },
    {
      "id": "eda4d3a6-f16f-4c24-a0b3-f47497bdd94b",
      "name": "User Status Flow",
      "type": "n8n-nodes-base.stickyNote",
      "position": [
        1456,
        1040
      ],
      "parameters": {
        "width": 350,
        "height": 678,
        "content": "🔄 **User Status**\n\nTracks user state: menu, config steps, generate_image, edit_image, deposit_credits."
      }
    },
    {
      "id": "aad174dd-7a64-4591-a33d-0c70b011c4c2",
      "name": "depositCredentials",
      "type": "n8n-nodes-base.set",
      "position": [
        3824,
        3632
      ]
    },
    {
      "id": "bc1bd2ae-8435-4a8a-8b02-829da1dd90e4",
      "name": "checkIfDepositInProgress",
      "type": "n8n-nodes-base.if",
      "position": [
        2864,
        3616
      ]
    },
    {
      "id": "ad028d5f-ed6a-4335-8b28-d3ad36ac726c",
      "name": "setDepositAmount3",
      "type": "n8n-nodes-base.set",
      "position": [
        3520,
        3472
      ]
    },
    {
      "id": "fb51fd41-0ec0-4061-85fa-2b6bd5c01402",
      "name": "setDepositAmount6",
      "type": "n8n-nodes-base.set",
      "position": [
        3520,
        3632
      ]
    },
    {
      "id": "c89674b2-63a5-42e1-89f9-0986c8112848",
      "name": "setDepositAmount10",
      "type": "n8n-nodes-base.set",
      "position": [
        3520,
        3792
      ]
    },
    {
      "id": "5a33cfc1-bde7-46b6-a257-901dfde2a875",
      "name": "insertPaymentRow",
      "type": "n8n-nodes-base.dataTable",
      "position": [
        4000,
        3632
      ]
    },
    {
      "id": "e06e19e3-e5d9-499e-9c81-580a46479b2a",
      "name": "apiMercadoPago",
      "type": "n8n-nodes-base.httpRequest",
      "position": [
        4176,
        3632
      ]
    },
    {
      "id": "6b94130a-4004-4bef-ba20-a3ccbd546279",
      "name": "getPix",
      "type": "n8n-nodes-base.set",
      "position": [
        4352,
        3632
      ]
    },
    {
      "id": "69581bfe-525a-4352-a39c-d543b555f894",
      "name": "pix_baseToFile",
      "type": "n8n-nodes-base.convertToFile",
      "position": [
        4528,
        3632
      ]
    },
    {
      "id": "ac42cbcd-3a7e-4057-9b9f-56922004feac",
      "name": "sendPixQRCode",
      "type": "n8n-nodes-base.telegram",
      "position": [
        4720,
        3632
      ]
    },
    {
      "id": "0562e39a-5c7b-4936-890e-8824aee868d0",
      "name": "sendPixText",
      "type": "n8n-nodes-base.telegram",
      "position": [
        4912,
        3632
      ]
    },
    {
      "id": "18a66f7a-3668-41af-996e-2f88d564b3d0",
      "name": "raceConditionDelay",
      "type": "n8n-nodes-base.wait",
      "position": [
        3392,
        4368
      ]
    },
    {
      "id": "ebc30f66-1cef-4687-8423-f0ea6e1d56fd",
      "name": "Race Condition Info",
      "type": "n8n-nodes-base.stickyNote",
      "position": [
        3280,
        4160
      ],
      "parameters": {
        "width": 320,
        "height": 374,
        "content": "🕒 **Race Condition Protection**\n\nRandom delay (1-4s) prevents conflicts from simultaneous webhook executions."
      }
    },
    {
      "id": "f7f89a80-9cdb-4010-a276-7fb975fe922f",
      "name": "switchForPaymentStatus",
      "type": "n8n-nodes-base.switch",
      "position": [
        4048,
        4352
      ]
    },
    {
      "id": "cf96bc91-684e-497a-a3cb-dcc1c1d4cc25",
      "name": "checkIfPaymentPending",
      "type": "n8n-nodes-base.if",
      "position": [
        4272,
        4208
      ]
    },
    {
      "id": "62b67941-b7af-48d3-99eb-c2ab2d7c2392",
      "name": "fetchPaymentRecord",
      "type": "n8n-nodes-base.dataTable",
      "position": [
        3808,
        4368
      ]
    },
    {
      "id": "1edc889b-2c31-4b7e-ac62-6d7c81dcf308",
      "name": "Pending Payment Validation",
      "type": "n8n-nodes-base.stickyNote",
      "position": [
        4128,
        3984
      ],
      "parameters": {
        "width": 320,
        "height": 150,
        "content": "✅ **Payment Validation**\n\nChecks if payment reference exists before processing webhook to avoid duplicates."
      }
    },
    {
      "id": "ba8908dd-5c60-49bd-86f4-590a3bc79d1b",
      "name": "upsertPaymentStatus",
      "type": "n8n-nodes-base.dataTable",
      "position": [
        4560,
        4064
      ]
    },
    {
      "id": "a5b74f85-20f1-42eb-b1f7-2666526eb94d",
      "name": "getUserAfterPayment",
      "type": "n8n-nodes-base.dataTable",
      "position": [
        4736,
        4064
      ]
    },
    {
      "id": "9ef4ef75-6d0a-4048-97c9-8a366e2976df",
      "name": "updateUserCreditsAfterPayment",
      "type": "n8n-nodes-base.dataTable",
      "position": [
        4912,
        4064
      ]
    },
    {
      "id": "4b05c0ed-3122-4669-af95-7514dd0a9c1e",
      "name": "paymentConfirmedText",
      "type": "n8n-nodes-base.telegram",
      "position": [
        5120,
        4064
      ]
    },
    {
      "id": "7a390020-bd98-435d-929f-3f5196e667f5",
      "name": "updateUserStatusAfterDecline",
      "type": "n8n-nodes-base.dataTable",
      "position": [
        4736,
        4480
      ]
    },
    {
      "id": "436d40b4-47e2-4511-9e4d-d9acfac87791",
      "name": "getUserAfterDecline",
      "type": "n8n-nodes-base.dataTable",
      "position": [
        4528,
        4480
      ]
    },
    {
      "id": "155d46e1-f926-4a68-beb1-06ffe6ffa6ed",
      "name": "paymentDeclinedText",
      "type": "n8n-nodes-base.telegram",
      "position": [
        5120,
        4480
      ]
    },
    {
      "id": "63407d87-7b6a-4004-a017-b6bb012caa56",
      "name": "qrCodePaymentInProgress",
      "type": "n8n-nodes-base.telegram",
      "position": [
        3088,
        3456
      ]
    },
    {
      "id": "4316f05d-bdfc-4913-9ced-861522ba62d2",
      "name": "updateCreditsSendedTask",
      "type": "n8n-nodes-base.dataTable",
      "position": [
        4640,
        2016
      ]
    },
    {
      "id": "8c392814-e5e3-401a-81b7-c82cbb4659b1",
      "name": "notCreditsEnoughMessage",
      "type": "n8n-nodes-base.telegram",
      "position": [
        4640,
        2192
      ]
    },
    {
      "id": "c5d1c916-53f6-4afb-a1b5-39836780c38f",
      "name": "taskSubmitedGenerate",
      "type": "n8n-nodes-base.telegram",
      "position": [
        4832,
        2016
      ]
    },
    {
      "id": "e8c0d040-3e87-4799-b5c7-59fed3aea4c8",
      "name": "sendActionGenerate",
      "type": "n8n-nodes-base.telegram",
      "position": [
        5024,
        2016
      ]
    },
    {
      "id": "405163c8-a2cf-4277-a1a5-248b7f65b2d6",
      "name": "checkTaskGenerate",
      "type": "n8n-nodes-wavespeed.wavespeedTaskStatus",
      "position": [
        5216,
        2016
      ]
    },
    {
      "id": "7a75a63b-b8eb-4c15-9974-ff6d197b3f5a",
      "name": "waitGenerateStatus",
      "type": "n8n-nodes-base.wait",
      "position": [
        5856,
        2160
      ]
    },
    {
      "id": "a654f0ed-d8da-4757-b2ca-6b26fc4b72a9",
      "name": "switchTaskGenerate",
      "type": "n8n-nodes-base.switch",
      "position": [
        5392,
        1984
      ]
    },
    {
      "id": "d9e12bf2-de12-4c72-8ea6-e74d2f68371b",
      "name": "getImage",
      "type": "n8n-nodes-base.httpRequest",
      "position": [
        5856,
        1888
      ]
    },
    {
      "id": "f6e53497-87c1-4d97-8d12-4bc298da2284",
      "name": "sendFailedGenerate",
      "type": "n8n-nodes-base.telegram",
      "position": [
        5856,
        2016
      ]
    },
    {
      "id": "198a6321-6c52-46dd-8f5b-76d150328bcf",
      "name": "resizeImage",
      "type": "n8n-nodes-base.editImage",
      "position": [
        6048,
        1888
      ]
    },
    {
      "id": "eef7ec33-9747-4ad6-8098-dc3990c23617",
      "name": "updateCreditOnFail",
      "type": "n8n-nodes-base.dataTable",
      "position": [
        6048,
        2016
      ]
    },
    {
      "id": "edf36f4f-7394-454f-b117-f269dc6e371f",
      "name": "sendGeneratedImage",
      "type": "n8n-nodes-base.telegram",
      "position": [
        6224,
        1888
      ]
    },
    {
      "id": "681da1ca-dde1-4e86-a0be-961fdbf43ec3",
      "name": "Send a text message1",
      "type": "n8n-nodes-base.telegram",
      "position": [
        464,
        -288
      ]
    },
    {
      "id": "79cc71b3-f201-4334-bf33-f1dcfa858ef2",
      "name": "If demo sended1",
      "type": "n8n-nodes-base.if",
      "position": [
        -560,
        -288
      ]
    },
    {
      "id": "46be3c6d-551c-4225-a17d-9f20c69f97f2",
      "name": "Welcome",
      "type": "n8n-nodes-base.telegram",
      "position": [
        -320,
        -288
      ]
    },
    {
      "id": "c12abd8d-bfc2-4449-a571-7c84804b1a6f",
      "name": "Send welcome media",
      "type": "n8n-nodes-base.telegram",
      "position": [
        -128,
        -288
      ]
    },
    {
      "id": "fa81ba19-a907-4d6b-bdce-f03bffe05d4d",
      "name": "Update welcome_demo_sended",
      "type": "n8n-nodes-base.dataTable",
      "position": [
        80,
        -288
      ]
    },
    {
      "id": "90799b9d-c463-4b92-bbe4-fc911c1f2ec2",
      "name": "Fields Chat",
      "type": "n8n-nodes-base.set",
      "position": [
        272,
        -288
      ]
    },
    {
      "id": "00778d4b-7f98-42eb-904c-228c54038d40",
      "name": "Demo Welcome Flow1",
      "type": "n8n-nodes-base.stickyNote",
      "position": [
        -672,
        -384
      ],
      "parameters": {
        "width": 1392,
        "height": 304,
        "content": "Welcome flow with demo media for first-time users. Currently disabled."
      }
    },
    {
      "id": "7cf0c5b1-3088-43d0-9286-ca298853ee23",
      "name": "Update use_edit_demo",
      "type": "n8n-nodes-base.dataTable",
      "position": [
        80,
        16
      ]
    },
    {
      "id": "428181a9-c950-49f4-8c57-9bc25abf6f3a",
      "name": "Edit image question",
      "type": "n8n-nodes-base.telegram",
      "position": [
        288,
        16
      ]
    },
    {
      "id": "46197493-7257-4b8f-9a54-6eef31d682f8",
      "name": "If use_edit_demo1",
      "type": "n8n-nodes-base.if",
      "position": [
        -560,
        32
      ]
    },
    {
      "id": "a8346294-c529-454e-adee-a64cdae910ed",
      "name": "Send a media group demo1",
      "type": "n8n-nodes-base.telegram",
      "position": [
        -112,
        16
      ]
    },
    {
      "id": "1a77a1b9-a467-49a1-a7cc-7e589d7b49b1",
      "name": "Welcome image edit message",
      "type": "n8n-nodes-base.telegram",
      "position": [
        -320,
        16
      ]
    },
    {
      "id": "be888f74-c994-42eb-a5a0-553062cf127e",
      "name": "Demo Edit Image Flow1",
      "type": "n8n-nodes-base.stickyNote",
      "position": [
        -672,
        -48
      ],
      "parameters": {
        "width": 1392,
        "height": 304,
        "content": "Demo flow showing image editing capabilities. Currently disabled."
      }
    },
    {
      "id": "0c354a09-540d-4409-acda-17be0128f3fa",
      "name": "Global Config Info1",
      "type": "n8n-nodes-base.stickyNote",
      "position": [
        -416,
        1280
      ],
      "parameters": {
        "width": 368,
        "height": 360,
        "content": "🌍 **Global Environment**\n\nMain bot configuration: tokens, database IDs, credit costs, and default messages. Edit carefully."
      }
    },
    {
      "id": "2795bf30-04fb-4ea2-b376-6b4ee1cbb14a",
      "name": "Entry Point1",
      "type": "n8n-nodes-base.stickyNote",
      "position": [
        -688,
        1280
      ],
      "parameters": {
        "width": 254,
        "height": 358,
        "content": "🎯 **Entry Point**\n\nTelegram Trigger receives all messages and callbacks. Routes to appropriate handlers."
      }
    },
    {
      "id": "cfb7df6c-77a2-4554-a7bc-329ab8bc0ea9",
      "name": "Customization Ideas1",
      "type": "n8n-nodes-base.stickyNote",
      "position": [
        -416,
        1680
      ],
      "parameters": {
        "width": 366,
        "height": 150,
        "content": "🛠️ **Customization**\n\nAdjust credits, costs, messages. Add watermarks, referrals, or swap AI providers."
      }
    },
    {
      "id": "482f8adc-9cce-4785-b033-b7965d9b1e75",
      "name": "Global env",
      "type": "n8n-nodes-base.set",
      "position": [
        -272,
        1488
      ]
    },
    {
      "id": "b91d4ab2-7adb-4fff-a05e-0625e0dca09f",
      "name": "Telegram Trigger",
      "type": "n8n-nodes-base.telegramTrigger",
      "position": [
        -608,
        1488
      ]
    }
  ],
  "connections": {
    "getPix": {
      "main": [
        [
          {
            "node": "pix_baseToFile",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "Welcome": {
      "main": [
        [
          {
            "node": "Send welcome media",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "getUser": {
      "main": [
        [
          {
            "node": "messageType",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "getImage": {
      "main": [
        [
          {
            "node": "resizeImage",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "uploadS3": {
      "main": [
        [
          {
            "node": "swtichW/WOCallback",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "Global env": {
      "main": [
        [
          {
            "node": "getUser",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "editFields": {
      "main": [
        [
          {
            "node": "editImageOnReply",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "Fields Chat": {
      "main": [
        [
          {
            "node": "Send a text message1",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "getFilePath": {
      "main": [
        [
          {
            "node": "downloadImage",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "messageType": {
      "main": [
        [
          {
            "node": "getFilePath",
            "type": "main",
            "index": 0
          }
        ],
        [
          {
            "node": "getFilePath",
            "type": "main",
            "index": 0
          }
        ],
        [
          {
            "node": "swtichW/WOCallback",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "resizeImage": {
      "main": [
        [
          {
            "node": "sendGeneratedImage",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "promptConfig": {
      "main": [
        [
          {
            "node": "switchPromptAction",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "switchMaster": {
      "main": [
        [
          {
            "node": "menuOptions",
            "type": "main",
            "index": 0
          }
        ],
        [
          {
            "node": "aspectRatioConfig",
            "type": "main",
            "index": 0
          }
        ],
        [
          {
            "node": "resolutionConfig",
            "type": "main",
            "index": 0
          }
        ],
        [
          {
            "node": "promptConfig",
            "type": "main",
            "index": 0
          }
        ],
        [
          {
            "node": "upsertSavePrompt1",
            "type": "main",
            "index": 0
          }
        ],
        [
          {
            "node": "newOptionAfterConfig",
            "type": "main",
            "index": 0
          }
        ],
        [
          {
            "node": "welcomeMessage",
            "type": "main",
            "index": 0
          }
        ],
        [
          {
            "node": "messageTypeGenerateImage",
            "type": "main",
            "index": 0
          }
        ],
        [],
        [
          {
            "node": "ifImage+Caption",
            "type": "main",
            "index": 0
          }
        ],
        [
          {
            "node": "sendDepositOptions",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "downloadImage": {
      "main": [
        [
          {
            "node": "uploadS3",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "paymentStatus": {
      "main": [
        [
          {
            "node": "raceConditionDelay",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "sendPixQRCode": {
      "main": [
        [
          {
            "node": "sendPixText",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "switchDeposit": {
      "main": [
        [
          {
            "node": "setDepositAmount3",
            "type": "main",
            "index": 0
          }
        ],
        [
          {
            "node": "setDepositAmount6",
            "type": "main",
            "index": 0
          }
        ],
        [
          {
            "node": "setDepositAmount10",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "apiMercadoPago": {
      "main": [
        [
          {
            "node": "getPix",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "pix_baseToFile": {
      "main": [
        [
          {
            "node": "sendPixQRCode",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "welcomeMessage": {
      "main": [
        [
          {
            "node": "updateUserFirstAccess",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "If demo sended1": {
      "main": [
        [
          {
            "node": "Welcome",
            "type": "main",
            "index": 0
          }
        ],
        [
          {
            "node": "Fields Chat",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "ifCreditsEnough": {
      "main": [
        [
          {
            "node": "editFields",
            "type": "main",
            "index": 0
          }
        ],
        [
          {
            "node": "notCreditsEnoughMessage",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "ifImage+Caption": {
      "main": [
        [
          {
            "node": "ifCreditsEnough2",
            "type": "main",
            "index": 0
          }
        ],
        [
          {
            "node": "welcomeImageEdit",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "Telegram Trigger": {
      "main": [
        [
          {
            "node": "Global env",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "editImageOnReply": {
      "main": [
        [
          {
            "node": "updateCreditsSendedTask",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "getPaymentStatus": {
      "main": [
        [
          {
            "node": "fetchPaymentRecord",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "ifCreditsEnough1": {
      "main": [
        [
          {
            "node": "WaveSpeed text-to-image submit",
            "type": "main",
            "index": 0
          }
        ],
        [
          {
            "node": "notCreditsEnoughMessage",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "ifCreditsEnough2": {
      "main": [
        [
          {
            "node": "editFields",
            "type": "main",
            "index": 0
          }
        ],
        [
          {
            "node": "notCreditsEnoughMessage",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "insertPaymentRow": {
      "main": [
        [
          {
            "node": "apiMercadoPago",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "upsertSkipPrompt": {
      "main": [
        [
          {
            "node": "newOptionAfterConfig",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "upsertUserStatus": {
      "main": [
        [
          {
            "node": "switchMaster",
            "type": "main",
            "index": 0
          },
          {
            "node": "switchPromptAction",
            "type": "main",
            "index": 0
          },
          {
            "node": "checkIfDepositInProgress",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "If use_edit_demo1": {
      "main": [
        [
          {
            "node": "Welcome image edit message",
            "type": "main",
            "index": 0
          }
        ],
        [
          {
            "node": "Edit image question",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "checkTaskGenerate": {
      "main": [
        [
          {
            "node": "switchTaskGenerate",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "setDepositAmount3": {
      "main": [
        [
          {
            "node": "depositCredentials",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "setDepositAmount6": {
      "main": [
        [
          {
            "node": "depositCredentials",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "upsertClearPrompt": {
      "main": [
        [
          {
            "node": "newOptionAfterConfig",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "upsertSavePrompt1": {
      "main": [
        [
          {
            "node": "confirmPromptSaved1",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "Send welcome media": {
      "main": [
        [
          {
            "node": "Update welcome_demo_sended",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "depositCredentials": {
      "main": [
        [
          {
            "node": "insertPaymentRow",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "fetchPaymentRecord": {
      "main": [
        [
          {
            "node": "switchForPaymentStatus",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "raceConditionDelay": {
      "main": [
        [
          {
            "node": "getPaymentStatus",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "sendActionGenerate": {
      "main": [
        [
          {
            "node": "checkTaskGenerate",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "sendFailedGenerate": {
      "main": [
        [
          {
            "node": "updateCreditOnFail",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "setDepositAmount10": {
      "main": [
        [
          {
            "node": "depositCredentials",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "switchPromptAction": {
      "main": [
        [
          {
            "node": "upsertStatusWaitingPrompt",
            "type": "main",
            "index": 0
          }
        ],
        [
          {
            "node": "upsertClearPrompt",
            "type": "main",
            "index": 0
          }
        ],
        [
          {
            "node": "upsertSkipPrompt",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "switchTaskGenerate": {
      "main": [
        [
          {
            "node": "getImage",
            "type": "main",
            "index": 0
          }
        ],
        [
          {
            "node": "sendFailedGenerate",
            "type": "main",
            "index": 0
          }
        ],
        [
          {
            "node": "waitGenerateStatus",
            "type": "main",
            "index": 0
          }
        ],
        [
          {
            "node": "waitGenerateStatus",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "swtichW/WOCallback": {
      "main": [
        [
          {
            "node": "switchReturn/Config",
            "type": "main",
            "index": 0
          }
        ],
        [
          {
            "node": "upsertUserStatus",
            "type": "main",
            "index": 0
          }
        ],
        [
          {
            "node": "upsertUserStatus",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "upsertStatusConfig": {
      "main": [
        [
          {
            "node": "aspectRatioConfig",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "upsertStatusReturn": {
      "main": [
        [
          {
            "node": "menuOptions",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "waitGenerateStatus": {
      "main": [
        [
          {
            "node": "sendActionGenerate",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "confirmPromptSaved1": {
      "main": [
        [
          {
            "node": "newOptionAfterConfig",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "getUserAfterDecline": {
      "main": [
        [
          {
            "node": "updateUserStatusAfterDecline",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "getUserAfterPayment": {
      "main": [
        [
          {
            "node": "updateUserCreditsAfterPayment",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "paymentDeclinedText": {
      "main": [
        [
          {
            "node": "sendOptionsAfterPayment",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "switchReturn/Config": {
      "main": [
        [
          {
            "node": "upsertStatusReturn",
            "type": "main",
            "index": 0
          }
        ],
        [
          {
            "node": "upsertStatusConfig",
            "type": "main",
            "index": 0
          }
        ],
        [
          {
            "node": "switchMaster",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "upsertPaymentStatus": {
      "main": [
        [
          {
            "node": "getUserAfterPayment",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "Update use_edit_demo": {
      "main": [
        [
          {
            "node": "Edit image question",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "paymentConfirmedText": {
      "main": [
        [
          {
            "node": "sendOptionsAfterPayment",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "taskSubmitedGenerate": {
      "main": [
        [
          {
            "node": "sendActionGenerate",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "welcomeGenerateImage": {
      "main": [
        [
          {
            "node": "sendForceReply",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "checkIfPaymentPending": {
      "main": [
        [
          {
            "node": "upsertPaymentStatus",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "updateUserFirstAccess": {
      "main": [
        [
          {
            "node": "sendOptionsWelcome",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "switchForPaymentStatus": {
      "main": [
        [
          {
            "node": "checkIfPaymentPending",
            "type": "main",
            "index": 0
          }
        ],
        [],
        [
          {
            "node": "getUserAfterDecline",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "updateCreditsSendedTask": {
      "main": [
        [
          {
            "node": "taskSubmitedGenerate",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "Send a media group demo1": {
      "main": [
        [
          {
            "node": "Update use_edit_demo",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "checkIfDepositInProgress": {
      "main": [
        [
          {
            "node": "qrCodePaymentInProgress",
            "type": "main",
            "index": 0
          }
        ],
        [
          {
            "node": "switchDeposit",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "messageTypeGenerateImage": {
      "main": [
        [
          {
            "node": "ifCreditsEnough1",
            "type": "main",
            "index": 0
          }
        ],
        [
          {
            "node": "welcomeGenerateImage",
            "type": "main",
            "index": 0
          }
        ],
        [
          {
            "node": "ifCreditsEnough",
            "type": "main",
            "index": 0
          }
        ],
        [
          {
            "node": "ifCreditsEnough1",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "upsertStatusWaitingPrompt": {
      "main": [
        [
          {
            "node": "askPromptInput1",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "Update welcome_demo_sended": {
      "main": [
        [
          {
            "node": "Fields Chat",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "Welcome image edit message": {
      "main": [
        [
          {
            "node": "Send a media group demo1",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "updateUserStatusAfterDecline": {
      "main": [
        [
          {
            "node": "paymentDeclinedText",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "updateUserCreditsAfterPayment": {
      "main": [
        [
          {
            "node": "paymentConfirmedText",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "WaveSpeed text-to-image submit": {
      "main": [
        [
          {
            "node": "updateCreditsSendedTask",
            "type": "main",
            "index": 0
          }
        ]
      ]
    }
  }
}