{
  "meta": {
    "instanceId": "3a61d8efbc87299451706b288a37c1a883318714df0d5351e2956e49e0cc6d7f",
    "templateCredsSetupCompleted": true
  },
  "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 WaveSpeed API\n2. **Image Editing**: Users send photos with captions to edit images using AI\n3. **Credit System**: Credits are deducted per generation with 4K/8K pricing tiers\n4. **Payments**: Users purchase credits via PIX instant payment (Brazil)\n5. **Storage**: Generated and uploaded images are stored in S3-compatible storage\n\nUsers can configure aspect ratios, resolutions, and custom default prompts. The bot handles concurrent requests safely with race condition protection.\n\n## Setup steps\n\n1. Create a Telegram bot via @BotFather and get your bot token\n2. Sign up for WaveSpeed API and obtain your credentials\n3. Set up S3-compatible storage (AWS S3 or MinIO)\n4. Create an n8n Data Table with columns: chat_id, status, credits, resolution, aspect_ratio, user_default_prompt\n5. Configure the **Global env** node with all your settings\n6. Set up credentials for Telegram, WaveSpeed, S3, and Mercado Pago\n7. Update webhook URLs and activate the workflow"
      },
      "typeVersion": 1
    },
    {
      "id": "56bc826e-cdfa-4cbe-8ef4-5f8e47bbf579",
      "name": "WaveSpeed text-to-image submit",
      "type": "n8n-nodes-wavespeed.waveSpeedTaskSubmit",
      "position": [
        3776,
        1840
      ],
      "parameters": {
        "model": "google/nano-banana-pro/text-to-image-ultra",
        "category": "text-to-image",
        "optionalParameters": {
          "value": {
            "resolution": "={{ $json.resolution }}",
            "aspect_ratio": "={{ $json.aspect_ratio }}",
            "output_format": "jpeg"
          },
          "schema": [
            {
              "id": "aspect_ratio",
              "type": "options",
              "display": true,
              "options": [
                {
                  "name": "1:1",
                  "value": "1:1",
                  "description": "1:1"
                },
                {
                  "name": "3:2",
                  "value": "3:2",
                  "description": "3:2"
                },
                {
                  "name": "2:3",
                  "value": "2:3",
                  "description": "2:3"
                },
                {
                  "name": "3:4",
                  "value": "3:4",
                  "description": "3:4"
                },
                {
                  "name": "4:3",
                  "value": "4:3",
                  "description": "4:3"
                },
                {
                  "name": "4:5",
                  "value": "4:5",
                  "description": "4:5"
                },
                {
                  "name": "5:4",
                  "value": "5:4",
                  "description": "5:4"
                },
                {
                  "name": "9:16",
                  "value": "9:16",
                  "description": "9:16"
                },
                {
                  "name": "16:9",
                  "value": "16:9",
                  "description": "16:9"
                },
                {
                  "name": "21:9",
                  "value": "21:9",
                  "description": "21:9"
                }
              ],
              "removed": false,
              "required": false,
              "displayName": "Aspect Ratio (OPTIONS)",
              "defaultMatch": false,
              "canBeUsedToMatch": false
            },
            {
              "id": "resolution",
              "type": "options",
              "display": true,
              "options": [
                {
                  "name": "4k",
                  "value": "4k",
                  "description": "4k"
                },
                {
                  "name": "8k",
                  "value": "8k",
                  "description": "8k"
                }
              ],
              "removed": false,
              "required": false,
              "displayName": "Resolution (OPTIONS) [Default: \"4k\"]",
              "defaultMatch": false,
              "canBeUsedToMatch": false
            },
            {
              "id": "output_format",
              "type": "options",
              "display": true,
              "options": [
                {
                  "name": "png",
                  "value": "png",
                  "description": "png"
                },
                {
                  "name": "jpeg",
                  "value": "jpeg",
                  "description": "jpeg"
                }
              ],
              "removed": false,
              "required": false,
              "displayName": "Output Format (OPTIONS) [Default: \"png\"]",
              "defaultMatch": false,
              "canBeUsedToMatch": false
            }
          ],
          "mappingMode": "defineBelow",
          "matchingColumns": [],
          "attemptToConvertTypes": false,
          "convertFieldsToString": false
        },
        "requiredParameters": {
          "value": {
            "prompt": "={{\n  (() => {\n    const userText = $('Telegram Trigger').item.json.message.text;\n    const userDefaultPrompt = $('getUser').item.json.user_default_prompt;\n    const globalDefaultPrompt = $('Global env').item.json.defaultEditPrompt;\n    \n    const defaultPrompt = globalDefaultPrompt || userDefaultPrompt || '';\n    \n    if (userText && defaultPrompt) {\n      return `${userText}\\n\\n${defaultPrompt}`;\n    }\n    \n    return userText || defaultPrompt || '';\n  })()\n}}"
          },
          "schema": [
            {
              "id": "prompt",
              "type": "string",
              "display": true,
              "required": true,
              "displayName": "Prompt (STRING) *",
              "defaultMatch": false,
              "canBeUsedToMatch": false
            }
          ],
          "mappingMode": "defineBelow",
          "matchingColumns": [
            "prompt"
          ],
          "attemptToConvertTypes": false,
          "convertFieldsToString": false
        }
      },
      "credentials": {
        "wavespeedApi": {
          "id": "credential-id",
          "name": "WaveSpeed account"
        }
      },
      "typeVersion": 1
    },
    {
      "id": "87715306-eb44-404b-8eba-991a40a526ce",
      "name": "newOptionAfterConfig",
      "type": "n8n-nodes-base.telegram",
      "position": [
        4624,
        1328
      ],
      "webhookId": "YOUR_WEBHOOK_ID",
      "parameters": {
        "text": "=Configuration updated successfully! ✅\n\nYour preferences have been saved.\nYou can continue normally 🚀",
        "chatId": "={{ $('getUser').item.json.chat_id }}",
        "replyMarkup": "inlineKeyboard",
        "inlineKeyboard": {
          "rows": [
            {
              "row": {
                "buttons": [
                  {
                    "text": "Generate Image",
                    "additionalFields": {
                      "callback_data": "generate_image"
                    }
                  },
                  {
                    "text": "Edit Image",
                    "additionalFields": {
                      "callback_data": "edit_image"
                    }
                  }
                ]
              }
            },
            {
              "row": {
                "buttons": [
                  {
                    "text": "Deposit Credits",
                    "additionalFields": {
                      "callback_data": "deposit_credits"
                    }
                  }
                ]
              }
            }
          ]
        },
        "additionalFields": {
          "appendAttribution": false
        }
      },
      "credentials": {
        "telegramApi": {
          "id": "credential-id",
          "name": "Imageon AI"
        }
      },
      "typeVersion": 1.2
    },
    {
      "id": "28080a0c-a502-46f6-b60f-2dc25800f1e2",
      "name": "sendOptionsWelcome",
      "type": "n8n-nodes-base.telegram",
      "position": [
        3888,
        1632
      ],
      "webhookId": "YOUR_WEBHOOK_ID",
      "parameters": {
        "text": "=Please select one of the options below to continue 👇\n\nJust tap a button to proceed 🚀",
        "chatId": "={{ $json.chat_id }}",
        "replyMarkup": "inlineKeyboard",
        "inlineKeyboard": {
          "rows": [
            {
              "row": {
                "buttons": [
                  {
                    "text": "Generate Image",
                    "additionalFields": {
                      "callback_data": "generate_image"
                    }
                  },
                  {
                    "text": "Edit Image",
                    "additionalFields": {
                      "callback_data": "edit_image"
                    }
                  }
                ]
              }
            },
            {
              "row": {
                "buttons": [
                  {
                    "text": "Deposit Credits",
                    "additionalFields": {
                      "callback_data": "deposit_credits"
                    }
                  }
                ]
              }
            }
          ]
        },
        "additionalFields": {
          "appendAttribution": false
        }
      },
      "credentials": {
        "telegramApi": {
          "id": "credential-id",
          "name": "Imageon AI"
        }
      },
      "typeVersion": 1.2
    },
    {
      "id": "6597915a-b50f-4e85-afdb-496f2f4e2418",
      "name": "welcomeMessage",
      "type": "n8n-nodes-base.telegram",
      "position": [
        3504,
        1632
      ],
      "webhookId": "YOUR_WEBHOOK_ID",
      "parameters": {
        "text": "=I’m <b>{{ $('Global env').item.json.botName }}</b> 🤖✨\n\nI use <b>Nano Banana Ultra</b> 🍌⚡ to generate and edit images with high quality and speed.\n\n🎁 To help you get started, I’ve added <b>{{ $('Global env').item.json.initialCredits }}</b> initial credits to your account.\n\nWhen you’re ready, just get started!\nAt any time, you can type:\n\n<pre>menu</pre>\nto return to the menu, or\n\n<pre>config</pre>\nto change generation and editing settings 🚀\n",
        "chatId": "={{ $('Telegram Trigger').item.json.message.chat.id }}",
        "additionalFields": {
          "parse_mode": "HTML",
          "appendAttribution": false
        }
      },
      "credentials": {
        "telegramApi": {
          "id": "credential-id",
          "name": "Imageon AI"
        }
      },
      "typeVersion": 1.2
    },
    {
      "id": "459129da-ecd1-4b4d-844d-0581fe54ab24",
      "name": "resolutionConfig",
      "type": "n8n-nodes-base.telegram",
      "position": [
        3504,
        720
      ],
      "webhookId": "YOUR_WEBHOOK_ID",
      "parameters": {
        "text": "=🍌 Nano Banana — Resolution\n\nChoose the image resolution 🖼️\n\n4K → High quality (balance between detail and cost)\n8K → Maximum quality (more detail and higher usage)\n\n⚠️ Note: The cost will change depending on the selected resolution:\n• 4K → {{ $('Global env').item.json.generateImageCost4k }}\n• 8K → {{ $('Global env').item.json.generateImageCost8k }}\n\nSelect an option to continue 👇",
        "chatId": "={{ $('getUser').item.json.chat_id }}",
        "replyMarkup": "inlineKeyboard",
        "inlineKeyboard": {
          "rows": [
            {
              "row": {
                "buttons": [
                  {
                    "text": "4k",
                    "additionalFields": {
                      "callback_data": "4k"
                    }
                  },
                  {
                    "text": "8k",
                    "additionalFields": {
                      "callback_data": "8k"
                    }
                  }
                ]
              }
            }
          ]
        },
        "additionalFields": {
          "appendAttribution": false
        }
      },
      "credentials": {
        "telegramApi": {
          "id": "credential-id",
          "name": "Imageon AI"
        }
      },
      "typeVersion": 1.2
    },
    {
      "id": "5bef06df-1345-4c98-baae-e19eaaf14c4e",
      "name": "aspectRatioConfig",
      "type": "n8n-nodes-base.telegram",
      "position": [
        3504,
        544
      ],
      "webhookId": "YOUR_WEBHOOK_ID",
      "parameters": {
        "text": "=🍌 Nano Banana — Aspect Ratio\n\nChoose the image aspect ratio 📐\n\n1:1 → Square (posts, avatars)\n3:4 → Vertical (portraits)\n9:16 → Full vertical (stories, reels)\n16:9 → Horizontal (landscapes, videos)\n21:9 → Ultra wide (cinematic)\n\nTap an option to continue 👇\nNext step: Resolution",
        "chatId": "={{ $('getUser').item.json.chat_id }}",
        "replyMarkup": "inlineKeyboard",
        "inlineKeyboard": {
          "rows": [
            {
              "row": {
                "buttons": [
                  {
                    "text": "1:1",
                    "additionalFields": {
                      "callback_data": "1:1"
                    }
                  },
                  {
                    "text": "3:4",
                    "additionalFields": {
                      "callback_data": "3:4"
                    }
                  },
                  {
                    "text": "9:16",
                    "additionalFields": {
                      "callback_data": "9:16"
                    }
                  },
                  {
                    "text": "16:9",
                    "additionalFields": {
                      "callback_data": "16:9"
                    }
                  },
                  {
                    "text": "21:9",
                    "additionalFields": {
                      "callback_data": "21:9"
                    }
                  }
                ]
              }
            }
          ]
        },
        "additionalFields": {
          "appendAttribution": false
        }
      },
      "credentials": {
        "telegramApi": {
          "id": "credential-id",
          "name": "Imageon AI"
        }
      },
      "typeVersion": 1.2
    },
    {
      "id": "41f12d55-018b-42c6-981e-bde38d18f988",
      "name": "upsertStatusReturn",
      "type": "n8n-nodes-base.dataTable",
      "position": [
        2864,
        384
      ],
      "parameters": {
        "columns": {
          "value": {
            "status": "menu"
          },
          "schema": [
            {
              "id": "status",
              "type": "string",
              "display": true,
              "removed": false,
              "readOnly": false,
              "required": false,
              "displayName": "status",
              "defaultMatch": false
            },
            {
              "id": "number_images",
              "type": "number",
              "display": true,
              "removed": true,
              "readOnly": false,
              "required": false,
              "displayName": "number_images",
              "defaultMatch": false
            },
            {
              "id": "username",
              "type": "string",
              "display": true,
              "removed": true,
              "readOnly": false,
              "required": false,
              "displayName": "username",
              "defaultMatch": false
            },
            {
              "id": "number_videos",
              "type": "number",
              "display": true,
              "removed": true,
              "readOnly": false,
              "required": false,
              "displayName": "number_videos",
              "defaultMatch": false
            },
            {
              "id": "credits",
              "type": "string",
              "display": true,
              "removed": true,
              "readOnly": false,
              "required": false,
              "displayName": "credits",
              "defaultMatch": false
            },
            {
              "id": "demo_sended",
              "type": "boolean",
              "display": true,
              "removed": true,
              "readOnly": false,
              "required": false,
              "displayName": "demo_sended",
              "defaultMatch": false
            }
          ],
          "mappingMode": "defineBelow",
          "matchingColumns": [],
          "attemptToConvertTypes": false,
          "convertFieldsToString": false
        },
        "filters": {
          "conditions": [
            {
              "keyName": "chat_id",
              "keyValue": "={{ $('getUser').item.json.chat_id }}"
            }
          ]
        },
        "options": {},
        "matchType": "allConditions",
        "operation": "upsert",
        "dataTableId": {
          "__rl": true,
          "mode": "id",
          "value": "={{ $('Global env').item.json.dataTableId }}"
        }
      },
      "typeVersion": 1
    },
    {
      "id": "97e65b5d-643a-4687-90af-1045afbbc5a0",
      "name": "upsertStatusConfig",
      "type": "n8n-nodes-base.dataTable",
      "position": [
        2864,
        544
      ],
      "parameters": {
        "columns": {
          "value": {
            "status": "config"
          },
          "schema": [
            {
              "id": "status",
              "type": "string",
              "display": true,
              "removed": false,
              "readOnly": false,
              "required": false,
              "displayName": "status",
              "defaultMatch": false
            },
            {
              "id": "number_images",
              "type": "number",
              "display": true,
              "removed": true,
              "readOnly": false,
              "required": false,
              "displayName": "number_images",
              "defaultMatch": false
            },
            {
              "id": "username",
              "type": "string",
              "display": true,
              "removed": true,
              "readOnly": false,
              "required": false,
              "displayName": "username",
              "defaultMatch": false
            },
            {
              "id": "number_videos",
              "type": "number",
              "display": true,
              "removed": true,
              "readOnly": false,
              "required": false,
              "displayName": "number_videos",
              "defaultMatch": false
            },
            {
              "id": "credits",
              "type": "string",
              "display": true,
              "removed": true,
              "readOnly": false,
              "required": false,
              "displayName": "credits",
              "defaultMatch": false
            },
            {
              "id": "demo_sended",
              "type": "boolean",
              "display": true,
              "removed": true,
              "readOnly": false,
              "required": false,
              "displayName": "demo_sended",
              "defaultMatch": false
            }
          ],
          "mappingMode": "defineBelow",
          "matchingColumns": [],
          "attemptToConvertTypes": false,
          "convertFieldsToString": false
        },
        "filters": {
          "conditions": [
            {
              "keyName": "chat_id",
              "keyValue": "={{ $('getUser').item.json.chat_id }}"
            }
          ]
        },
        "options": {},
        "matchType": "allConditions",
        "operation": "upsert",
        "dataTableId": {
          "__rl": true,
          "mode": "id",
          "value": "={{ $('Global env').item.json.dataTableId }}"
        }
      },
      "typeVersion": 1
    },
    {
      "id": "5bf92236-5a20-4743-9391-410be86c5b35",
      "name": "switchReturn/Config",
      "type": "n8n-nodes-base.switch",
      "position": [
        1584,
        1296
      ],
      "parameters": {
        "rules": {
          "values": [
            {
              "outputKey": "Return Menu",
              "conditions": {
                "options": {
                  "version": 3,
                  "leftValue": "",
                  "caseSensitive": true,
                  "typeValidation": "strict"
                },
                "combinator": "and",
                "conditions": [
                  {
                    "id": "96938911-f031-4803-a93e-fba36c6dd3ef",
                    "operator": {
                      "type": "boolean",
                      "operation": "true",
                      "singleValue": true
                    },
                    "leftValue": "={{ $('Telegram Trigger').item.json.message.text?.trim().toLowerCase() === 'menu' }}",
                    "rightValue": ""
                  }
                ]
              },
              "renameOutput": true
            },
            {
              "outputKey": "Generate Config",
              "conditions": {
                "options": {
                  "version": 3,
                  "leftValue": "",
                  "caseSensitive": true,
                  "typeValidation": "strict"
                },
                "combinator": "and",
                "conditions": [
                  {
                    "id": "4a7cb421-b1c3-4c5b-9b10-6eae9a191dc3",
                    "operator": {
                      "type": "boolean",
                      "operation": "true",
                      "singleValue": true
                    },
                    "leftValue": "={{ $('Telegram Trigger').item.json.message.text?.trim().toLowerCase() === 'config' }}",
                    "rightValue": ""
                  }
                ]
              },
              "renameOutput": true
            },
            {
              "outputKey": "Texto",
              "conditions": {
                "options": {
                  "version": 3,
                  "leftValue": "",
                  "caseSensitive": true,
                  "typeValidation": "strict"
                },
                "combinator": "and",
                "conditions": [
                  {
                    "id": "f818958c-837c-45f2-a7d5-4e2a4bd60566",
                    "operator": {
                      "type": "string",
                      "operation": "notEmpty",
                      "singleValue": true
                    },
                    "leftValue": "={{ $('Telegram Trigger').item.json.message.text }}",
                    "rightValue": ""
                  }
                ]
              },
              "renameOutput": true
            }
          ]
        },
        "options": {}
      },
      "typeVersion": 3.4
    },
    {
      "id": "cc14b083-4a14-4bf3-911c-9108376ff804",
      "name": "switchMaster",
      "type": "n8n-nodes-base.switch",
      "position": [
        2416,
        1360
      ],
      "parameters": {
        "rules": {
          "values": [
            {
              "outputKey": "Back Main Menu",
              "conditions": {
                "options": {
                  "version": 2,
                  "leftValue": "",
                  "caseSensitive": true,
                  "typeValidation": "strict"
                },
                "combinator": "and",
                "conditions": [
                  {
                    "id": "3b61cd09-0eaf-40de-8978-19a5aea68624",
                    "operator": {
                      "name": "filter.operator.equals",
                      "type": "string",
                      "operation": "equals"
                    },
                    "leftValue": "={{ $json.status }}",
                    "rightValue": "menu"
                  }
                ]
              },
              "renameOutput": true
            },
            {
              "outputKey": "Config",
              "conditions": {
                "options": {
                  "version": 2,
                  "leftValue": "",
                  "caseSensitive": true,
                  "typeValidation": "strict"
                },
                "combinator": "and",
                "conditions": [
                  {
                    "id": "94cac091-3130-44dc-8192-bf83bd25bc7f",
                    "operator": {
                      "name": "filter.operator.equals",
                      "type": "string",
                      "operation": "equals"
                    },
                    "leftValue": "={{ $json.status }}",
                    "rightValue": "config"
                  }
                ]
              },
              "renameOutput": true
            },
            {
              "outputKey": "Config Step 2 (Resolution)",
              "conditions": {
                "options": {
                  "version": 2,
                  "leftValue": "",
                  "caseSensitive": true,
                  "typeValidation": "strict"
                },
                "combinator": "and",
                "conditions": [
                  {
                    "id": "23bef492-a30e-4d65-85ed-58e811ecb941",
                    "operator": {
                      "name": "filter.operator.equals",
                      "type": "string",
                      "operation": "equals"
                    },
                    "leftValue": "={{ $json.status }}",
                    "rightValue": "configStep2"
                  }
                ]
              },
              "renameOutput": true
            },
            {
              "outputKey": "Config Step 3 (Prompt)",
              "conditions": {
                "options": {
                  "version": 2,
                  "leftValue": "",
                  "caseSensitive": true,
                  "typeValidation": "strict"
                },
                "combinator": "and",
                "conditions": [
                  {
                    "id": "d1bb84a6-3ded-4f69-96d0-e0830c551e27",
                    "operator": {
                      "name": "filter.operator.equals",
                      "type": "string",
                      "operation": "equals"
                    },
                    "leftValue": "={{ $json.status }}",
                    "rightValue": "configStep3"
                  }
                ]
              },
              "renameOutput": true
            },
            {
              "outputKey": "Config Step 3 Waiting (Prompt)",
              "conditions": {
                "options": {
                  "version": 2,
                  "leftValue": "",
                  "caseSensitive": true,
                  "typeValidation": "strict"
                },
                "combinator": "and",
                "conditions": [
                  {
                    "id": "b7ab0eda-a86a-4f68-8062-4cdd455021f8",
                    "operator": {
                      "name": "filter.operator.equals",
                      "type": "string",
                      "operation": "equals"
                    },
                    "leftValue": "={{ $json.status }}",
                    "rightValue": "configStep3_waiting"
                  }
                ]
              },
              "renameOutput": true
            },
            {
              "outputKey": "Config Done",
              "conditions": {
                "options": {
                  "version": 2,
                  "leftValue": "",
                  "caseSensitive": true,
                  "typeValidation": "strict"
                },
                "combinator": "and",
                "conditions": [
                  {
                    "id": "7892eebb-e13c-44c2-a166-3cfd64b702a3",
                    "operator": {
                      "name": "filter.operator.equals",
                      "type": "string",
                      "operation": "equals"
                    },
                    "leftValue": "={{ $json.status }}",
                    "rightValue": "configDone"
                  }
                ]
              },
              "renameOutput": true
            },
            {
              "outputKey": "Empty",
              "conditions": {
                "options": {
                  "version": 2,
                  "leftValue": "",
                  "caseSensitive": true,
                  "typeValidation": "strict"
                },
                "combinator": "and",
                "conditions": [
                  {
                    "id": "e1577ca2-685c-4c5f-b22b-5b12064da2b4",
                    "operator": {
                      "type": "string",
                      "operation": "empty",
                      "singleValue": true
                    },
                    "leftValue": "={{ $('getUser').item.json.status }}",
                    "rightValue": ""
                  }
                ]
              },
              "renameOutput": true
            },
            {
              "outputKey": "Generate Image",
              "conditions": {
                "options": {
                  "version": 2,
                  "leftValue": "",
                  "caseSensitive": true,
                  "typeValidation": "strict"
                },
                "combinator": "and",
                "conditions": [
                  {
                    "id": "5f8e9a30-ed44-44ed-87d5-a5bb0ca8bbd3",
                    "operator": {
                      "name": "filter.operator.equals",
                      "type": "string",
                      "operation": "equals"
                    },
                    "leftValue": "={{\n  $json.status || $('getUser').item.json.status\n}}",
                    "rightValue": "generate_image"
                  }
                ]
              },
              "renameOutput": true
            },
            {
              "outputKey": "Image to Video",
              "conditions": {
                "options": {
                  "version": 2,
                  "leftValue": "",
                  "caseSensitive": true,
                  "typeValidation": "strict"
                },
                "combinator": "and",
                "conditions": [
                  {
                    "id": "f92b00c1-d18d-4a5d-9929-f82d59938843",
                    "operator": {
                      "name": "filter.operator.equals",
                      "type": "string",
                      "operation": "equals"
                    },
                    "leftValue": "={{ $json.status }}",
                    "rightValue": "image_to_video"
                  }
                ]
              },
              "renameOutput": true
            },
            {
              "outputKey": "Image Edit",
              "conditions": {
                "options": {
                  "version": 2,
                  "leftValue": "",
                  "caseSensitive": true,
                  "typeValidation": "strict"
                },
                "combinator": "and",
                "conditions": [
                  {
                    "id": "7f6cb9a6-de64-4dbd-82b8-37c7385c1978",
                    "operator": {
                      "name": "filter.operator.equals",
                      "type": "string",
                      "operation": "equals"
                    },
                    "leftValue": "={{ $json.status }}",
                    "rightValue": "edit_image"
                  }
                ]
              },
              "renameOutput": true
            },
            {
              "outputKey": "Deposit",
              "conditions": {
                "options": {
                  "version": 2,
                  "leftValue": "",
                  "caseSensitive": true,
                  "typeValidation": "strict"
                },
                "combinator": "and",
                "conditions": [
                  {
                    "id": "9d6c2167-28b2-4d24-8717-b676ceae3b1d",
                    "operator": {
                      "name": "filter.operator.equals",
                      "type": "string",
                      "operation": "equals"
                    },
                    "leftValue": "={{ $json.status }}",
                    "rightValue": "deposit_credits"
                  }
                ]
              },
              "renameOutput": true
            }
          ]
        },
        "options": {}
      },
      "typeVersion": 3.3
    },
    {
      "id": "94fb7f83-68ab-4cd2-bd89-ab5368de6351",
      "name": "getUser",
      "type": "n8n-nodes-base.dataTable",
      "onError": "continueRegularOutput",
      "position": [
        16,
        1488
      ],
      "parameters": {
        "filters": {
          "conditions": [
            {
              "keyName": "chat_id",
              "keyValue": "={{    $('Telegram Trigger').item.json.callback_query?.message?.chat?.id    ||    $('Telegram Trigger').item.json.message?.chat?.id  }}"
            }
          ]
        },
        "operation": "get",
        "returnAll": true,
        "dataTableId": {
          "__rl": true,
          "mode": "id",
          "value": "={{ $json.dataTableId }}"
        }
      },
      "typeVersion": 1.1,
      "alwaysOutputData": true
    },
    {
      "id": "1198f205-dda6-4e4a-9d62-b1ed013c882f",
      "name": "updateUserFirstAccess",
      "type": "n8n-nodes-base.dataTable",
      "position": [
        3696,
        1632
      ],
      "parameters": {
        "columns": {
          "value": {
            "status": "menu",
            "chat_id": "={{ $('Telegram Trigger').item.json.message.chat.id }}",
            "credits": "={{ $('Global env').item.json.initialCredits }}",
            "resolution": "4k",
            "aspect_ratio": "16:9",
            "number_images": 0,
            "number_videos": 0
          },
          "schema": [
            {
              "id": "status",
              "type": "string",
              "display": true,
              "removed": false,
              "readOnly": false,
              "required": false,
              "displayName": "status",
              "defaultMatch": false
            },
            {
              "id": "number_images",
              "type": "number",
              "display": true,
              "removed": false,
              "readOnly": false,
              "required": false,
              "displayName": "number_images",
              "defaultMatch": false
            },
            {
              "id": "chat_id",
              "type": "string",
              "display": true,
              "removed": false,
              "readOnly": false,
              "required": false,
              "displayName": "chat_id",
              "defaultMatch": false
            },
            {
              "id": "number_videos",
              "type": "number",
              "display": true,
              "removed": false,
              "readOnly": false,
              "required": false,
              "displayName": "number_videos",
              "defaultMatch": false
            },
            {
              "id": "credits",
              "type": "string",
              "display": true,
              "removed": false,
              "readOnly": false,
              "required": false,
              "displayName": "credits",
              "defaultMatch": false
            },
            {
              "id": "demo_sended",
              "type": "boolean",
              "display": true,
              "removed": true,
              "readOnly": false,
              "required": false,
              "displayName": "demo_sended",
              "defaultMatch": false
            },
            {
              "id": "use_edit_demo_sended",
              "type": "boolean",
              "display": true,
              "removed": true,
              "readOnly": false,
              "required": false,
              "displayName": "use_edit_demo_sended",
              "defaultMatch": false
            },
            {
              "id": "resolution",
              "type": "string",
              "display": true,
              "removed": false,
              "readOnly": false,
              "required": false,
              "displayName": "resolution",
              "defaultMatch": false
            },
            {
              "id": "aspect_ratio",
              "type": "string",
              "display": true,
              "removed": false,
              "readOnly": false,
              "required": false,
              "displayName": "aspect_ratio",
              "defaultMatch": false
            }
          ],
          "mappingMode": "defineBelow",
          "matchingColumns": [],
          "attemptToConvertTypes": false,
          "convertFieldsToString": false
        },
        "filters": {
          "conditions": [
            {
              "keyName": "chat_id",
              "keyValue": "={{ $('Telegram Trigger').item.json.message.chat.id }}"
            }
          ]
        },
        "options": {},
        "operation": "upsert",
        "dataTableId": {
          "__rl": true,
          "mode": "id",
          "value": "={{ $('Global env').item.json.dataTableId }}"
        }
      },
      "typeVersion": 1.1
    },
    {
      "id": "2836e6cf-a5e4-4496-97a8-5687c1c6ffad",
      "name": "welcomeGenerateImage",
      "type": "n8n-nodes-base.telegram",
      "position": [
        3568,
        2064
      ],
      "webhookId": "YOUR_WEBHOOK_ID",
      "parameters": {
        "text": "=Write what you want me to generate — describe the scene, style, mood, or any idea you have in mind.\n\n⏳ Generation may take up to 1 minute, depending on current demand. Just sit back and relax.\n\n🔁 You can type back at any time to return to the menu.\n\n⚠️ Note: If an image is already being generated, it will stay in the queue and be delivered as soon as it’s ready — even if you go back to the menu.",
        "chatId": "={{ $('Telegram Trigger').item.json.callback_query?.message?.chat?.id ?? $('Telegram Trigger').item.json.message?.chat?.id }}",
        "additionalFields": {
          "appendAttribution": false
        }
      },
      "credentials": {
        "telegramApi": {
          "id": "credential-id",
          "name": "Imageon AI"
        }
      },
      "typeVersion": 1.2
    },
    {
      "id": "a56003eb-981a-41fa-a47f-4f11b9eba77d",
      "name": "sendForceReply",
      "type": "n8n-nodes-base.telegram",
      "position": [
        3744,
        2064
      ],
      "webhookId": "YOUR_WEBHOOK_ID",
      "parameters": {
        "text": "Now it’s your turn ✨",
        "chatId": "={{ $json.result.chat.id }}",
        "forceReply": {
          "force_reply": true
        },
        "replyMarkup": "forceReply",
        "additionalFields": {
          "appendAttribution": false
        }
      },
      "credentials": {
        "telegramApi": {
          "id": "credential-id",
          "name": "Imageon AI"
        }
      },
      "typeVersion": 1.2
    },
    {
      "id": "43631000-3f95-4414-badb-0e5f11c896a6",
      "name": "editImageOnReply",
      "type": "n8n-nodes-wavespeed.waveSpeedTaskSubmit",
      "position": [
        3968,
        2560
      ],
      "parameters": {
        "model": "google/nano-banana-pro/edit-ultra",
        "category": "image-to-image",
        "optionalParameters": {
          "value": {
            "resolution": "={{ $('getUser').item.json.resolution }}",
            "aspect_ratio": "={{ $('getUser').item.json.aspect_ratio }}",
            "output_format": "jpeg"
          },
          "schema": [
            {
              "id": "aspect_ratio",
              "type": "options",
              "display": true,
              "options": [
                {
                  "name": "1:1",
                  "value": "1:1",
                  "description": "1:1"
                },
                {
                  "name": "3:2",
                  "value": "3:2",
                  "description": "3:2"
                },
                {
                  "name": "2:3",
                  "value": "2:3",
                  "description": "2:3"
                },
                {
                  "name": "3:4",
                  "value": "3:4",
                  "description": "3:4"
                },
                {
                  "name": "4:3",
                  "value": "4:3",
                  "description": "4:3"
                },
                {
                  "name": "4:5",
                  "value": "4:5",
                  "description": "4:5"
                },
                {
                  "name": "5:4",
                  "value": "5:4",
                  "description": "5:4"
                },
                {
                  "name": "9:16",
                  "value": "9:16",
                  "description": "9:16"
                },
                {
                  "name": "16:9",
                  "value": "16:9",
                  "description": "16:9"
                },
                {
                  "name": "21:9",
                  "value": "21:9",
                  "description": "21:9"
                }
              ],
              "removed": false,
              "required": false,
              "displayName": "Aspect Ratio (OPTIONS)",
              "defaultMatch": false,
              "canBeUsedToMatch": false
            },
            {
              "id": "resolution",
              "type": "options",
              "display": true,
              "options": [
                {
                  "name": "4k",
                  "value": "4k",
                  "description": "4k"
                },
                {
                  "name": "8k",
                  "value": "8k",
                  "description": "8k"
                }
              ],
              "removed": false,
              "required": false,
              "displayName": "Resolution (OPTIONS) [Default: \"4k\"]",
              "defaultMatch": false,
              "canBeUsedToMatch": false
            },
            {
              "id": "output_format",
              "type": "options",
              "display": true,
              "options": [
                {
                  "name": "png",
                  "value": "png",
                  "description": "png"
                },
                {
                  "name": "jpeg",
                  "value": "jpeg",
                  "description": "jpeg"
                }
              ],
              "removed": false,
              "required": false,
              "displayName": "Output Format (OPTIONS) [Default: \"png\"]",
              "defaultMatch": false,
              "canBeUsedToMatch": false
            }
          ],
          "mappingMode": "defineBelow",
          "matchingColumns": [],
          "attemptToConvertTypes": false,
          "convertFieldsToString": false
        },
        "requiredParameters": {
          "value": {
            "images": "={{ $json.photo }}",
            "prompt": "={{ $json.message.caption }}"
          },
          "schema": [
            {
              "id": "prompt",
              "type": "string",
              "display": true,
              "removed": false,
              "required": true,
              "displayName": "Prompt (STRING) *",
              "defaultMatch": false,
              "canBeUsedToMatch": false
            },
            {
              "id": "images",
              "type": "string",
              "display": true,
              "removed": false,
              "required": true,
              "displayName": "Images (COLLECTION) *",
              "defaultMatch": false,
              "canBeUsedToMatch": false
            }
          ],
          "mappingMode": "defineBelow",
          "matchingColumns": [
            "prompt"
          ],
          "attemptToConvertTypes": false,
          "convertFieldsToString": false
        }
      },
      "credentials": {
        "wavespeedApi": {
          "id": "credential-id",
          "name": "WaveSpeed account"
        }
      },
      "typeVersion": 1
    },
    {
      "id": "831ae13f-35e6-4bd7-a512-6a30d18372ba",
      "name": "editFields",
      "type": "n8n-nodes-base.set",
      "position": [
        3808,
        2560
      ],
      "parameters": {
        "options": {},
        "assignments": {
          "assignments": [
            {
              "id": "144f4c93-64c0-420e-ba08-5b1784e86069",
              "name": "=photo",
              "type": "string",
              "value": "={{\n  (() => {\n    const images = [];\n\n    const msg = $('Telegram Trigger').item.json.message;\n\n    const photos =\n      msg?.reply_to_message?.photo\n      ??\n      msg?.photo;\n\n    if (photos?.length) {\n      const lastPhoto = photos[photos.length - 1];\n\n      images.push(\n        `https://s3.doras.space/api/v1/buckets/${$('Global env').item.json.bucketName}/objects/download?preview=true&prefix=${lastPhoto.file_unique_id}.jpg&version_id=null`\n      );\n    }\n\n    const logo = $('Global env').item.json.logoOrWatermarkUrl;\n    if (logo) images.push(logo);\n\n    return images;\n  })()\n}}"
            },
            {
              "id": "ea324856-3bb8-4ca4-9de4-1a63ac95e28b",
              "name": "message.caption",
              "type": "string",
              "value": "={{\n  (() => {\n    const msg = $('Telegram Trigger').item.json.message;\n\n\n    const userText = msg?.caption || msg?.text || '';\n\n    const userDefaultPrompt = $('getUser').item.json.user_default_prompt;\n    const globalDefaultPrompt = $('Global env').item.json.defaultEditPrompt;\n\n\n    const defaultPrompt = globalDefaultPrompt || userDefaultPrompt || '';\n\n\n    if (userText && defaultPrompt) {\n      return `${userText}\\n\\n${defaultPrompt}`;\n    }\n\n    return userText || defaultPrompt || '';\n  })()\n}}"
            }
          ]
        }
      },
      "typeVersion": 3.4
    },
    {
      "id": "a5de6b2f-e73e-4732-b36b-9ab64d927c3d",
      "name": "messageType",
      "type": "n8n-nodes-base.switch",
      "position": [
        192,
        1472
      ],
      "parameters": {
        "rules": {
          "values": [
            {
              "outputKey": "Image + Caption",
              "conditions": {
                "options": {
                  "version": 2,
                  "leftValue": "",
                  "caseSensitive": true,
                  "typeValidation": "strict"
                },
                "combinator": "and",
                "conditions": [
                  {
                    "id": "img-caption-1",
                    "operator": {
                      "type": "array",
                      "operation": "exists",
                      "singleValue": true
                    },
                    "leftValue": "={{ $('Telegram Trigger').item.json.message.photo }}",
                    "rightValue": ""
                  },
                  {
                    "id": "img-caption-2",
                    "operator": {
                      "type": "object",
                      "operation": "notExists",
                      "singleValue": true
                    },
                    "leftValue": "={{ $('Telegram Trigger').item.json.message.reply_to_message }}",
                    "rightValue": ""
                  }
                ]
              },
              "renameOutput": true
            },
            {
              "outputKey": "Reply + Image",
              "conditions": {
                "options": {
                  "version": 2,
                  "leftValue": "",
                  "caseSensitive": true,
                  "typeValidation": "strict"
                },
                "combinator": "and",
                "conditions": [
                  {
                    "id": "reply-img-1",
                    "operator": {
                      "type": "object",
                      "operation": "exists",
                      "singleValue": true
                    },
                    "leftValue": "={{ $('Telegram Trigger').item.json.message.reply_to_message }}",
                    "rightValue": ""
                  },
                  {
                    "id": "reply-img-2",
                    "operator": {
                      "type": "array",
                      "operation": "exists",
                      "singleValue": true
                    },
                    "leftValue": "={{ $('Telegram Trigger').item.json.message.reply_to_message.photo }}",
                    "rightValue": ""
                  }
                ]
              },
              "renameOutput": true
            },
            {
              "outputKey": "No Image",
              "conditions": {
                "options": {
                  "version": 2,
                  "leftValue": "",
                  "caseSensitive": true,
                  "typeValidation": "strict"
                },
                "combinator": "and",
                "conditions": [
                  {
                    "id": "sem-img-1",
                    "operator": {
                      "type": "array",
                      "operation": "notExists",
                      "singleValue": true
                    },
                    "leftValue": "={{ $('Telegram Trigger').item.json.message.photo }}",
                    "rightValue": ""
                  },
                  {
                    "id": "sem-img-2",
                    "operator": {
                      "type": "array",
                      "operation": "notExists",
                      "singleValue": true
                    },
                    "leftValue": "={{ $('Telegram Trigger').item.json.message.reply_to_message.photo }}",
                    "rightValue": ""
                  }
                ]
              },
              "renameOutput": true
            }
          ]
        },
        "options": {
          "fallbackOutput": "none"
        }
      },
      "typeVersion": 3.2
    },
    {
      "id": "85f8a46f-497a-4270-b3b5-b72ef2bb0420",
      "name": "getFilePath",
      "type": "n8n-nodes-base.httpRequest",
      "position": [
        576,
        1408
      ],
      "parameters": {
        "url": "=https://api.telegram.org/bot{{ $('Global env').item.json.botToken }}/getFile",
        "method": "POST",
        "options": {},
        "jsonBody": "={{ \n  JSON.stringify({\n    file_id: (() => {\n      const replyPhotos = $('Telegram Trigger').item.json.message?.reply_to_message?.photo;\n      const photos = $('Telegram Trigger').item.json.message?.photo;\n\n      const arr = replyPhotos?.length ? replyPhotos : photos;\n      return arr?.[arr.length - 1]?.file_id;\n    })()\n  })\n}}",
        "sendBody": true,
        "specifyBody": "json"
      },
      "typeVersion": 4.2
    },
    {
      "id": "6da6b769-4605-447b-be30-430a6d913f8e",
      "name": "downloadImage",
      "type": "n8n-nodes-base.httpRequest",
      "position": [
        752,
        1408
      ],
      "parameters": {
        "url": "=https://api.telegram.org/file/bot{{ $('Global env').item.json.botToken }}/{{ $json.result.file_path }}",
        "options": {
          "response": {
            "response": {
              "responseFormat": "file"
            }
          }
        }
      },
      "typeVersion": 4.2
    },
    {
      "id": "4a714f2d-88f9-4701-a3c6-1dd3e5058e92",
      "name": "uploadS3",
      "type": "n8n-nodes-base.s3",
      "position": [
        944,
        1408
      ],
      "parameters": {
        "fileName": "={{\n  (() => {\n    const photos =\n      $('Telegram Trigger').item.json.message?.reply_to_message?.photo\n      ??\n      $('Telegram Trigger').item.json.message?.photo;\n\n    return photos?.length\n      ? photos[photos.length - 1].file_unique_id + '.jpg'\n      : undefined;\n  })()\n}}",
        "operation": "upload",
        "bucketName": "={{ $('Global env').item.json.bucketName }}",
        "additionalFields": {}
      },
      "credentials": {
        "s3": {
          "id": "credential-id",
          "name": "MiniO"
        }
      },
      "typeVersion": 1
    },
    {
      "id": "1439660e-9eed-4318-a165-a9369d0b2168",
      "name": "swtichW/WOCallback",
      "type": "n8n-nodes-base.switch",
      "position": [
        1232,
        1504
      ],
      "parameters": {
        "rules": {
          "values": [
            {
              "outputKey": "W/o Callback",
              "conditions": {
                "options": {
                  "version": 3,
                  "leftValue": "",
                  "caseSensitive": true,
                  "typeValidation": "strict"
                },
                "combinator": "and",
                "conditions": [
                  {
                    "id": "234dfd45-657f-41fb-ab15-11d6514dd5b9",
                    "operator": {
                      "type": "boolean",
                      "operation": "true",
                      "singleValue": true
                    },
                    "leftValue": "={{\n  (\n    !$('Telegram Trigger').item.json.callback_query &&\n    !$('Telegram Trigger').item.json.message?.photo &&\n    $('Telegram Trigger').item.json.message?.chat?.type !== 'group'\n  ).toBoolean()\n}}",
                    "rightValue": "true"
                  }
                ]
              },
              "renameOutput": true
            },
            {
              "outputKey": "W Callback",
              "conditions": {
                "options": {
                  "version": 3,
                  "leftValue": "",
                  "caseSensitive": true,
                  "typeValidation": "strict"
                },
                "combinator": "and",
                "conditions": [
                  {
                    "id": "21088171-90a7-438c-b354-4800bc1e5bd4",
                    "operator": {
                      "type": "object",
                      "operation": "exists",
                      "singleValue": true
                    },
                    "leftValue": "={{ $('Telegram Trigger').item.json.callback_query }}",
                    "rightValue": ""
                  }
                ]
              },
              "renameOutput": true
            },
            {
              "outputKey": "Photo Array",
              "conditions": {
                "options": {
                  "version": 3,
                  "leftValue": "",
                  "caseSensitive": true,
                  "typeValidation": "strict"
                },
                "combinator": "and",
                "conditions": [
                  {
                    "id": "caa44b46-52d6-4dac-b8ec-e383de4ce47e",
                    "operator": {
                      "type": "array",
                      "operation": "exists",
                      "singleValue": true
                    },
                    "leftValue": "={{ $('Telegram Trigger').item.json.message.photo }}",
                    "rightValue": ""
                  }
                ]
              },
              "renameOutput": true
            }
          ]
        },
        "options": {}
      },
      "typeVersion": 3.4
    },
    {
      "id": "eb4fa5c0-1936-4415-8e01-d704c2223d78",
      "name": "upsertUserStatus",
      "type": "n8n-nodes-base.dataTable",
      "position": [
        1584,
        1536
      ],
      "parameters": {
        "columns": {
          "value": {
            "status": "={{ \n  (() => {\n    const cb = $('Telegram Trigger').item.json.callback_query?.data;\n    const usersPromptConfig = $('Global env').item.json.usersPromptConfig;\n\n    // aspect ratio selection\n    if (['1:1','3:4','9:16','16:9','21:9'].includes(cb)) {\n      return 'configStep2';\n    }\n\n    // resolution selection\n    if (['4k','8k'].includes(cb)) {\n      return usersPromptConfig === true\n        ? 'configStep3'\n        : 'configDone';\n    }\n\n    // if callback exists (imagem, vídeo, menu, etc)\n    if (cb) {\n      return cb;\n    }\n\n    // if NO callback -> keep current user status\n    return $('getUser').item.json.status;\n  })()\n}}",
            "resolution": "={{ \n  ['4k','8k']\n    .includes($('Telegram Trigger').item.json.callback_query?.data)\n    ? $('Telegram Trigger').item.json.callback_query.data\n    : $('getUser').item.json.resolution\n}}",
            "aspect_ratio": "={{ \n  ['1:1','3:4','9:16','16:9','21:9']\n    .includes($('Telegram Trigger').item.json.callback_query?.data)\n    ? $('Telegram Trigger').item.json.callback_query.data\n    : $('getUser').item.json.aspect_ratio\n}}"
          },
          "schema": [
            {
              "id": "status",
              "type": "string",
              "display": true,
              "removed": false,
              "readOnly": false,
              "required": false,
              "displayName": "status",
              "defaultMatch": false
            },
            {
              "id": "number_images",
              "type": "number",
              "display": true,
              "removed": true,
              "readOnly": false,
              "required": false,
              "displayName": "number_images",
              "defaultMatch": false
            },
            {
              "id": "chat_id",
              "type": "string",
              "display": true,
              "removed": true,
              "readOnly": false,
              "required": false,
              "displayName": "chat_id",
              "defaultMatch": false
            },
            {
              "id": "number_videos",
              "type": "number",
              "display": true,
              "removed": true,
              "readOnly": false,
              "required": false,
              "displayName": "number_videos",
              "defaultMatch": false
            },
            {
              "id": "credits",
              "type": "string",
              "display": true,
              "removed": true,
              "readOnly": false,
              "required": false,
              "displayName": "credits",
              "defaultMatch": false
            },
            {
              "id": "demo_sended",
              "type": "boolean",
              "display": true,
              "removed": true,
              "readOnly": false,
              "required": false,
              "displayName": "demo_sended",
              "defaultMatch": false
            },
            {
              "id": "use_edit_demo_sended",
              "type": "boolean",
              "display": true,
              "removed": true,
              "readOnly": false,
              "required": false,
              "displayName": "use_edit_demo_sended",
              "defaultMatch": false
            },
            {
              "id": "resolution",
              "type": "string",
              "display": true,
              "removed": false,
              "readOnly": false,
              "required": false,
              "displayName": "resolution",
              "defaultMatch": false
            },
            {
              "id": "aspect_ratio",
              "type": "string",
              "display": true,
              "removed": false,
              "readOnly": false,
              "required": false,
              "displayName": "aspect_ratio",
              "defaultMatch": false
            }
          ],
          "mappingMode": "defineBelow",
          "matchingColumns": [],
          "attemptToConvertTypes": false,
          "convertFieldsToString": false
        },
        "filters": {
          "conditions": [
            {
              "keyName": "chat_id",
              "keyValue": "={{ \n  $('Telegram Trigger').item.json.callback_query?.message?.chat?.id \n  || \n  $('Telegram Trigger').item.json.message?.chat?.id \n}}"
            }
          ]
        },
        "options": {},
        "matchType": "allConditions",
        "operation": "upsert",
        "dataTableId": {
          "__rl": true,
          "mode": "id",
          "value": "={{ $('Global env').item.json.dataTableId }}"
        }
      },
      "typeVersion": 1
    },
    {
      "id": "38462bcc-770e-4ed6-8083-21fe05e1f82b",
      "name": "messageTypeGenerateImage",
      "type": "n8n-nodes-base.switch",
      "position": [
        3200,
        2032
      ],
      "parameters": {
        "rules": {
          "values": [
            {
              "outputKey": "Reply + Text",
              "conditions": {
                "options": {
                  "version": 2,
                  "leftValue": "",
                  "caseSensitive": true,
                  "typeValidation": "strict"
                },
                "combinator": "and",
                "conditions": [
                  {
                    "id": "43aa9489-25ab-4318-a955-6cafd8a5daa0",
                    "operator": {
                      "type": "object",
                      "operation": "exists",
                      "singleValue": true
                    },
                    "leftValue": "={{ $('Telegram Trigger').item.json.message.reply_to_message }}",
                    "rightValue": ""
                  },
                  {
                    "id": "47daa9ce-481b-4f1d-a12b-9371d55ac29a",
                    "operator": {
                      "type": "array",
                      "operation": "notExists",
                      "singleValue": true
                    },
                    "leftValue": "={{ $('Telegram Trigger').item.json.message.reply_to_message.photo }}",
                    "rightValue": ""
                  }
                ]
              },
              "renameOutput": true
            },
            {
              "outputKey": "Welcome",
              "conditions": {
                "options": {
                  "version": 2,
                  "leftValue": "",
                  "caseSensitive": true,
                  "typeValidation": "strict"
                },
                "combinator": "and",
                "conditions": [
                  {
                    "id": "6d519428-7451-4266-804b-77ea5233c255",
                    "operator": {
                      "type": "object",
                      "operation": "exists",
                      "singleValue": true
                    },
                    "leftValue": "={{ $('Telegram Trigger').item.json.callback_query }}",
                    "rightValue": ""
                  }
                ]
              },
              "renameOutput": true
            },
            {
              "outputKey": "Reply + Image",
              "conditions": {
                "options": {
                  "version": 2,
                  "leftValue": "",
                  "caseSensitive": true,
                  "typeValidation": "strict"
                },
                "combinator": "and",
                "conditions": [
                  {
                    "id": "f90a27bd-06db-4e91-bcdc-f9462e1a6d2d",
                    "operator": {
                      "type": "object",
                      "operation": "exists",
                      "singleValue": true
                    },
                    "leftValue": "={{ $('Telegram Trigger').item.json.message.reply_to_message }}",
                    "rightValue": ""
                  },
                  {
                    "id": "02682dc1-c8ab-402c-9599-18a747a32b79",
                    "operator": {
                      "type": "array",
                      "operation": "exists",
                      "singleValue": true
                    },
                    "leftValue": "={{ $('Telegram Trigger').item.json.message.reply_to_message.photo }}",
                    "rightValue": ""
                  }
                ]
              },
              "renameOutput": true
            },
            {
              "outputKey": "Text Prompt",
              "conditions": {
                "options": {
                  "version": 2,
                  "leftValue": "",
                  "caseSensitive": true,
                  "typeValidation": "strict"
                },
                "combinator": "and",
                "conditions": [
                  {
                    "id": "2cda27f8-aaaf-4896-82c0-243733f7110d",
                    "operator": {
                      "type": "boolean",
                      "operation": "false",
                      "singleValue": true
                    },
                    "leftValue": "={{\n  !!$('Telegram Trigger').item.json.message?.text\n  &&\n  $('getUser').item.json.status !== 'generate_image'\n}}",
                    "rightValue": ""
                  }
                ]
              },
              "renameOutput": true
            }
          ]
        },
        "options": {
          "fallbackOutput": "none"
        }
      },
      "typeVersion": 3.2
    },
    {
      "id": "ae77ab85-73bf-4c4b-a48e-2ab590873315",
      "name": "ifImage+Caption",
      "type": "n8n-nodes-base.if",
      "position": [
        3296,
        2912
      ],
      "parameters": {
        "options": {},
        "conditions": {
          "options": {
            "version": 3,
            "leftValue": "",
            "caseSensitive": true,
            "typeValidation": "strict"
          },
          "combinator": "and",
          "conditions": [
            {
              "id": "28334d2d-8edc-40aa-a964-5abfa264f970",
              "operator": {
                "type": "array",
                "operation": "exists",
                "singleValue": true
              },
              "leftValue": "={{ $('Telegram Trigger').item.json.message.photo }}",
              "rightValue": ""
            }
          ]
        }
      },
      "typeVersion": 2.3
    },
    {
      "id": "69c12a5e-fa8e-4567-a24b-42b5a1857f0f",
      "name": "ifCreditsEnough",
      "type": "n8n-nodes-base.if",
      "position": [
        3568,
        2256
      ],
      "parameters": {
        "options": {},
        "conditions": {
          "options": {
            "version": 3,
            "leftValue": "",
            "caseSensitive": true,
            "typeValidation": "strict"
          },
          "combinator": "and",
          "conditions": [
            {
              "id": "9e1f3a5b-f95a-41d4-b121-d5d534e80fdc",
              "operator": {
                "type": "boolean",
                "operation": "true",
                "singleValue": true
              },
              "leftValue": "={{\n  (() => {\n    const resolution = $('getUser').item.json.resolution;\n    const credits = Number($('getUser').item.json.credits) || 0;\n\n    const cost4k = Number($('Global env').item.json.generateImageCost4k) || 0;\n    const cost8k = Number($('Global env').item.json.generateImageCost8k) || 0;\n\n    const cost =\n      resolution === '8k'\n        ? cost8k\n        : cost4k; // default 4k\n\n    return credits >= cost;\n  })()\n}}",
              "rightValue": 0
            }
          ]
        }
      },
      "typeVersion": 2.3
    },
    {
      "id": "e48fc944-5ff5-47f9-987b-4915a4fd88a6",
      "name": "ifCreditsEnough1",
      "type": "n8n-nodes-base.if",
      "position": [
        3568,
        1904
      ],
      "parameters": {
        "options": {},
        "conditions": {
          "options": {
            "version": 3,
            "leftValue": "",
            "caseSensitive": true,
            "typeValidation": "strict"
          },
          "combinator": "and",
          "conditions": [
            {
              "id": "9e1f3a5b-f95a-41d4-b121-d5d534e80fdc",
              "operator": {
                "type": "boolean",
                "operation": "true",
                "singleValue": true
              },
              "leftValue": "={{\n  (() => {\n    const resolution = $('getUser').item.json.resolution;\n    const credits = Number($('getUser').item.json.credits) || 0;\n\n    const cost4k = Number($('Global env').item.json.generateImageCost4k) || 0;\n    const cost8k = Number($('Global env').item.json.generateImageCost8k) || 0;\n\n    const cost =\n      resolution === '8k'\n        ? cost8k\n        : cost4k; // default 4k\n\n    return credits >= cost;\n  })()\n}}",
              "rightValue": 0
            }
          ]
        }
      },
      "typeVersion": 2.3
    },
    {
      "id": "a10ec164-c1d4-4b39-af37-0c01a3c1265d",
      "name": "ifCreditsEnough2",
      "type": "n8n-nodes-base.if",
      "position": [
        3520,
        2800
      ],
      "parameters": {
        "options": {},
        "conditions": {
          "options": {
            "version": 3,
            "leftValue": "",
            "caseSensitive": true,
            "typeValidation": "strict"
          },
          "combinator": "and",
          "conditions": [
            {
              "id": "9e1f3a5b-f95a-41d4-b121-d5d534e80fdc",
              "operator": {
                "type": "boolean",
                "operation": "true",
                "singleValue": true
              },
              "leftValue": "={{\n  (() => {\n    const resolution = $('getUser').item.json.resolution;\n    const credits = Number($('getUser').item.json.credits) || 0;\n\n    const cost4k = Number($('Global env').item.json.generateImageCost4k) || 0;\n    const cost8k = Number($('Global env').item.json.generateImageCost8k) || 0;\n\n    const cost =\n      resolution === '8k'\n        ? cost8k\n        : cost4k; // default 4k\n\n    return credits >= cost;\n  })()\n}}",
              "rightValue": 0
            }
          ]
        }
      },
      "typeVersion": 2.3
    },
    {
      "id": "40c0f57f-6b3f-44f4-8481-83326f257d5f",
      "name": "welcomeImageEdit",
      "type": "n8n-nodes-base.telegram",
      "position": [
        3520,
        2992
      ],
      "webhookId": "YOUR_WEBHOOK_ID",
      "parameters": {
        "text": "=Send the photo you want to edit 🖼️\nAdd a short caption describing what you want to change.\n\n✍️ Keep it clear and objective:\n\nStyle\n\nDetails to modify\n\nMood or effect\n\nThe caption will be used as the edit prompt.\nWhen you’re ready, just send the image 🚀\n\n🔁 You can type <code>menu</code> anytime to return to the menu, or <code>config</code> to change settings.",
        "chatId": "={{ $('Telegram Trigger').item.json.callback_query?.message?.chat?.id ?? $('Telegram Trigger').item.json.message?.chat?.id }}",
        "additionalFields": {
          "parse_mode": "HTML",
          "appendAttribution": false
        }
      },
      "credentials": {
        "telegramApi": {
          "id": "credential-id",
          "name": "Imageon AI"
        }
      },
      "typeVersion": 1.2
    },
    {
      "id": "5bf442a7-52ae-4fb1-9917-8dd2b854c20f",
      "name": "promptConfig",
      "type": "n8n-nodes-base.telegram",
      "position": [
        3504,
        896
      ],
      "webhookId": "YOUR_WEBHOOK_ID",
      "parameters": {
        "text": "=🍌 Nano Banana — Default Prompt\n\nThe default prompt is automatically added to all your generations.\n\n📝 **Current prompt:**\n{{ $('getUser').item.json.user_default_prompt ? $('getUser').item.json.user_default_prompt : '_None defined_' }}\n\nChoose an option 👇",
        "chatId": "={{ $('getUser').item.json.chat_id }}",
        "replyMarkup": "inlineKeyboard",
        "inlineKeyboard": {
          "rows": [
            {
              "row": {
                "buttons": [
                  {
                    "text": "✏️ Set new",
                    "additionalFields": {
                      "callback_data": "prompt_set"
                    }
                  },
                  {
                    "text": "🗑️ Remove",
                    "additionalFields": {
                      "callback_data": "prompt_clear"
                    }
                  }
                ]
              }
            },
            {
              "row": {
                "buttons": [
                  {
                    "text": "⏭️ Skip (keep current)",
                    "additionalFields": {
                      "callback_data": "prompt_skip"
                    }
                  }
                ]
              }
            }
          ]
        },
        "additionalFields": {
          "parse_mode": "Markdown",
          "appendAttribution": false
        }
      },
      "credentials": {
        "telegramApi": {
          "id": "credential-id",
          "name": "Imageon AI"
        }
      },
      "typeVersion": 1.2
    },
    {
      "id": "0982447c-cadf-420f-a3f8-2ebea3f3047b",
      "name": "switchPromptAction",
      "type": "n8n-nodes-base.switch",
      "position": [
        3696,
        880
      ],
      "parameters": {
        "rules": {
          "values": [
            {
              "outputKey": "Set Prompt",
              "conditions": {
                "options": {
                  "version": 2,
                  "leftValue": "",
                  "caseSensitive": true,
                  "typeValidation": "strict"
                },
                "combinator": "and",
                "conditions": [
                  {
                    "id": "prompt-set",
                    "operator": {
                      "type": "string",
                      "operation": "equals"
                    },
                    "leftValue": "={{ $('Telegram Trigger').item.json.callback_query.data }}",
                    "rightValue": "prompt_set"
                  }
                ]
              },
              "renameOutput": true
            },
            {
              "outputKey": "Clear Prompt",
              "conditions": {
                "options": {
                  "version": 2,
                  "leftValue": "",
                  "caseSensitive": true,
                  "typeValidation": "strict"
                },
                "combinator": "and",
                "conditions": [
                  {
                    "id": "prompt-clear",
                    "operator": {
                      "type": "string",
                      "operation": "equals"
                    },
                    "leftValue": "={{ $('Telegram Trigger').item.json.callback_query.data }}",
                    "rightValue": "prompt_clear"
                  }
                ]
              },
              "renameOutput": true
            },
            {
              "outputKey": "Skip Prompt",
              "conditions": {
                "options": {
                  "version": 2,
                  "leftValue": "",
                  "caseSensitive": true,
                  "typeValidation": "strict"
                },
                "combinator": "and",
                "conditions": [
                  {
                    "id": "prompt-skip",
                    "operator": {
                      "type": "string",
                      "operation": "equals"
                    },
                    "leftValue": "={{ $('Telegram Trigger').item.json.callback_query.data }}",
                    "rightValue": "prompt_skip"
                  }
                ]
              },
              "renameOutput": true
            }
          ]
        },
        "options": {
          "fallbackOutput": "none"
        }
      },
      "typeVersion": 3.3
    },
    {
      "id": "2bc86d67-a373-405f-8bd7-080091a72234",
      "name": "upsertStatusWaitingPrompt",
      "type": "n8n-nodes-base.dataTable",
      "position": [
        3904,
        720
      ],
      "parameters": {
        "columns": {
          "value": {
            "status": "configStep3_waiting"
          },
          "schema": [
            {
              "id": "status",
              "type": "string",
              "display": true,
              "removed": false,
              "readOnly": false,
              "required": false,
              "displayName": "status",
              "defaultMatch": false
            }
          ],
          "mappingMode": "defineBelow",
          "matchingColumns": []
        },
        "filters": {
          "conditions": [
            {
              "keyName": "chat_id",
              "keyValue": "={{ $('getUser').item.json.chat_id }}"
            }
          ]
        },
        "options": {},
        "matchType": "allConditions",
        "operation": "upsert",
        "dataTableId": {
          "__rl": true,
          "mode": "id",
          "value": "={{ $('Global env').item.json.dataTableId }}"
        }
      },
      "typeVersion": 1
    },
    {
      "id": "c13adfad-21b1-4fb6-a0b2-c1b1597d5e0a",
      "name": "upsertClearPrompt",
      "type": "n8n-nodes-base.dataTable",
      "position": [
        3904,
        896
      ],
      "parameters": {
        "columns": {
          "value": {
            "status": "configDone"
          },
          "schema": [
            {
              "id": "status",
              "type": "string",
              "display": true,
              "removed": false,
              "readOnly": false,
              "required": false,
              "displayName": "status",
              "defaultMatch": false
            },
            {
              "id": "user_default_prompt",
              "type": "string",
              "display": true,
              "removed": false,
              "readOnly": false,
              "required": false,
              "displayName": "user_default_prompt",
              "defaultMatch": false
            }
          ],
          "mappingMode": "defineBelow",
          "matchingColumns": [],
          "attemptToConvertTypes": false,
          "convertFieldsToString": false
        },
        "filters": {
          "conditions": [
            {
              "keyName": "chat_id",
              "keyValue": "={{ $('getUser').item.json.chat_id }}"
            }
          ]
        },
        "options": {},
        "matchType": "allConditions",
        "operation": "upsert",
        "dataTableId": {
          "__rl": true,
          "mode": "id",
          "value": "={{ $('Global env').item.json.dataTableId }}"
        }
      },
      "typeVersion": 1
    },
    {
      "id": "dbc8e5f1-cb22-4bc5-9196-416f0a8bc0e4",
      "name": "upsertSkipPrompt",
      "type": "n8n-nodes-base.dataTable",
      "position": [
        3904,
        1040
      ],
      "parameters": {
        "columns": {
          "value": {
            "status": "configDone"
          },
          "schema": [
            {
              "id": "status",
              "type": "string",
              "display": true,
              "removed": false,
              "readOnly": false,
              "required": false,
              "displayName": "status",
              "defaultMatch": false
            }
          ],
          "mappingMode": "defineBelow",
          "matchingColumns": []
        },
        "filters": {
          "conditions": [
            {
              "keyName": "chat_id",
              "keyValue": "={{ $('getUser').item.json.chat_id }}"
            }
          ]
        },
        "options": {},
        "matchType": "allConditions",
        "operation": "upsert",
        "dataTableId": {
          "__rl": true,
          "mode": "id",
          "value": "={{ $('Global env').item.json.dataTableId }}"
        }
      },
      "typeVersion": 1
    },
    {
      "id": "9e87c754-9fb8-48a8-a25b-bdb7d0726a02",
      "name": "askPromptInput1",
      "type": "n8n-nodes-base.telegram",
      "position": [
        4080,
        720
      ],
      "webhookId": "YOUR_WEBHOOK_ID",
      "parameters": {
        "text": "=**Default Prompt**\n\nThe default prompt is automatically added to all your generations.\n\n📝 **Current prompt:**\n{{ $('getUser').item.json.user_default_prompt ? $('getUser').item.json.user_default_prompt : '_None defined_' }}\n\n💡 **Example:**\n_\"4k, high quality, cinematic lighting, detailed, masterpiece\"_",
        "chatId": "={{ $('getUser').item.json.chat_id }}",
        "additionalFields": {}
      },
      "credentials": {
        "telegramApi": {
          "id": "credential-id",
          "name": "Imageon AI"
        }
      },
      "typeVersion": 1.2
    },
    {
      "id": "d864a052-7088-4b07-b0a4-bf5952e83772",
      "name": "upsertSavePrompt1",
      "type": "n8n-nodes-base.dataTable",
      "position": [
        3504,
        1168
      ],
      "parameters": {
        "columns": {
          "value": {
            "status": "={{ \n  (() => {\n    const text = $('Telegram Trigger').item.json.message?.text;\n\n    // if no text or empty -> keep current status\n    if (!text || !text.trim()) {\n      return 'configStep3_waiting';\n    }\n\n    // if text exists -> finish configuration\n    return 'configDone';\n  })()\n}}",
            "user_default_prompt": "={{ $('Telegram Trigger').item.json.message.text }}"
          },
          "schema": [
            {
              "id": "status",
              "type": "string",
              "display": true,
              "removed": false,
              "readOnly": false,
              "required": false,
              "displayName": "status",
              "defaultMatch": false
            },
            {
              "id": "user_default_prompt",
              "type": "string",
              "display": true,
              "removed": false,
              "readOnly": false,
              "required": false,
              "displayName": "user_default_prompt",
              "defaultMatch": false
            }
          ],
          "mappingMode": "defineBelow",
          "matchingColumns": [],
          "attemptToConvertTypes": false,
          "convertFieldsToString": false
        },
        "filters": {
          "conditions": [
            {
              "keyName": "chat_id",
              "keyValue": "={{ $('getUser').item.json.chat_id }}"
            }
          ]
        },
        "options": {},
        "matchType": "allConditions",
        "operation": "upsert",
        "dataTableId": {
          "__rl": true,
          "mode": "id",
          "value": "={{ $('Global env').item.json.dataTableId }}"
        }
      },
      "typeVersion": 1
    },
    {
      "id": "51179467-d4b3-4e80-9217-1daae48b7a7f",
      "name": "confirmPromptSaved1",
      "type": "n8n-nodes-base.telegram",
      "position": [
        3680,
        1168
      ],
      "webhookId": "YOUR_WEBHOOK_ID",
      "parameters": {
        "text": "={{ \n  (() => {\n    const prompt = $('Telegram Trigger').item.json.message?.text;\n\n    if (!prompt || !prompt.trim()) {\n      return '⚠️ Prompt not set.\\nNo custom prompt was provided. The default prompt will be used.';\n    }\n\n    return `✅ Prompt configured successfully!\\n\\n📝 Your prompt:\\n\"${prompt}\"`;\n  })()\n}}\n",
        "chatId": "={{ $('getUser').item.json.chat_id }}",
        "additionalFields": {
          "parse_mode": "Markdown",
          "appendAttribution": false
        }
      },
      "credentials": {
        "telegramApi": {
          "id": "credential-id",
          "name": "Imageon AI"
        }
      },
      "typeVersion": 1.2
    },
    {
      "id": "e50ab3cf-67fe-4f94-a8f1-125c1542db48",
      "name": "menuOptions",
      "type": "n8n-nodes-base.telegram",
      "position": [
        3504,
        384
      ],
      "webhookId": "YOUR_WEBHOOK_ID",
      "parameters": {
        "text": "=🔙 Back to Main Menu\n\nYou’re back at the main menu.\nChoose an option below to continue 👇",
        "chatId": "={{ $('getUser').item.json.chat_id }}",
        "replyMarkup": "inlineKeyboard",
        "inlineKeyboard": {
          "rows": [
            {
              "row": {
                "buttons": [
                  {
                    "text": "Generate Image",
                    "additionalFields": {
                      "callback_data": "generate_image"
                    }
                  },
                  {
                    "text": "Edit Image",
                    "additionalFields": {
                      "callback_data": "edit_image"
                    }
                  }
                ]
              }
            },
            {
              "row": {
                "buttons": [
                  {
                    "text": "Deposit Credits",
                    "additionalFields": {
                      "pay": true,
                      "callback_data": "deposit_credits"
                    }
                  }
                ]
              }
            }
          ]
        },
        "additionalFields": {
          "appendAttribution": false
        }
      },
      "credentials": {
        "telegramApi": {
          "id": "credential-id",
          "name": "Imageon AI"
        }
      },
      "typeVersion": 1.2
    },
    {
      "id": "4ab2222d-185d-4cbf-bbf3-e435c5e92ec6",
      "name": "sendDepositOptions",
      "type": "n8n-nodes-base.telegram",
      "position": [
        3520,
        3264
      ],
      "webhookId": "YOUR_WEBHOOK_ID",
      "parameters": {
        "text": "=You’re in the deposit menu — just choose an amount to continue.",
        "chatId": "={{ $('getUser').item.json.chat_id }}",
        "replyMarkup": "inlineKeyboard",
        "inlineKeyboard": {
          "rows": [
            {
              "row": {
                "buttons": [
                  {
                    "text": "R$ 3,00",
                    "additionalFields": {
                      "callback_data": "deposit_3"
                    }
                  },
                  {
                    "text": "R$ 6,00",
                    "additionalFields": {
                      "callback_data": "deposit_6"
                    }
                  },
                  {
                    "text": "R$ 10,00",
                    "additionalFields": {
                      "callback_data": "deposit_10"
                    }
                  }
                ]
              }
            }
          ]
        },
        "additionalFields": {
          "appendAttribution": false
        }
      },
      "credentials": {
        "telegramApi": {
          "id": "credential-id",
          "name": "Imageon AI"
        }
      },
      "typeVersion": 1.2
    },
    {
      "id": "876b1dde-9f37-4c40-ac7b-d297bcc03b87",
      "name": "switchDeposit",
      "type": "n8n-nodes-base.switch",
      "position": [
        3232,
        3616
      ],
      "parameters": {
        "rules": {
          "values": [
            {
              "conditions": {
                "options": {
                  "version": 3,
                  "leftValue": "",
                  "caseSensitive": true,
                  "typeValidation": "strict"
                },
                "combinator": "and",
                "conditions": [
                  {
                    "id": "6c633024-2289-48fd-a3fc-f16d952931c3",
                    "operator": {
                      "type": "string",
                      "operation": "equals"
                    },
                    "leftValue": "={{ $json.status }}",
                    "rightValue": "deposit_3"
                  }
                ]
              }
            },
            {
              "conditions": {
                "options": {
                  "version": 3,
                  "leftValue": "",
                  "caseSensitive": true,
                  "typeValidation": "strict"
                },
                "combinator": "and",
                "conditions": [
                  {
                    "id": "0c9730b2-352f-4ee2-9d73-b3e81232a4f6",
                    "operator": {
                      "name": "filter.operator.equals",
                      "type": "string",
                      "operation": "equals"
                    },
                    "leftValue": "={{ $json.status }}",
                    "rightValue": "deposit_6"
                  }
                ]
              }
            },
            {
              "conditions": {
                "options": {
                  "version": 3,
                  "leftValue": "",
                  "caseSensitive": true,
                  "typeValidation": "strict"
                },
                "combinator": "and",
                "conditions": [
                  {
                    "id": "2440304c-6421-4d48-abca-c2cd35256f1b",
                    "operator": {
                      "name": "filter.operator.equals",
                      "type": "string",
                      "operation": "equals"
                    },
                    "leftValue": "={{ $json.status }}",
                    "rightValue": "deposit_10"
                  }
                ]
              }
            }
          ]
        },
        "options": {}
      },
      "typeVersion": 3.4
    },
    {
      "id": "06a9d328-6d1e-4ade-b345-c2e75e1845b8",
      "name": "getPaymentStatus",
      "type": "n8n-nodes-base.httpRequest",
      "position": [
        3632,
        4368
      ],
      "parameters": {
        "url": "=https://api.mercadopago.com/v1/payments/{{ $('paymentStatus').item.json.query.id || $('paymentStatus').item.json.query['data.id'] }}",
        "options": {},
        "sendHeaders": true,
        "headerParameters": {
          "parameters": [
            {
              "name": "Authorization",
              "value": "="
            }
          ]
        }
      },
      "typeVersion": 4.2
    },
    {
      "id": "69573f42-bb8a-4c64-838b-da505002ab87",
      "name": "paymentStatus",
      "type": "n8n-nodes-base.webhook",
      "position": [
        3152,
        4368
      ],
      "webhookId": "YOUR_WEBHOOK_ID",
      "parameters": {
        "path": "your-webhook-path",
        "options": {},
        "httpMethod": "POST"
      },
      "typeVersion": 2.1
    },
    {
      "id": "0603e82c-ff45-4d11-940a-851ec41e6910",
      "name": "sendOptionsAfterPayment",
      "type": "n8n-nodes-base.telegram",
      "position": [
        5440,
        4288
      ],
      "webhookId": "YOUR_WEBHOOK_ID",
      "parameters": {
        "text": "=Please select one of the options below to continue 👇\n\nJust tap a button to proceed 🚀",
        "chatId": "={{ $json.result.chat.id }}",
        "replyMarkup": "inlineKeyboard",
        "inlineKeyboard": {
          "rows": [
            {
              "row": {
                "buttons": [
                  {
                    "text": "Generate Image",
                    "additionalFields": {
                      "callback_data": "generate_image"
                    }
                  },
                  {
                    "text": "Edit Image",
                    "additionalFields": {
                      "callback_data": "edit_image"
                    }
                  }
                ]
              }
            },
            {
              "row": {
                "buttons": [
                  {
                    "text": "Deposit Credits",
                    "additionalFields": {
                      "callback_data": "deposti_credits"
                    }
                  }
                ]
              }
            }
          ]
        },
        "additionalFields": {
          "appendAttribution": false
        }
      },
      "credentials": {
        "telegramApi": {
          "id": "credential-id",
          "name": "Telegram Loja"
        }
      },
      "typeVersion": 1.2
    },
    {
      "id": "5e2d51ff-9a72-4138-9245-497f3f8d9eff",
      "name": "Credit System",
      "type": "n8n-nodes-base.stickyNote",
      "position": [
        5872,
        1664
      ],
      "parameters": {
        "color": 7,
        "width": 400,
        "height": 196,
        "content": "💳 **Credit System**\n\nUsers get initial credits, deducted on generation. Failed tasks refund credits automatically."
      },
      "typeVersion": 1
    },
    {
      "id": "d50f4328-d259-4bf1-8679-d5342e4077a3",
      "name": "Payment Integration",
      "type": "n8n-nodes-base.stickyNote",
      "position": [
        2672,
        4320
      ],
      "parameters": {
        "color": 7,
        "width": 400,
        "height": 180,
        "content": "💰 **PIX Payment**\n\nBrazilian instant payment via Mercado Pago API. Handles QR code generation and webhook confirmations."
      },
      "typeVersion": 1
    },
    {
      "id": "9f9087d6-a185-4e77-a4f8-7365daad9d7a",
      "name": "S3 Storage",
      "type": "n8n-nodes-base.stickyNote",
      "position": [
        512,
        1216
      ],
      "parameters": {
        "color": 7,
        "width": 590,
        "height": 342,
        "content": "📦 **S3 Storage**\n\nStores uploaded images for AI editing. Compatible with AWS S3 or MinIO."
      },
      "typeVersion": 1
    },
    {
      "id": "28ec08ce-a14f-41e3-9067-c91b66091b13",
      "name": "WaveSpeed API",
      "type": "n8n-nodes-base.stickyNote",
      "position": [
        4640,
        1824
      ],
      "parameters": {
        "color": 7,
        "width": 350,
        "content": "🎨 **WaveSpeed API**\n\nAI image generation and editing. Models: nano-banana-pro for text-to-image and edit-ultra."
      },
      "typeVersion": 1
    },
    {
      "id": "eda4d3a6-f16f-4c24-a0b3-f47497bdd94b",
      "name": "User Status Flow",
      "type": "n8n-nodes-base.stickyNote",
      "position": [
        1456,
        1040
      ],
      "parameters": {
        "color": 7,
        "width": 350,
        "height": 678,
        "content": "🔄 **User Status**\n\nTracks user state: menu, config steps, generate_image, edit_image, deposit_credits."
      },
      "typeVersion": 1
    },
    {
      "id": "aad174dd-7a64-4591-a33d-0c70b011c4c2",
      "name": "depositCredentials",
      "type": "n8n-nodes-base.set",
      "position": [
        3824,
        3632
      ],
      "parameters": {
        "options": {},
        "assignments": {
          "assignments": [
            {
              "id": "4ed3cf60-f355-420c-bd51-a9702c2ca8af",
              "name": "public_Key",
              "type": "string",
              "value": ""
            },
            {
              "id": "0d690fec-4b00-4e32-9139-a08613f1feea",
              "name": "access_token",
              "type": "string",
              "value": ""
            },
            {
              "id": "7096c8a6-86dc-40ed-8a4f-c923b6d328b8",
              "name": "preco",
              "type": "string",
              "value": "={{ $json.preco }}"
            },
            {
              "id": "f54fdb6d-6a82-4880-a7de-488b7b3c9d2a",
              "name": "external_reference",
              "type": "string",
              "value": "={{\n  'CLIENTE' +\n  $('getUser').item.json.chat_id +\n  '-' +\n  Math.floor(1000 + Math.random() * 9000)\n}}"
            },
            {
              "id": "e8f040ed-27d4-475e-936a-342ec94fa21b",
              "name": "description",
              "type": "string",
              "value": "Platform Credits"
            },
            {
              "id": "997c1ae6-d834-4cf0-9175-412188f7ba75",
              "name": "notification_url",
              "type": "string",
              "value": "YOUR_NOTIFICATION_URL"
            },
            {
              "id": "66c0761c-9aec-4133-9f7d-f84aea6055bc",
              "name": "cpf",
              "type": "string",
              "value": "+1234567890"
            },
            {
              "id": "8ff6529a-bb30-4951-8295-aa5303058867",
              "name": "email_cliente",
              "type": "string",
              "value": "user@example.com"
            }
          ]
        }
      },
      "typeVersion": 3.4
    },
    {
      "id": "bc1bd2ae-8435-4a8a-8b02-829da1dd90e4",
      "name": "checkIfDepositInProgress",
      "type": "n8n-nodes-base.if",
      "position": [
        2864,
        3616
      ],
      "parameters": {
        "options": {},
        "conditions": {
          "options": {
            "version": 3,
            "leftValue": "",
            "caseSensitive": true,
            "typeValidation": "strict"
          },
          "combinator": "and",
          "conditions": [
            {
              "id": "e0489959-9f99-4d46-96ea-6a8cf824e6dd",
              "operator": {
                "type": "boolean",
                "operation": "true",
                "singleValue": true
              },
              "leftValue": "={{ ['deposit_3', 'deposit_6', 'deposit_10'].includes($('getUser').item.json.status) }}",
              "rightValue": ""
            }
          ]
        }
      },
      "typeVersion": 2.3
    },
    {
      "id": "ad028d5f-ed6a-4335-8b28-d3ad36ac726c",
      "name": "setDepositAmount3",
      "type": "n8n-nodes-base.set",
      "position": [
        3520,
        3472
      ],
      "parameters": {
        "options": {},
        "assignments": {
          "assignments": [
            {
              "id": "9017b02a-cfd5-4513-a959-e57c231826fc",
              "name": "preco",
              "type": "string",
              "value": "3"
            }
          ]
        }
      },
      "typeVersion": 3.4
    },
    {
      "id": "fb51fd41-0ec0-4061-85fa-2b6bd5c01402",
      "name": "setDepositAmount6",
      "type": "n8n-nodes-base.set",
      "position": [
        3520,
        3632
      ],
      "parameters": {
        "options": {},
        "assignments": {
          "assignments": [
            {
              "id": "9017b02a-cfd5-4513-a959-e57c231826fc",
              "name": "preco",
              "type": "string",
              "value": "6"
            }
          ]
        }
      },
      "typeVersion": 3.4
    },
    {
      "id": "c89674b2-63a5-42e1-89f9-0986c8112848",
      "name": "setDepositAmount10",
      "type": "n8n-nodes-base.set",
      "position": [
        3520,
        3792
      ],
      "parameters": {
        "options": {},
        "assignments": {
          "assignments": [
            {
              "id": "9017b02a-cfd5-4513-a959-e57c231826fc",
              "name": "preco",
              "type": "string",
              "value": "10"
            }
          ]
        }
      },
      "typeVersion": 3.4
    },
    {
      "id": "5a33cfc1-bde7-46b6-a257-901dfde2a875",
      "name": "insertPaymentRow",
      "type": "n8n-nodes-base.dataTable",
      "position": [
        4000,
        3632
      ],
      "parameters": {
        "columns": {
          "value": {
            "amount": "={{ $json.preco }}",
            "status": "=pending",
            "chat_id": "={{ $('getUser').item.json.chat_id }}",
            "reference": "={{ $('depositCredentials').item.json.external_reference }}"
          },
          "schema": [
            {
              "id": "chat_id",
              "type": "string",
              "display": true,
              "removed": false,
              "readOnly": false,
              "required": false,
              "displayName": "chat_id",
              "defaultMatch": false
            },
            {
              "id": "status",
              "type": "string",
              "display": true,
              "removed": false,
              "readOnly": false,
              "required": false,
              "displayName": "status",
              "defaultMatch": false
            },
            {
              "id": "amount",
              "type": "number",
              "display": true,
              "removed": false,
              "readOnly": false,
              "required": false,
              "displayName": "amount",
              "defaultMatch": false
            },
            {
              "id": "reference",
              "type": "string",
              "display": true,
              "removed": false,
              "readOnly": false,
              "required": false,
              "displayName": "reference",
              "defaultMatch": false
            }
          ],
          "mappingMode": "defineBelow",
          "matchingColumns": [],
          "attemptToConvertTypes": false,
          "convertFieldsToString": false
        },
        "options": {},
        "dataTableId": {
          "__rl": true,
          "mode": "id",
          "value": "={{ $('Global env').item.json.paymentDataTableId }}"
        }
      },
      "typeVersion": 1.1
    },
    {
      "id": "e06e19e3-e5d9-499e-9c81-580a46479b2a",
      "name": "apiMercadoPago",
      "type": "n8n-nodes-base.httpRequest",
      "position": [
        4176,
        3632
      ],
      "parameters": {
        "url": "https://api.mercadopago.com/v1/payments",
        "method": "POST",
        "options": {},
        "jsonBody": "={\n   \"description\": \"{{ $('depositCredentials').item.json.description }}\",\n   \"external_reference\": \"{{ $('depositCredentials').item.json.external_reference }}\",\n   \"notification_url\": \"{{ $('depositCredentials').item.json.notification_url }}\",\n   \"payer\": {\n      \"email\": \"{{ $('depositCredentials').item.json.email_cliente }}\",\n            \"identification\": {\n            \"type\": \"CPF\",\n            \"number\": \"{{ $('depositCredentials').item.json.cpf }}\"\n            }\n   },\n   \"payment_method_id\": \"pix\",\n   \"transaction_amount\": {{ $('depositCredentials').item.json.preco }}\n}",
        "sendBody": true,
        "sendHeaders": true,
        "specifyBody": "json",
        "headerParameters": {
          "parameters": [
            {
              "name": "Authorization",
              "value": "=Bearer {{ $('depositCredentials').item.json.access_token }}"
            },
            {
              "name": "X-Idempotency-Key",
              "value": "={{ $('depositCredentials').item.json.external_reference }}"
            }
          ]
        }
      },
      "typeVersion": 4.2
    },
    {
      "id": "6b94130a-4004-4bef-ba20-a3ccbd546279",
      "name": "getPix",
      "type": "n8n-nodes-base.set",
      "position": [
        4352,
        3632
      ],
      "parameters": {
        "options": {},
        "assignments": {
          "assignments": [
            {
              "id": "d5ca2013-0b0e-4c78-ae7b-6749c5801f33",
              "name": "pix_url",
              "type": "string",
              "value": "={{ $json.point_of_interaction.transaction_data.qr_code }}"
            },
            {
              "id": "5a1ac43e-3672-47d3-aba9-e3527cd2588a",
              "name": "pix_base64",
              "type": "string",
              "value": "={{ $json.point_of_interaction.transaction_data.qr_code_base64 }}"
            },
            {
              "id": "3cb127f5-1e7d-4034-afcf-220696f5d59f",
              "name": "id_transacao",
              "type": "string",
              "value": "={{ $json.id }}"
            }
          ]
        }
      },
      "typeVersion": 3.4
    },
    {
      "id": "69581bfe-525a-4352-a39c-d543b555f894",
      "name": "pix_baseToFile",
      "type": "n8n-nodes-base.convertToFile",
      "position": [
        4528,
        3632
      ],
      "parameters": {
        "options": {},
        "operation": "toBinary",
        "sourceProperty": "pix_base64"
      },
      "typeVersion": 1.1
    },
    {
      "id": "ac42cbcd-3a7e-4057-9b9f-56922004feac",
      "name": "sendPixQRCode",
      "type": "n8n-nodes-base.telegram",
      "position": [
        4720,
        3632
      ],
      "webhookId": "YOUR_WEBHOOK_ID",
      "parameters": {
        "chatId": "={{ $('getUser').item.json.chat_id }}",
        "operation": "sendPhoto",
        "binaryData": true,
        "additionalFields": {
          "caption": "=<pre>{{ $('getPix').item.json.pix_url }}</pre>",
          "parse_mode": "HTML"
        }
      },
      "credentials": {
        "telegramApi": {
          "id": "credential-id",
          "name": "Imageon AI"
        }
      },
      "typeVersion": 1.2
    },
    {
      "id": "0562e39a-5c7b-4936-890e-8824aee868d0",
      "name": "sendPixText",
      "type": "n8n-nodes-base.telegram",
      "position": [
        4912,
        3632
      ],
      "webhookId": "YOUR_WEBHOOK_ID",
      "parameters": {
        "text": "=Please complete the payment by scanning the QR code above or by using the Copy & Paste code. 😊",
        "chatId": "={{ $('getUser').item.json.chat_id }}",
        "additionalFields": {
          "appendAttribution": false
        }
      },
      "credentials": {
        "telegramApi": {
          "id": "credential-id",
          "name": "Imageon AI"
        }
      },
      "typeVersion": 1.2
    },
    {
      "id": "18a66f7a-3668-41af-996e-2f88d564b3d0",
      "name": "raceConditionDelay",
      "type": "n8n-nodes-base.wait",
      "position": [
        3392,
        4368
      ],
      "webhookId": "YOUR_WEBHOOK_ID",
      "parameters": {
        "amount": "={{ Math.floor(Math.random() * 4) + 1 }}"
      },
      "typeVersion": 1.1
    },
    {
      "id": "ebc30f66-1cef-4687-8423-f0ea6e1d56fd",
      "name": "Race Condition Info",
      "type": "n8n-nodes-base.stickyNote",
      "position": [
        3280,
        4160
      ],
      "parameters": {
        "color": 7,
        "width": 320,
        "height": 374,
        "content": "🕒 **Race Condition Protection**\n\nRandom delay (1-4s) prevents conflicts from simultaneous webhook executions."
      },
      "typeVersion": 1
    },
    {
      "id": "f7f89a80-9cdb-4010-a276-7fb975fe922f",
      "name": "switchForPaymentStatus",
      "type": "n8n-nodes-base.switch",
      "position": [
        4048,
        4352
      ],
      "parameters": {
        "rules": {
          "values": [
            {
              "outputKey": "Approved",
              "conditions": {
                "options": {
                  "version": 2,
                  "leftValue": "",
                  "caseSensitive": true,
                  "typeValidation": "strict"
                },
                "combinator": "and",
                "conditions": [
                  {
                    "id": "6f67c3f2-80f4-4939-8e5c-6aa784acb336",
                    "operator": {
                      "type": "string",
                      "operation": "equals"
                    },
                    "leftValue": "={{ $('getPaymentStatus').item.json.status }}",
                    "rightValue": "approved"
                  }
                ]
              },
              "renameOutput": true
            },
            {
              "outputKey": "Pending",
              "conditions": {
                "options": {
                  "version": 2,
                  "leftValue": "",
                  "caseSensitive": true,
                  "typeValidation": "strict"
                },
                "combinator": "and",
                "conditions": [
                  {
                    "id": "+1234567890c2-b571-8e270aab83f3",
                    "operator": {
                      "name": "filter.operator.equals",
                      "type": "string",
                      "operation": "equals"
                    },
                    "leftValue": "={{ $('getPaymentStatus').item.json.status }}",
                    "rightValue": "pending"
                  }
                ]
              },
              "renameOutput": true
            },
            {
              "outputKey": "Rejected",
              "conditions": {
                "options": {
                  "version": 2,
                  "leftValue": "",
                  "caseSensitive": true,
                  "typeValidation": "strict"
                },
                "combinator": "and",
                "conditions": [
                  {
                    "id": "bd96ecde-4b9a-4d59-99e7-b38992c8c46d",
                    "operator": {
                      "name": "filter.operator.equals",
                      "type": "string",
                      "operation": "equals"
                    },
                    "leftValue": "={{ $('getPaymentStatus').item.json.status }}",
                    "rightValue": "rejected"
                  }
                ]
              },
              "renameOutput": true
            }
          ]
        },
        "options": {}
      },
      "typeVersion": 3.2
    },
    {
      "id": "cf96bc91-684e-497a-a3cb-dcc1c1d4cc25",
      "name": "checkIfPaymentPending",
      "type": "n8n-nodes-base.if",
      "position": [
        4272,
        4208
      ],
      "parameters": {
        "options": {},
        "conditions": {
          "options": {
            "version": 3,
            "leftValue": "",
            "caseSensitive": true,
            "typeValidation": "strict"
          },
          "combinator": "and",
          "conditions": [
            {
              "id": "c2a0cf89-9d33-431b-8e2e-42834a0737ca",
              "operator": {
                "name": "filter.operator.equals",
                "type": "string",
                "operation": "equals"
              },
              "leftValue": "={{ $('getPaymentStatusRow').item.json.status }}",
              "rightValue": "pending"
            }
          ]
        }
      },
      "typeVersion": 2.3
    },
    {
      "id": "62b67941-b7af-48d3-99eb-c2ab2d7c2392",
      "name": "fetchPaymentRecord",
      "type": "n8n-nodes-base.dataTable",
      "position": [
        3808,
        4368
      ],
      "parameters": {
        "filters": {
          "conditions": [
            {
              "keyName": "reference",
              "keyValue": "={{ $json.external_reference }}"
            }
          ]
        },
        "operation": "get",
        "dataTableId": {
          "__rl": true,
          "mode": "id",
          "value": "=SsrqjZWPYOVsFA2Q"
        }
      },
      "typeVersion": 1.1
    },
    {
      "id": "1edc889b-2c31-4b7e-ac62-6d7c81dcf308",
      "name": "Pending Payment Validation",
      "type": "n8n-nodes-base.stickyNote",
      "position": [
        4128,
        3984
      ],
      "parameters": {
        "color": 7,
        "width": 320,
        "height": 150,
        "content": "✅ **Payment Validation**\n\nChecks if payment reference exists before processing webhook to avoid duplicates."
      },
      "typeVersion": 1
    },
    {
      "id": "ba8908dd-5c60-49bd-86f4-590a3bc79d1b",
      "name": "upsertPaymentStatus",
      "type": "n8n-nodes-base.dataTable",
      "position": [
        4560,
        4064
      ],
      "parameters": {
        "columns": {
          "value": {
            "status": "approved"
          },
          "schema": [
            {
              "id": "chat_id",
              "type": "string",
              "display": true,
              "removed": true,
              "readOnly": false,
              "required": false,
              "displayName": "chat_id",
              "defaultMatch": false
            },
            {
              "id": "status",
              "type": "string",
              "display": true,
              "removed": false,
              "readOnly": false,
              "required": false,
              "displayName": "status",
              "defaultMatch": false
            },
            {
              "id": "amount",
              "type": "number",
              "display": true,
              "removed": true,
              "readOnly": false,
              "required": false,
              "displayName": "amount",
              "defaultMatch": false
            },
            {
              "id": "reference",
              "type": "string",
              "display": true,
              "removed": true,
              "readOnly": false,
              "required": false,
              "displayName": "reference",
              "defaultMatch": false
            }
          ],
          "mappingMode": "defineBelow",
          "matchingColumns": [],
          "attemptToConvertTypes": false,
          "convertFieldsToString": false
        },
        "filters": {
          "conditions": [
            {
              "keyName": "reference",
              "keyValue": "={{ $json.reference }}"
            }
          ]
        },
        "options": {},
        "operation": "upsert",
        "dataTableId": {
          "__rl": true,
          "mode": "id",
          "value": "SsrqjZWPYOVsFA2Q"
        }
      },
      "typeVersion": 1.1
    },
    {
      "id": "a5b74f85-20f1-42eb-b1f7-2666526eb94d",
      "name": "getUserAfterPayment",
      "type": "n8n-nodes-base.dataTable",
      "position": [
        4736,
        4064
      ],
      "parameters": {
        "filters": {
          "conditions": [
            {
              "keyName": "chat_id",
              "keyValue": "={{ $json.chat_id }}"
            }
          ]
        },
        "operation": "get",
        "dataTableId": {
          "__rl": true,
          "mode": "id",
          "value": "SsrqjZWPYOVsFA2Q"
        }
      },
      "typeVersion": 1.1
    },
    {
      "id": "9ef4ef75-6d0a-4048-97c9-8a366e2976df",
      "name": "updateUserCreditsAfterPayment",
      "type": "n8n-nodes-base.dataTable",
      "position": [
        4912,
        4064
      ],
      "parameters": {
        "columns": {
          "value": {
            "status": "menu",
            "credits": "={{ \n  (Number($json.credits) || 0) + \n  (Number($('getPaymentStatus').item.json.transaction_details.total_paid_amount) || 0) \n}}"
          },
          "schema": [
            {
              "id": "status",
              "type": "string",
              "display": true,
              "removed": false,
              "readOnly": false,
              "required": false,
              "displayName": "status",
              "defaultMatch": false
            },
            {
              "id": "number_images",
              "type": "number",
              "display": true,
              "removed": true,
              "readOnly": false,
              "required": false,
              "displayName": "number_images",
              "defaultMatch": false
            },
            {
              "id": "chat_id",
              "type": "string",
              "display": true,
              "removed": true,
              "readOnly": false,
              "required": false,
              "displayName": "chat_id",
              "defaultMatch": false
            },
            {
              "id": "number_videos",
              "type": "number",
              "display": true,
              "removed": true,
              "readOnly": false,
              "required": false,
              "displayName": "number_videos",
              "defaultMatch": false
            },
            {
              "id": "credits",
              "type": "string",
              "display": true,
              "removed": false,
              "readOnly": false,
              "required": false,
              "displayName": "credits",
              "defaultMatch": false
            },
            {
              "id": "demo_sended",
              "type": "boolean",
              "display": true,
              "removed": true,
              "readOnly": false,
              "required": false,
              "displayName": "demo_sended",
              "defaultMatch": false
            },
            {
              "id": "use_edit_demo_sended",
              "type": "boolean",
              "display": true,
              "removed": true,
              "readOnly": false,
              "required": false,
              "displayName": "use_edit_demo_sended",
              "defaultMatch": false
            },
            {
              "id": "resolution",
              "type": "string",
              "display": true,
              "removed": true,
              "readOnly": false,
              "required": false,
              "displayName": "resolution",
              "defaultMatch": false
            },
            {
              "id": "aspect_ratio",
              "type": "string",
              "display": true,
              "removed": true,
              "readOnly": false,
              "required": false,
              "displayName": "aspect_ratio",
              "defaultMatch": false
            },
            {
              "id": "user_default_prompt",
              "type": "string",
              "display": true,
              "removed": true,
              "readOnly": false,
              "required": false,
              "displayName": "user_default_prompt",
              "defaultMatch": false
            },
            {
              "id": "user_logo",
              "type": "string",
              "display": true,
              "removed": true,
              "readOnly": false,
              "required": false,
              "displayName": "user_logo",
              "defaultMatch": false
            }
          ],
          "mappingMode": "defineBelow",
          "matchingColumns": [],
          "attemptToConvertTypes": false,
          "convertFieldsToString": false
        },
        "filters": {
          "conditions": [
            {
              "keyName": "chat_id",
              "keyValue": "={{ $json.chat_id }}"
            }
          ]
        },
        "options": {},
        "operation": "upsert",
        "dataTableId": {
          "__rl": true,
          "mode": "id",
          "value": "=SsrqjZWPYOVsFA2Q"
        }
      },
      "typeVersion": 1.1
    },
    {
      "id": "4b05c0ed-3122-4669-af95-7514dd0a9c1e",
      "name": "paymentConfirmedText",
      "type": "n8n-nodes-base.telegram",
      "position": [
        5120,
        4064
      ],
      "webhookId": "YOUR_WEBHOOK_ID",
      "parameters": {
        "text": "=✅ Payment Confirmed!\n\nWe’ve successfully identified your payment of R$ {{\n(Number($('getPaymentStatus').item.json.transaction_details.total_paid_amount) || 0)\n.toFixed(2)\n.replace('.', ',')\n}}.\n\n✨ Your current credit balance is now R$ {{\n(Number($json.credits) || 0)\n.toFixed(2)\n.replace('.', ',')\n}}.\n\nYou can now start using your credits right away 🚀",
        "chatId": "={{ $json.chat_id }}",
        "additionalFields": {
          "appendAttribution": false
        }
      },
      "credentials": {
        "telegramApi": {
          "id": "credential-id",
          "name": "Telegram Loja"
        }
      },
      "typeVersion": 1.2
    },
    {
      "id": "7a390020-bd98-435d-929f-3f5196e667f5",
      "name": "updateUserStatusAfterDecline",
      "type": "n8n-nodes-base.dataTable",
      "position": [
        4736,
        4480
      ],
      "parameters": {
        "columns": {
          "value": {
            "status": "menu"
          },
          "schema": [
            {
              "id": "status",
              "type": "string",
              "display": true,
              "removed": false,
              "readOnly": false,
              "required": false,
              "displayName": "status",
              "defaultMatch": false
            },
            {
              "id": "number_images",
              "type": "number",
              "display": true,
              "removed": true,
              "readOnly": false,
              "required": false,
              "displayName": "number_images",
              "defaultMatch": false
            },
            {
              "id": "chat_id",
              "type": "string",
              "display": true,
              "removed": true,
              "readOnly": false,
              "required": false,
              "displayName": "chat_id",
              "defaultMatch": false
            },
            {
              "id": "number_videos",
              "type": "number",
              "display": true,
              "removed": true,
              "readOnly": false,
              "required": false,
              "displayName": "number_videos",
              "defaultMatch": false
            },
            {
              "id": "credits",
              "type": "string",
              "display": true,
              "removed": true,
              "readOnly": false,
              "required": false,
              "displayName": "credits",
              "defaultMatch": false
            },
            {
              "id": "demo_sended",
              "type": "boolean",
              "display": true,
              "removed": true,
              "readOnly": false,
              "required": false,
              "displayName": "demo_sended",
              "defaultMatch": false
            },
            {
              "id": "use_edit_demo_sended",
              "type": "boolean",
              "display": true,
              "removed": true,
              "readOnly": false,
              "required": false,
              "displayName": "use_edit_demo_sended",
              "defaultMatch": false
            },
            {
              "id": "resolution",
              "type": "string",
              "display": true,
              "removed": true,
              "readOnly": false,
              "required": false,
              "displayName": "resolution",
              "defaultMatch": false
            },
            {
              "id": "aspect_ratio",
              "type": "string",
              "display": true,
              "removed": true,
              "readOnly": false,
              "required": false,
              "displayName": "aspect_ratio",
              "defaultMatch": false
            },
            {
              "id": "user_default_prompt",
              "type": "string",
              "display": true,
              "removed": true,
              "readOnly": false,
              "required": false,
              "displayName": "user_default_prompt",
              "defaultMatch": false
            },
            {
              "id": "user_logo",
              "type": "string",
              "display": true,
              "removed": true,
              "readOnly": false,
              "required": false,
              "displayName": "user_logo",
              "defaultMatch": false
            }
          ],
          "mappingMode": "defineBelow",
          "matchingColumns": [],
          "attemptToConvertTypes": false,
          "convertFieldsToString": false
        },
        "filters": {
          "conditions": [
            {
              "keyName": "chat_id",
              "keyValue": "={{ $('getFieldsChatId').item.json.chat_id }}"
            }
          ]
        },
        "options": {},
        "operation": "upsert",
        "dataTableId": {
          "__rl": true,
          "mode": "id",
          "value": "=SsrqjZWPYOVsFA2Q"
        }
      },
      "typeVersion": 1.1
    },
    {
      "id": "436d40b4-47e2-4511-9e4d-d9acfac87791",
      "name": "getUserAfterDecline",
      "type": "n8n-nodes-base.dataTable",
      "position": [
        4528,
        4480
      ],
      "parameters": {
        "filters": {
          "conditions": [
            {
              "keyName": "chat_id",
              "keyValue": "={{ $json.chat_id }}"
            }
          ]
        },
        "operation": "get",
        "dataTableId": {
          "__rl": true,
          "mode": "id",
          "value": "=SsrqjZWPYOVsFA2Q"
        }
      },
      "typeVersion": 1.1
    },
    {
      "id": "155d46e1-f926-4a68-beb1-06ffe6ffa6ed",
      "name": "paymentDeclinedText",
      "type": "n8n-nodes-base.telegram",
      "position": [
        5120,
        4480
      ],
      "webhookId": "YOUR_WEBHOOK_ID",
      "parameters": {
        "text": "=It seems your payment was declined. Don’t worry — you can try again.",
        "chatId": "={{ $('getFieldsChatId').item.json.chat_id }}",
        "additionalFields": {
          "appendAttribution": false
        }
      },
      "credentials": {
        "telegramApi": {
          "id": "credential-id",
          "name": "Telegram Loja"
        }
      },
      "typeVersion": 1.2
    },
    {
      "id": "63407d87-7b6a-4004-a017-b6bb012caa56",
      "name": "qrCodePaymentInProgress",
      "type": "n8n-nodes-base.telegram",
      "position": [
        3088,
        3456
      ],
      "webhookId": "YOUR_WEBHOOK_ID",
      "parameters": {
        "text": "=You already have a QR code awaiting payment — just complete it to continue 😊",
        "chatId": "={{ $('getUser').item.json.chat_id }}",
        "additionalFields": {
          "appendAttribution": false
        }
      },
      "credentials": {
        "telegramApi": {
          "id": "credential-id",
          "name": "Imageon AI"
        }
      },
      "typeVersion": 1.2
    },
    {
      "id": "4316f05d-bdfc-4913-9ced-861522ba62d2",
      "name": "updateCreditsSendedTask",
      "type": "n8n-nodes-base.dataTable",
      "position": [
        4640,
        2016
      ],
      "parameters": {
        "columns": {
          "value": {
            "credits": "={{\n  Number($('getUser').item.json.credits)\n  -\n  (\n    $('getUser').item.json.resolution === '4k'\n      ? Number($('Global env').item.json.generateImageCost4k)\n      : Number($('Global env').item.json.generateImageCost8k)\n  )\n}}"
          },
          "schema": [
            {
              "id": "status",
              "type": "string",
              "display": true,
              "removed": true,
              "readOnly": false,
              "required": false,
              "displayName": "status",
              "defaultMatch": false
            },
            {
              "id": "number_images",
              "type": "number",
              "display": true,
              "removed": true,
              "readOnly": false,
              "required": false,
              "displayName": "number_images",
              "defaultMatch": false
            },
            {
              "id": "username",
              "type": "string",
              "display": true,
              "removed": true,
              "readOnly": false,
              "required": false,
              "displayName": "username",
              "defaultMatch": false
            },
            {
              "id": "number_videos",
              "type": "number",
              "display": true,
              "removed": true,
              "readOnly": false,
              "required": false,
              "displayName": "number_videos",
              "defaultMatch": false
            },
            {
              "id": "credits",
              "type": "string",
              "display": true,
              "removed": false,
              "readOnly": false,
              "required": false,
              "displayName": "credits",
              "defaultMatch": false
            },
            {
              "id": "demo_sended",
              "type": "boolean",
              "display": true,
              "removed": true,
              "readOnly": false,
              "required": false,
              "displayName": "demo_sended",
              "defaultMatch": false
            }
          ],
          "mappingMode": "defineBelow",
          "matchingColumns": [],
          "attemptToConvertTypes": false,
          "convertFieldsToString": false
        },
        "filters": {
          "conditions": [
            {
              "keyName": "chat_id",
              "keyValue": "={{ $('getUser').item.json.chat_id }}"
            }
          ]
        },
        "options": {},
        "operation": "update",
        "dataTableId": {
          "__rl": true,
          "mode": "id",
          "value": "={{ $('Global env').item.json.dataTableId }}"
        }
      },
      "typeVersion": 1.1
    },
    {
      "id": "8c392814-e5e3-401a-81b7-c82cbb4659b1",
      "name": "notCreditsEnoughMessage",
      "type": "n8n-nodes-base.telegram",
      "position": [
        4640,
        2192
      ],
      "webhookId": "ac153982-8e79-4bf8-b645-bdea02361fe8",
      "parameters": {
        "text": "={{ $('Global env').item.json.creditsNotEnough }}\n\n💳 Current balance: {{ $json.credits }} credits",
        "chatId": "={{ $('getUser').item.json.chat_id }}",
        "additionalFields": {
          "appendAttribution": false
        }
      },
      "credentials": {
        "telegramApi": {
          "id": "credential-id",
          "name": "Imageon AI"
        }
      },
      "typeVersion": 1.2
    },
    {
      "id": "c5d1c916-53f6-4afb-a1b5-39836780c38f",
      "name": "taskSubmitedGenerate",
      "type": "n8n-nodes-base.telegram",
      "position": [
        4832,
        2016
      ],
      "webhookId": "0b6362c8-a365-4383-b107-167dfe32bfae",
      "parameters": {
        "text": "={{ $('Global env').item.json.taskSubmitedMessage }}",
        "chatId": "={{ $('Telegram Trigger').item.json.message.chat.id }}",
        "additionalFields": {
          "appendAttribution": false
        }
      },
      "credentials": {
        "telegramApi": {
          "id": "credential-id",
          "name": "Imageon AI"
        }
      },
      "typeVersion": 1.2
    },
    {
      "id": "e8c0d040-3e87-4799-b5c7-59fed3aea4c8",
      "name": "sendActionGenerate",
      "type": "n8n-nodes-base.telegram",
      "position": [
        5024,
        2016
      ],
      "webhookId": "6767a01d-f877-406b-830a-968b003d558f",
      "parameters": {
        "action": "upload_photo",
        "chatId": "={{ $('Telegram Trigger').item.json.message.chat.id }}",
        "operation": "sendChatAction"
      },
      "credentials": {
        "telegramApi": {
          "id": "credential-id",
          "name": "Imageon AI"
        }
      },
      "typeVersion": 1.2
    },
    {
      "id": "405163c8-a2cf-4277-a1a5-248b7f65b2d6",
      "name": "checkTaskGenerate",
      "type": "n8n-nodes-wavespeed.wavespeedTaskStatus",
      "position": [
        5216,
        2016
      ],
      "parameters": {
        "taskId": "={{\n  $if(\n    $('WaveSpeed text-to-image submit').isExecuted,\n    $('WaveSpeed text-to-image submit').item.json.task_id,\n    $('editImageOnReply').item.json.task_id\n  )\n}}\n"
      },
      "credentials": {
        "wavespeedApi": {
          "id": "credential-id",
          "name": "WaveSpeed account"
        }
      },
      "typeVersion": 1
    },
    {
      "id": "7a75a63b-b8eb-4c15-9974-ff6d197b3f5a",
      "name": "waitGenerateStatus",
      "type": "n8n-nodes-base.wait",
      "position": [
        5856,
        2160
      ],
      "webhookId": "wait-webhook",
      "parameters": {},
      "typeVersion": 1.1
    },
    {
      "id": "a654f0ed-d8da-4757-b2ca-6b26fc4b72a9",
      "name": "switchTaskGenerate",
      "type": "n8n-nodes-base.switch",
      "position": [
        5392,
        1984
      ],
      "parameters": {
        "rules": {
          "values": [
            {
              "outputKey": "Completed",
              "conditions": {
                "options": {
                  "version": 3,
                  "leftValue": "",
                  "caseSensitive": true,
                  "typeValidation": "strict"
                },
                "combinator": "and",
                "conditions": [
                  {
                    "id": "1d223eb6-05f7-40ec-aaf9-0160f552d251",
                    "operator": {
                      "name": "filter.operator.equals",
                      "type": "string",
                      "operation": "equals"
                    },
                    "leftValue": "={{ $json.data.status }}",
                    "rightValue": "completed"
                  }
                ]
              },
              "renameOutput": true
            },
            {
              "outputKey": "Failed",
              "conditions": {
                "options": {
                  "version": 3,
                  "leftValue": "",
                  "caseSensitive": true,
                  "typeValidation": "strict"
                },
                "combinator": "and",
                "conditions": [
                  {
                    "id": "fb832215-ebed-489e-82a9-7889b9a51082",
                    "operator": {
                      "name": "filter.operator.equals",
                      "type": "string",
                      "operation": "equals"
                    },
                    "leftValue": "={{ $json.data.status }}",
                    "rightValue": "failed"
                  }
                ]
              },
              "renameOutput": true
            },
            {
              "outputKey": "Processing",
              "conditions": {
                "options": {
                  "version": 3,
                  "leftValue": "",
                  "caseSensitive": true,
                  "typeValidation": "strict"
                },
                "combinator": "and",
                "conditions": [
                  {
                    "id": "afe3bcb7-e14e-4352-9649-03aa1a050918",
                    "operator": {
                      "type": "string",
                      "operation": "equals"
                    },
                    "leftValue": "={{ $json.data.status }}",
                    "rightValue": "processing"
                  }
                ]
              },
              "renameOutput": true
            },
            {
              "outputKey": "Created",
              "conditions": {
                "options": {
                  "version": 3,
                  "leftValue": "",
                  "caseSensitive": true,
                  "typeValidation": "strict"
                },
                "combinator": "and",
                "conditions": [
                  {
                    "id": "fad21419-ffc5-47b8-819c-50129338460a",
                    "operator": {
                      "name": "filter.operator.equals",
                      "type": "string",
                      "operation": "equals"
                    },
                    "leftValue": "={{ $json.data.status }}",
                    "rightValue": "created"
                  }
                ]
              },
              "renameOutput": true
            }
          ]
        },
        "options": {}
      },
      "typeVersion": 3.4
    },
    {
      "id": "d9e12bf2-de12-4c72-8ea6-e74d2f68371b",
      "name": "getImage",
      "type": "n8n-nodes-base.httpRequest",
      "position": [
        5856,
        1888
      ],
      "parameters": {
        "url": "={{ $json.data.outputs[0] }}",
        "options": {}
      },
      "typeVersion": 4.3
    },
    {
      "id": "f6e53497-87c1-4d97-8d12-4bc298da2284",
      "name": "sendFailedGenerate",
      "type": "n8n-nodes-base.telegram",
      "position": [
        5856,
        2016
      ],
      "webhookId": "ae7be9f7-bcb0-4ddb-a6c1-4ef53351b666",
      "parameters": {
        "text": "={{ $('checkTaskGenerate').item.json.data.error }}",
        "chatId": "={{ $('Telegram Trigger').item.json.message.chat.id }}",
        "additionalFields": {
          "appendAttribution": false
        }
      },
      "credentials": {
        "telegramApi": {
          "id": "credential-id",
          "name": "Imageon AI"
        }
      },
      "typeVersion": 1.2
    },
    {
      "id": "198a6321-6c52-46dd-8f5b-76d150328bcf",
      "name": "resizeImage",
      "type": "n8n-nodes-base.editImage",
      "position": [
        6048,
        1888
      ],
      "parameters": {
        "width": 2560,
        "height": 1920,
        "options": {},
        "operation": "resize"
      },
      "typeVersion": 1
    },
    {
      "id": "eef7ec33-9747-4ad6-8098-dc3990c23617",
      "name": "updateCreditOnFail",
      "type": "n8n-nodes-base.dataTable",
      "position": [
        6048,
        2016
      ],
      "parameters": {
        "columns": {
          "value": {
            "credits": "={{\n  Number($('updateCreditsSendedTask').item.json.credits)\n  +\n  (\n    $('getUser').item.json.resolution === '4k'\n      ? Number($('Global env').item.json.generateImageCost4k)\n      : Number($('Global env').item.json.generateImageCost8k)\n  )\n}}"
          },
          "schema": [
            {
              "id": "status",
              "type": "string",
              "display": true,
              "removed": true,
              "readOnly": false,
              "required": false,
              "displayName": "status",
              "defaultMatch": false
            },
            {
              "id": "number_images",
              "type": "number",
              "display": true,
              "removed": true,
              "readOnly": false,
              "required": false,
              "displayName": "number_images",
              "defaultMatch": false
            },
            {
              "id": "username",
              "type": "string",
              "display": true,
              "removed": true,
              "readOnly": false,
              "required": false,
              "displayName": "username",
              "defaultMatch": false
            },
            {
              "id": "number_videos",
              "type": "number",
              "display": true,
              "removed": true,
              "readOnly": false,
              "required": false,
              "displayName": "number_videos",
              "defaultMatch": false
            },
            {
              "id": "credits",
              "type": "string",
              "display": true,
              "removed": false,
              "readOnly": false,
              "required": false,
              "displayName": "credits",
              "defaultMatch": false
            },
            {
              "id": "demo_sended",
              "type": "boolean",
              "display": true,
              "removed": true,
              "readOnly": false,
              "required": false,
              "displayName": "demo_sended",
              "defaultMatch": false
            }
          ],
          "mappingMode": "defineBelow",
          "matchingColumns": [],
          "attemptToConvertTypes": false,
          "convertFieldsToString": false
        },
        "filters": {
          "conditions": [
            {
              "keyName": "chat_id",
              "keyValue": "={{ $('getUser').item.json.chat_id }}"
            }
          ]
        },
        "options": {},
        "operation": "update",
        "dataTableId": {
          "__rl": true,
          "mode": "id",
          "value": "={{ $('Global env').item.json.dataTableId }}"
        }
      },
      "typeVersion": 1.1
    },
    {
      "id": "edf36f4f-7394-454f-b117-f269dc6e371f",
      "name": "sendGeneratedImage",
      "type": "n8n-nodes-base.telegram",
      "position": [
        6224,
        1888
      ],
      "webhookId": "ae7be9f7-bcb0-4ddb-a6c1-4ef53351b666",
      "parameters": {
        "chatId": "={{ $('Telegram Trigger').item.json.message.chat.id }}",
        "operation": "sendPhoto",
        "binaryData": true,
        "additionalFields": {
          "caption": "={{ $('Global env').item.json.successMessage }}\n\n✨ If you want the image in maximum quality, click here:\n<a href=\"{{ $('checkTaskGenerate').item.json.data.outputs[0] }}\">Download image</a>",
          "parse_mode": "HTML"
        }
      },
      "credentials": {
        "telegramApi": {
          "id": "credential-id",
          "name": "Imageon AI"
        }
      },
      "typeVersion": 1.2
    },
    {
      "id": "681da1ca-dde1-4e86-a0be-961fdbf43ec3",
      "name": "Send a text message1",
      "type": "n8n-nodes-base.telegram",
      "disabled": true,
      "position": [
        464,
        -288
      ],
      "webhookId": "YOUR_WEBHOOK_ID",
      "parameters": {
        "text": "={{ $('getUser').item.json.chat_id }}",
        "chatId": "={{ $json.message.chat.id }}",
        "replyMarkup": "inlineKeyboard",
        "additionalFields": {
          "appendAttribution": false
        }
      },
      "credentials": {
        "telegramApi": {
          "id": "credential-id",
          "name": "Telegram Loja"
        }
      },
      "typeVersion": 1.2
    },
    {
      "id": "79cc71b3-f201-4334-bf33-f1dcfa858ef2",
      "name": "If demo sended1",
      "type": "n8n-nodes-base.if",
      "disabled": true,
      "position": [
        -560,
        -288
      ],
      "parameters": {
        "options": {},
        "conditions": {
          "options": {
            "version": 3,
            "leftValue": "",
            "caseSensitive": true,
            "typeValidation": "strict"
          },
          "combinator": "and",
          "conditions": [
            {
              "id": "9a19a8e2-0583-43f3-ac53-cbebf7e7904e",
              "operator": {
                "type": "boolean",
                "operation": "false",
                "singleValue": true
              },
              "leftValue": "={{ $json.demo_sended }}",
              "rightValue": ""
            }
          ]
        }
      },
      "typeVersion": 2.3
    },
    {
      "id": "46be3c6d-551c-4225-a17d-9f20c69f97f2",
      "name": "Welcome",
      "type": "n8n-nodes-base.telegram",
      "disabled": true,
      "position": [
        -320,
        -288
      ],
      "webhookId": "YOUR_WEBHOOK_ID",
      "parameters": {
        "text": "=",
        "chatId": "={{ $('getUser').item.json.chat_id }}",
        "additionalFields": {
          "appendAttribution": false
        }
      },
      "credentials": {
        "telegramApi": {
          "id": "credential-id",
          "name": "Telegram Loja"
        }
      },
      "typeVersion": 1.2
    },
    {
      "id": "c12abd8d-bfc2-4449-a571-7c84804b1a6f",
      "name": "Send welcome media",
      "type": "n8n-nodes-base.telegram",
      "disabled": true,
      "position": [
        -128,
        -288
      ],
      "webhookId": "YOUR_WEBHOOK_ID",
      "parameters": {
        "media": {
          "media": [
            {
              "additionalFields": {}
            },
            {
              "additionalFields": {}
            },
            {
              "additionalFields": {}
            },
            {
              "additionalFields": {}
            }
          ]
        },
        "chatId": "={{ $('getUser').item.json.chat_id }}",
        "operation": "sendMediaGroup",
        "additionalFields": {}
      },
      "credentials": {
        "telegramApi": {
          "id": "credential-id",
          "name": "Telegram Loja"
        }
      },
      "typeVersion": 1.2
    },
    {
      "id": "fa81ba19-a907-4d6b-bdce-f03bffe05d4d",
      "name": "Update welcome_demo_sended",
      "type": "n8n-nodes-base.dataTable",
      "disabled": true,
      "position": [
        80,
        -288
      ],
      "parameters": {
        "columns": {
          "value": {
            "status": "selecao",
            "credits": "={{ $('Global env').item.json.initialCredits }}",
            "resolution": "4k",
            "demo_sended": true,
            "aspect_ratio": "16:9",
            "number_images": 0,
            "number_videos": 0
          },
          "schema": [
            {
              "id": "status",
              "type": "string",
              "display": true,
              "removed": false,
              "readOnly": false,
              "required": false,
              "displayName": "status",
              "defaultMatch": false
            },
            {
              "id": "number_images",
              "type": "number",
              "display": true,
              "removed": false,
              "readOnly": false,
              "required": false,
              "displayName": "number_images",
              "defaultMatch": false
            },
            {
              "id": "chat_id",
              "type": "string",
              "display": true,
              "removed": true,
              "readOnly": false,
              "required": false,
              "displayName": "chat_id",
              "defaultMatch": false
            },
            {
              "id": "number_videos",
              "type": "number",
              "display": true,
              "removed": false,
              "readOnly": false,
              "required": false,
              "displayName": "number_videos",
              "defaultMatch": false
            },
            {
              "id": "credits",
              "type": "string",
              "display": true,
              "removed": false,
              "readOnly": false,
              "required": false,
              "displayName": "credits",
              "defaultMatch": false
            },
            {
              "id": "demo_sended",
              "type": "boolean",
              "display": true,
              "removed": false,
              "readOnly": false,
              "required": false,
              "displayName": "demo_sended",
              "defaultMatch": false
            },
            {
              "id": "use_edit_demo_sended",
              "type": "boolean",
              "display": true,
              "removed": true,
              "readOnly": false,
              "required": false,
              "displayName": "use_edit_demo_sended",
              "defaultMatch": false
            },
            {
              "id": "resolution",
              "type": "string",
              "display": true,
              "removed": false,
              "readOnly": false,
              "required": false,
              "displayName": "resolution",
              "defaultMatch": false
            },
            {
              "id": "aspect_ratio",
              "type": "string",
              "display": true,
              "removed": false,
              "readOnly": false,
              "required": false,
              "displayName": "aspect_ratio",
              "defaultMatch": false
            }
          ],
          "mappingMode": "defineBelow",
          "matchingColumns": [],
          "attemptToConvertTypes": false,
          "convertFieldsToString": false
        },
        "filters": {
          "conditions": [
            {
              "keyName": "chat_id",
              "keyValue": "={{ $('getUser').item.json.chat_id }}"
            }
          ]
        },
        "options": {},
        "operation": "update",
        "dataTableId": {
          "__rl": true,
          "mode": "id",
          "value": "={{ $json.dataTableId }}"
        }
      },
      "typeVersion": 1.1
    },
    {
      "id": "90799b9d-c463-4b92-bbe4-fc911c1f2ec2",
      "name": "Fields Chat",
      "type": "n8n-nodes-base.set",
      "disabled": true,
      "position": [
        272,
        -288
      ],
      "parameters": {
        "options": {},
        "assignments": {
          "assignments": [
            {
              "id": "5f5f541c-8a44-41f1-84f8-e2a181c36f44",
              "name": "message.chat.id",
              "type": "number",
              "value": "={{ $('Telegram Trigger').item.json.message.chat.id }}"
            },
            {
              "id": "1bc8ac26-35cd-463d-8f53-001be2a2e78b",
              "name": "message.from.first_name",
              "type": "string",
              "value": "={{ $('Telegram Trigger').item.json.message.from.first_name }}"
            },
            {
              "id": "088a55f8-aa55-4b63-afde-e2158c9c8661",
              "name": "message.from.username",
              "type": "string",
              "value": "={{ $('Telegram Trigger').item.json.message.from.username }}"
            }
          ]
        }
      },
      "typeVersion": 3.4
    },
    {
      "id": "00778d4b-7f98-42eb-904c-228c54038d40",
      "name": "Demo Welcome Flow1",
      "type": "n8n-nodes-base.stickyNote",
      "position": [
        -672,
        -384
      ],
      "parameters": {
        "color": 7,
        "width": 1392,
        "height": 304,
        "content": "Welcome flow with demo media for first-time users. Currently disabled."
      },
      "typeVersion": 1
    },
    {
      "id": "7cf0c5b1-3088-43d0-9286-ca298853ee23",
      "name": "Update use_edit_demo",
      "type": "n8n-nodes-base.dataTable",
      "disabled": true,
      "position": [
        80,
        16
      ],
      "parameters": {
        "columns": {
          "value": {
            "use_edit_demo_sended": true
          },
          "schema": [
            {
              "id": "status",
              "type": "string",
              "display": true,
              "removed": true,
              "readOnly": false,
              "required": false,
              "displayName": "status",
              "defaultMatch": false
            },
            {
              "id": "number_images",
              "type": "number",
              "display": true,
              "removed": true,
              "readOnly": false,
              "required": false,
              "displayName": "number_images",
              "defaultMatch": false
            },
            {
              "id": "chat_id",
              "type": "string",
              "display": true,
              "removed": true,
              "readOnly": false,
              "required": false,
              "displayName": "chat_id",
              "defaultMatch": false
            },
            {
              "id": "number_videos",
              "type": "number",
              "display": true,
              "removed": true,
              "readOnly": false,
              "required": false,
              "displayName": "number_videos",
              "defaultMatch": false
            },
            {
              "id": "credits",
              "type": "string",
              "display": true,
              "removed": true,
              "readOnly": false,
              "required": false,
              "displayName": "credits",
              "defaultMatch": false
            },
            {
              "id": "demo_sended",
              "type": "boolean",
              "display": true,
              "removed": true,
              "readOnly": false,
              "required": false,
              "displayName": "demo_sended",
              "defaultMatch": false
            },
            {
              "id": "use_edit_demo_sended",
              "type": "boolean",
              "display": true,
              "removed": false,
              "readOnly": false,
              "required": false,
              "displayName": "use_edit_demo_sended",
              "defaultMatch": false
            },
            {
              "id": "resolution",
              "type": "string",
              "display": true,
              "removed": true,
              "readOnly": false,
              "required": false,
              "displayName": "resolution",
              "defaultMatch": false
            },
            {
              "id": "aspect_ratio",
              "type": "string",
              "display": true,
              "removed": true,
              "readOnly": false,
              "required": false,
              "displayName": "aspect_ratio",
              "defaultMatch": false
            }
          ],
          "mappingMode": "defineBelow",
          "matchingColumns": [],
          "attemptToConvertTypes": false,
          "convertFieldsToString": false
        },
        "filters": {
          "conditions": [
            {
              "keyName": "chat_id",
              "keyValue": "={{ $('getUser').item.json.chat_id }}"
            }
          ]
        },
        "options": {},
        "operation": "update",
        "dataTableId": {
          "__rl": true,
          "mode": "id",
          "value": "={{ $json.dataTableId }}"
        }
      },
      "typeVersion": 1.1
    },
    {
      "id": "428181a9-c950-49f4-8c57-9bc25abf6f3a",
      "name": "Edit image question",
      "type": "n8n-nodes-base.telegram",
      "disabled": true,
      "position": [
        288,
        16
      ],
      "webhookId": "YOUR_WEBHOOK_ID",
      "parameters": {
        "text": "=",
        "chatId": "={{ $('Telegram Trigger').item.json.callback_query?.message?.chat?.id ?? $('Telegram Trigger').item.json.message?.chat?.id }}",
        "additionalFields": {
          "appendAttribution": false
        }
      },
      "credentials": {
        "telegramApi": {
          "id": "credential-id",
          "name": "Telegram Loja"
        }
      },
      "typeVersion": 1.2
    },
    {
      "id": "46197493-7257-4b8f-9a54-6eef31d682f8",
      "name": "If use_edit_demo1",
      "type": "n8n-nodes-base.if",
      "disabled": true,
      "position": [
        -560,
        32
      ],
      "parameters": {
        "options": {},
        "conditions": {
          "options": {
            "version": 3,
            "leftValue": "",
            "caseSensitive": true,
            "typeValidation": "strict"
          },
          "combinator": "and",
          "conditions": [
            {
              "id": "7b4f0596-9c9e-4dd5-8196-7beb1398def8",
              "operator": {
                "type": "boolean",
                "operation": "false",
                "singleValue": true
              },
              "leftValue": "={{ $json.use_edit_demo_sended }}",
              "rightValue": false
            }
          ]
        }
      },
      "typeVersion": 2.3
    },
    {
      "id": "a8346294-c529-454e-adee-a64cdae910ed",
      "name": "Send a media group demo1",
      "type": "n8n-nodes-base.telegram",
      "disabled": true,
      "position": [
        -112,
        16
      ],
      "webhookId": "YOUR_WEBHOOK_ID",
      "parameters": {
        "media": {
          "media": [
            {
              "additionalFields": {}
            },
            {
              "additionalFields": {}
            }
          ]
        },
        "chatId": "={{ $('Telegram Trigger').item.json.callback_query?.message?.chat?.id ?? $('Telegram Trigger').item.json.message?.chat?.id }}",
        "operation": "sendMediaGroup",
        "additionalFields": {}
      },
      "credentials": {
        "telegramApi": {
          "id": "credential-id",
          "name": "Telegram Loja"
        }
      },
      "typeVersion": 1.2
    },
    {
      "id": "1a77a1b9-a467-49a1-a7cc-7e589d7b49b1",
      "name": "Welcome image edit message",
      "type": "n8n-nodes-base.telegram",
      "disabled": true,
      "position": [
        -320,
        16
      ],
      "webhookId": "YOUR_WEBHOOK_ID",
      "parameters": {
        "text": "=",
        "chatId": "={{ $('Telegram Trigger').item.json.callback_query?.message?.chat?.id ?? $('Telegram Trigger').item.json.message?.chat?.id }}",
        "additionalFields": {
          "appendAttribution": false
        }
      },
      "credentials": {
        "telegramApi": {
          "id": "credential-id",
          "name": "Telegram Loja"
        }
      },
      "typeVersion": 1.2
    },
    {
      "id": "be888f74-c994-42eb-a5a0-553062cf127e",
      "name": "Demo Edit Image Flow1",
      "type": "n8n-nodes-base.stickyNote",
      "position": [
        -672,
        -48
      ],
      "parameters": {
        "color": 7,
        "width": 1392,
        "height": 304,
        "content": "Demo flow showing image editing capabilities. Currently disabled."
      },
      "typeVersion": 1
    },
    {
      "id": "0c354a09-540d-4409-acda-17be0128f3fa",
      "name": "Global Config Info1",
      "type": "n8n-nodes-base.stickyNote",
      "position": [
        -416,
        1280
      ],
      "parameters": {
        "color": 7,
        "width": 368,
        "height": 360,
        "content": "🌍 **Global Environment**\n\nMain bot configuration: tokens, database IDs, credit costs, and default messages. Edit carefully."
      },
      "typeVersion": 1
    },
    {
      "id": "2795bf30-04fb-4ea2-b376-6b4ee1cbb14a",
      "name": "Entry Point1",
      "type": "n8n-nodes-base.stickyNote",
      "position": [
        -688,
        1280
      ],
      "parameters": {
        "color": 7,
        "width": 254,
        "height": 358,
        "content": "🎯 **Entry Point**\n\nTelegram Trigger receives all messages and callbacks. Routes to appropriate handlers."
      },
      "typeVersion": 1
    },
    {
      "id": "cfb7df6c-77a2-4554-a7bc-329ab8bc0ea9",
      "name": "Customization Ideas1",
      "type": "n8n-nodes-base.stickyNote",
      "position": [
        -416,
        1680
      ],
      "parameters": {
        "color": 7,
        "width": 366,
        "height": 150,
        "content": "🛠️ **Customization**\n\nAdjust credits, costs, messages. Add watermarks, referrals, or swap AI providers."
      },
      "typeVersion": 1
    },
    {
      "id": "482f8adc-9cce-4785-b033-b7965d9b1e75",
      "name": "Global env",
      "type": "n8n-nodes-base.set",
      "onError": "continueRegularOutput",
      "position": [
        -272,
        1488
      ],
      "parameters": {
        "options": {},
        "assignments": {
          "assignments": [
            {
              "id": "69fe2d80-fb2a-453c-8ced-1126c317b910",
              "name": "botName",
              "type": "string",
              "value": ""
            },
            {
              "id": "f9324b82-a224-4290-a77a-18fc5638e3c5",
              "name": "botToken",
              "type": "string",
              "value": ""
            },
            {
              "id": "4de25ceb-79d1-40a1-99a4-0c5fc6c0de0d",
              "name": "paymentDataTableId",
              "type": "string",
              "value": ""
            },
            {
              "id": "82e21534-2159-44aa-81bb-d8ae769df339",
              "name": "dataTableId",
              "type": "string",
              "value": ""
            },
            {
              "id": "9c0b3b78-9e60-49ca-843e-c6cd04249621",
              "name": "bucketName",
              "type": "string",
              "value": ""
            },
            {
              "id": "4bda9013-92ff-4b83-b27d-5c3ccc1f142d",
              "name": "initialCredits",
              "type": "string",
              "value": "4"
            },
            {
              "id": "9b92bcf4-3354-4eef-a0b3-dd0bb2c26a77",
              "name": "generateImageCost4k",
              "type": "string",
              "value": "0.25"
            },
            {
              "id": "4f7fe1e4-61ea-4ea8-8c9f-d0176c779cda",
              "name": "generateImageCost8k",
              "type": "string",
              "value": "0.5"
            },
            {
              "id": "8974879a-3287-4905-a60e-56c2b7f5b9fd",
              "name": "generateVideoCust",
              "type": "string",
              "value": "2"
            },
            {
              "id": "5c2618b7-3f16-46e1-8f9b-d47cc7acbeed",
              "name": "successMessage",
              "type": "string",
              "value": "=🎉 Done!\nHope you like the result ✨"
            },
            {
              "id": "890907c4-0cf4-4e05-a3d7-31d5e47f2814",
              "name": "taskSubmitedMessage",
              "type": "string",
              "value": "=✅ Your request has been received!\n\nYour image is now being processed.\nPlease wait a moment — it will be delivered as soon as it’s ready 🚀✨"
            },
            {
              "id": "eb0a47d4-1b46-4829-aa6e-d7f2ce7c4977",
              "name": "creditsNotEnough",
              "type": "string",
              "value": "=Oops! You don’t have enough credits to continue 😕"
            },
            {
              "id": "1c9fc5d0-a18f-4fc0-a1a8-62ade650ee8a",
              "name": "defaultEditPrompt",
              "type": "string",
              "value": "="
            },
            {
              "id": "f05a151d-8465-4ff1-a29b-b90ad172b5d1",
              "name": "baseImageUrl",
              "type": "string",
              "value": ""
            },
            {
              "id": "ebcc4d73-8ecd-41c3-adec-11a038215f90",
              "name": "usersPromptConfig",
              "type": "boolean",
              "value": true
            }
          ]
        }
      },
      "typeVersion": 3.4
    },
    {
      "id": "b91d4ab2-7adb-4fff-a05e-0625e0dca09f",
      "name": "Telegram Trigger",
      "type": "n8n-nodes-base.telegramTrigger",
      "position": [
        -608,
        1488
      ],
      "webhookId": "fe88ef39-a615-4b95-9396-ffdf3579a96d",
      "parameters": {
        "updates": [
          "message",
          "callback_query",
          "pre_checkout_query"
        ],
        "additionalFields": {
          "download": false
        }
      },
      "credentials": {
        "telegramApi": {
          "id": "credential-id",
          "name": "Imageon AI"
        }
      },
      "typeVersion": 1.2
    }
  ],
  "pinData": {
    "Telegram Trigger": [
      {}
    ]
  },
  "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
          }
        ]
      ]
    }
  }
}