{
  "id": "nE3JTHLYHcVeLg70",
  "meta": {
    "templateCredsSetupCompleted": true
  },
  "name": "Digiflaz Management",
  "tags": [
    {
      "id": "TP4PAaWeCf1SVUdK",
      "name": "Digiflazz Management",
      "createdAt": "2025-09-18T03:22:47.434Z",
      "updatedAt": "2025-09-18T03:22:47.434Z"
    }
  ],
  "nodes": [
    {
      "id": "eb098b4a-557c-4c39-aa1f-d942bb1e98cf",
      "name": "Telegram Trigger",
      "type": "n8n-nodes-base.telegramTrigger",
      "position": [
        -640,
        176
      ],
      "parameters": {
        "updates": [
          "message",
          "callback_query"
        ],
        "additionalFields": {}
      },
      "credentials": {
        "telegramApi": {
          "name": "<your credential>"
        }
      },
      "typeVersion": 1.2
    },
    {
      "id": "e4f4fde2-75c4-4c4f-9e70-5d9366e28857",
      "name": "Main Command Router",
      "type": "n8n-nodes-base.switch",
      "position": [
        -400,
        176
      ],
      "parameters": {
        "rules": {
          "values": [
            {
              "outputKey": "welcome",
              "conditions": {
                "options": {
                  "leftValue": "",
                  "caseSensitive": true,
                  "typeValidation": "strict"
                },
                "combinator": "and",
                "conditions": [
                  {
                    "operator": {
                      "type": "string",
                      "operation": "startsWith"
                    },
                    "leftValue": "={{ $json.message?.text || $json.callback_query?.data }}",
                    "rightValue": "/start"
                  }
                ]
              },
              "renameOutput": true
            },
            {
              "outputKey": "main_menu",
              "conditions": {
                "options": {
                  "leftValue": "",
                  "caseSensitive": true,
                  "typeValidation": "strict"
                },
                "combinator": "or",
                "conditions": [
                  {
                    "operator": {
                      "type": "string",
                      "operation": "startsWith"
                    },
                    "leftValue": "={{ $json.message?.text || $json.callback_query?.data }}",
                    "rightValue": "/menu"
                  },
                  {
                    "operator": {
                      "type": "string",
                      "operation": "equals"
                    },
                    "leftValue": "={{ $json.callback_query?.data }}",
                    "rightValue": "main_menu"
                  }
                ]
              },
              "renameOutput": true
            },
            {
              "outputKey": "check_balance",
              "conditions": {
                "options": {
                  "leftValue": "",
                  "caseSensitive": true,
                  "typeValidation": "strict"
                },
                "combinator": "and",
                "conditions": [
                  {
                    "operator": {
                      "type": "string",
                      "operation": "equals"
                    },
                    "leftValue": "={{ $json.callback_query?.data }}",
                    "rightValue": "check_balance"
                  }
                ]
              },
              "renameOutput": true
            },
            {
              "outputKey": "list_products",
              "conditions": {
                "options": {
                  "leftValue": "",
                  "caseSensitive": true,
                  "typeValidation": "strict"
                },
                "combinator": "and",
                "conditions": [
                  {
                    "operator": {
                      "type": "string",
                      "operation": "equals"
                    },
                    "leftValue": "={{ $json.callback_query?.data }}",
                    "rightValue": "list_products"
                  }
                ]
              },
              "renameOutput": true
            },
            {
              "outputKey": "topup_command",
              "conditions": {
                "options": {
                  "leftValue": "",
                  "caseSensitive": true,
                  "typeValidation": "strict"
                },
                "combinator": "or",
                "conditions": [
                  {
                    "operator": {
                      "type": "string",
                      "operation": "startsWith"
                    },
                    "leftValue": "={{ $json.message?.text || $json.callback_query?.data }}",
                    "rightValue": "/topup"
                  },
                  {
                    "operator": {
                      "type": "string",
                      "operation": "equals"
                    },
                    "leftValue": "={{ $json.callback_query?.data }}",
                    "rightValue": "new_transaction"
                  }
                ]
              },
              "renameOutput": true
            },
            {
              "outputKey": "deposit_request",
              "conditions": {
                "options": {
                  "leftValue": "",
                  "caseSensitive": true,
                  "typeValidation": "strict"
                },
                "combinator": "or",
                "conditions": [
                  {
                    "operator": {
                      "type": "string",
                      "operation": "startsWith"
                    },
                    "leftValue": "={{ $json.message?.text }}",
                    "rightValue": "/deposit"
                  },
                  {
                    "operator": {
                      "type": "string",
                      "operation": "equals"
                    },
                    "leftValue": "={{ $json.callback_query?.data }}",
                    "rightValue": "request_deposit"
                  }
                ]
              },
              "renameOutput": true
            },
            {
              "outputKey": "checkbill_command",
              "conditions": {
                "options": {
                  "leftValue": "",
                  "caseSensitive": true,
                  "typeValidation": "strict"
                },
                "combinator": "or",
                "conditions": [
                  {
                    "operator": {
                      "type": "string",
                      "operation": "startsWith"
                    },
                    "leftValue": "={{ $json.message?.text || $json.callback_query?.data }}",
                    "rightValue": "/checkbill"
                  },
                  {
                    "operator": {
                      "type": "string",
                      "operation": "equals"
                    },
                    "leftValue": "={{ $json.callback_query?.data }}",
                    "rightValue": "check_bills"
                  }
                ]
              },
              "renameOutput": true
            },
            {
              "outputKey": "paybill_command",
              "conditions": {
                "options": {
                  "leftValue": "",
                  "caseSensitive": true,
                  "typeValidation": "strict"
                },
                "combinator": "or",
                "conditions": [
                  {
                    "operator": {
                      "type": "string",
                      "operation": "startsWith"
                    },
                    "leftValue": "={{ $json.message?.text || $json.callback_query?.data }}",
                    "rightValue": "/paybill"
                  },
                  {
                    "operator": {
                      "type": "string",
                      "operation": "equals"
                    },
                    "leftValue": "={{ $json.callback_query?.data }}",
                    "rightValue": "pay_bills"
                  }
                ]
              },
              "renameOutput": true
            },
            {
              "outputKey": "history_command",
              "conditions": {
                "options": {
                  "leftValue": "",
                  "caseSensitive": true,
                  "typeValidation": "strict"
                },
                "combinator": "and",
                "conditions": [
                  {
                    "operator": {
                      "type": "string",
                      "operation": "equals"
                    },
                    "leftValue": "={{ $json.callback_query?.data }}",
                    "rightValue": "transaction_history"
                  }
                ]
              },
              "renameOutput": true
            },
            {
              "outputKey": "process_topup",
              "conditions": {
                "options": {
                  "leftValue": "",
                  "caseSensitive": true,
                  "typeValidation": "strict"
                },
                "combinator": "and",
                "conditions": [
                  {
                    "operator": {
                      "type": "string",
                      "operation": "startsWith"
                    },
                    "leftValue": "={{ $json.callback_query?.data }}",
                    "rightValue": "topup_"
                  }
                ]
              },
              "renameOutput": true
            },
            {
              "outputKey": "process_checkbill",
              "conditions": {
                "options": {
                  "leftValue": "",
                  "caseSensitive": true,
                  "typeValidation": "strict"
                },
                "combinator": "and",
                "conditions": [
                  {
                    "operator": {
                      "type": "string",
                      "operation": "startsWith"
                    },
                    "leftValue": "={{ $json.callback_query?.data }}",
                    "rightValue": "checkbill_"
                  }
                ]
              },
              "renameOutput": true
            },
            {
              "outputKey": "process_paybill",
              "conditions": {
                "options": {
                  "leftValue": "",
                  "caseSensitive": true,
                  "typeValidation": "strict"
                },
                "combinator": "and",
                "conditions": [
                  {
                    "operator": {
                      "type": "string",
                      "operation": "startsWith"
                    },
                    "leftValue": "={{ $json.callback_query?.data }}",
                    "rightValue": "paybill_"
                  }
                ]
              },
              "renameOutput": true
            }
          ]
        },
        "options": {}
      },
      "typeVersion": 3
    },
    {
      "id": "c9456149-5d6b-4e75-b388-4fb83bcdb5dc",
      "name": "Welcome Message",
      "type": "n8n-nodes-base.telegram",
      "position": [
        -64,
        -16
      ],
      "parameters": {
        "text": "\ud83d\ude80 *Welcome to Digiflazz Management Bot!*\n\n\u2728 This bot helps you manage your mobile credit & PPOB business easily:\n\n\ud83d\udcb0 */balance* - Check deposit balance\n\ud83d\udecd\ufe0f */products* - View product list\n\ud83d\udcb3 */topup* - Prepaid transactions\n\ud83c\udff7\ufe0f */checkbill* - Check postpaid bills\n\ud83d\udcb0 */paybill* - Pay bills\n\ud83d\udcb8 */deposit* - Request deposit\n\ud83d\udccb */menu* - Main menu\n\ud83d\udcc8 */history* - Transaction history\n\n\ud83d\udca1 *Tips:* Use inline keyboard for easier navigation!\n\n\ud83d\udd10 *Security:* This bot uses MD5 encryption for all API transactions",
        "chatId": "={{ $json.message?.chat?.id || $json.callback_query?.message?.chat?.id }}",
        "replyMarkup": {
          "type": "inlineKeyboard",
          "values": [
            [
              {
                "text": "\ud83d\udcb0 Check Balance",
                "callbackData": "check_balance"
              },
              {
                "text": "\ud83d\udecd\ufe0f Products",
                "callbackData": "list_products"
              }
            ],
            [
              {
                "text": "\ud83d\udcb3 New Transaction",
                "callbackData": "new_transaction"
              },
              {
                "text": "\ud83d\udcb8 Deposit",
                "callbackData": "request_deposit"
              }
            ],
            [
              {
                "text": "\ud83c\udff7\ufe0f Check Bills",
                "callbackData": "check_bills"
              },
              {
                "text": "\ud83d\udcb0 Pay Bills",
                "callbackData": "pay_bills"
              }
            ],
            [
              {
                "text": "\ud83d\udcc8 History",
                "callbackData": "transaction_history"
              },
              {
                "text": "\ud83d\udccb Main Menu",
                "callbackData": "main_menu"
              }
            ]
          ]
        },
        "additionalFields": {}
      },
      "credentials": {
        "telegramApi": {
          "name": "<your credential>"
        }
      },
      "typeVersion": 1.2
    },
    {
      "id": "40b35a12-4708-4311-9114-eea7c3a3d28b",
      "name": "Main Menu",
      "type": "n8n-nodes-base.telegram",
      "position": [
        -64,
        176
      ],
      "parameters": {
        "text": "\ud83d\udccb *Digiflazz Management Main Menu*\n\nSelect the operation you want to perform:",
        "chatId": "={{ $json.message?.chat?.id || $json.callback_query?.message?.chat?.id }}",
        "replyMarkup": {
          "type": "inlineKeyboard",
          "values": [
            [
              {
                "text": "\ud83d\udcb0 Check Balance",
                "callbackData": "check_balance"
              },
              {
                "text": "\ud83d\udcb8 Request Deposit",
                "callbackData": "request_deposit"
              }
            ],
            [
              {
                "text": "\ud83d\udecd\ufe0f Product List",
                "callbackData": "list_products"
              },
              {
                "text": "\ud83d\udd0d Search Product",
                "callbackData": "search_product"
              }
            ],
            [
              {
                "text": "\ud83d\udcb3 Prepaid Topup",
                "callbackData": "new_transaction"
              },
              {
                "text": "\ud83c\udff7\ufe0f Check Bills",
                "callbackData": "check_bills"
              }
            ],
            [
              {
                "text": "\ud83d\udcb0 Pay Bills",
                "callbackData": "pay_bills"
              },
              {
                "text": "\ud83d\udcc8 Transaction History",
                "callbackData": "transaction_history"
              }
            ],
            [
              {
                "text": "\u2699\ufe0f Settings",
                "callbackData": "settings"
              },
              {
                "text": "\u2753 Help",
                "callbackData": "help"
              }
            ]
          ]
        },
        "additionalFields": {}
      },
      "credentials": {
        "telegramApi": {
          "name": "<your credential>"
        }
      },
      "typeVersion": 1.2
    },
    {
      "id": "4efaf4e7-40b8-49aa-b1fd-1900b9951c27",
      "name": "Generate Balance Signature",
      "type": "n8n-nodes-base.code",
      "onError": "continueRegularOutput",
      "position": [
        192,
        368
      ],
      "parameters": {
        "jsCode": "// Generate MD5 signature for balance check\nconst crypto = require('crypto');\nconst username = '{{DIGIFLAZZ_USERNAME}}';\nconst apiKey = '{{DIGIFLAZZ_API_KEY}}';\nconst command = 'depo';\n\nconst signature = crypto.createHash('md5').update(username + apiKey + command).digest('hex');\n\nreturn {\n  json: {\n    cmd: 'deposit',\n    username: username,\n    sign: signature\n  }\n};"
      },
      "typeVersion": 2
    },
    {
      "id": "13ec07db-dcfa-4dbb-99e5-ce6d539e192b",
      "name": "Check Balance API",
      "type": "n8n-nodes-base.httpRequest",
      "onError": "continueRegularOutput",
      "position": [
        384,
        368
      ],
      "parameters": {
        "url": "https://api.digiflazz.com/v1/cek-saldo",
        "method": "POST",
        "options": {
          "timeout": 30000,
          "response": {
            "response": {}
          }
        },
        "sendBody": true,
        "sendHeaders": true,
        "bodyParameters": {
          "parameters": [
            {}
          ]
        },
        "headerParameters": {
          "parameters": [
            {
              "name": "Content-Type",
              "value": "application/json"
            }
          ]
        }
      },
      "typeVersion": 4.2
    },
    {
      "id": "3c2c2921-36a7-4619-9aca-98280052868f",
      "name": "Format Balance Response",
      "type": "n8n-nodes-base.code",
      "onError": "continueRegularOutput",
      "position": [
        576,
        368
      ],
      "parameters": {
        "jsCode": "// Handle both success and error responses for balance check\nconst response = $input.first();\n\nif (response.json && response.json.data) {\n  // Success response\n  const data = response.json.data;\n  const balance = Number(data.deposit || 0);\n  \n  let statusIcon = '';\n  let statusColor = '';\n  let warningText = '';\n  \n  if (balance < 100000) {\n    statusIcon = '\ud83d\udd34';\n    statusColor = 'Need Deposit';\n    warningText = '\u26a0\ufe0f *Warning:* Your balance is low! Please make a deposit soon.';\n  } else if (balance < 500000) {\n    statusIcon = '\ud83d\udfe1';\n    statusColor = 'Good';\n    warningText = '\u2705 Your balance is sufficient for transactions.';\n  } else {\n    statusIcon = '\ud83d\udfe2';\n    statusColor = 'Very Good';\n    warningText = '\u2705 Your balance is sufficient for transactions.';\n  }\n  \n  const message = `\ud83d\udcb0 *Balance Information*\\n\\n\ud83d\udcb3 Deposit Balance: *Rp ${balance.toLocaleString('id-ID')}*\\n\\n${warningText}\\n\\n\ud83d\udcca Status: ${statusIcon} ${statusColor}\\n\\n\u23f0 Checked at: ${new Date().toLocaleString('en-US', { timeZone: 'Asia/Jakarta' })} WIB`;\n  \n  return {\n    json: {\n      success: true,\n      message: message,\n      balance: balance,\n      status: statusColor\n    }\n  };\n} else {\n  // Error response\n  let errorMessage = '\u274c *Failed to Check Balance*\\n\\n';\n  \n  if (response.json && response.json.data && response.json.data.rc) {\n    const rc = response.json.data.rc;\n    const msg = response.json.data.message || 'Unknown error';\n    errorMessage += `\ud83d\udccb Response Code: ${rc}\\n\ud83d\udcac Message: ${msg}\\n\\n`;\n    \n    switch (rc) {\n      case '41':\n        errorMessage += '\ud83d\udca1 Solution: Invalid signature, check API Key';\n        break;\n      case '45':\n        errorMessage += '\ud83d\udca1 Solution: IP not recognized, contact admin';\n        break;\n      default:\n        errorMessage += '\ud83d\udca1 Contact customer service for assistance';\n    }\n  } else {\n    errorMessage += '\ud83d\udd0d Network error occurred\\n\ud83d\udca1 Please try again in a few moments';\n  }\n  \n  return {\n    json: {\n      success: false,\n      message: errorMessage\n    }\n  };\n}"
      },
      "typeVersion": 2
    },
    {
      "id": "9895edc1-40bd-433c-bdf5-f8cc48ac8a75",
      "name": "Send Balance Result",
      "type": "n8n-nodes-base.telegram",
      "position": [
        768,
        368
      ],
      "parameters": {
        "text": "={{ $json.message }}",
        "chatId": "={{ $('Telegram Trigger').item.json.message?.chat?.id || $('Telegram Trigger').item.json.callback_query?.message?.chat?.id }}",
        "replyMarkup": {
          "type": "inlineKeyboard",
          "values": [
            [
              {
                "text": "\ud83d\udcb8 Request Deposit",
                "callbackData": "request_deposit"
              },
              {
                "text": "\ud83d\udcca Refresh Balance",
                "callbackData": "check_balance"
              }
            ],
            [
              {
                "text": "\ud83d\udcb3 New Transaction",
                "callbackData": "new_transaction"
              },
              {
                "text": "\ud83d\udd19 Main Menu",
                "callbackData": "main_menu"
              }
            ]
          ]
        },
        "additionalFields": {}
      },
      "credentials": {
        "telegramApi": {
          "name": "<your credential>"
        }
      },
      "typeVersion": 1.2
    },
    {
      "id": "a31f1481-abd7-4778-b8aa-4a88d11b48e0",
      "name": "Generate Product Signature",
      "type": "n8n-nodes-base.code",
      "onError": "continueRegularOutput",
      "position": [
        192,
        560
      ],
      "parameters": {
        "jsCode": "// Generate MD5 signature for product list\nconst crypto = require('crypto');\nconst username = '{{DIGIFLAZZ_USERNAME}}';\nconst apiKey = '{{DIGIFLAZZ_API_KEY}}';\nconst command = 'pricelist';\n\nconst signature = crypto.createHash('md5').update(username + apiKey + command).digest('hex');\n\nreturn {\n  json: {\n    cmd: 'prepaid',\n    username: username,\n    sign: signature\n  }\n};"
      },
      "typeVersion": 2
    },
    {
      "id": "e50db72a-6972-4137-a98d-930045894b61",
      "name": "Get Products API",
      "type": "n8n-nodes-base.httpRequest",
      "onError": "continueRegularOutput",
      "position": [
        384,
        560
      ],
      "parameters": {
        "url": "https://api.digiflazz.com/v1/price-list",
        "method": "POST",
        "options": {
          "timeout": 30000,
          "response": {
            "response": {}
          }
        },
        "sendBody": true,
        "sendHeaders": true,
        "bodyParameters": {
          "parameters": [
            {}
          ]
        },
        "headerParameters": {
          "parameters": [
            {
              "name": "Content-Type",
              "value": "application/json"
            }
          ]
        }
      },
      "typeVersion": 4.2
    },
    {
      "id": "74155705-1e36-4684-949e-7d4dbcbdafc4",
      "name": "Format Product List",
      "type": "n8n-nodes-base.code",
      "onError": "continueRegularOutput",
      "position": [
        576,
        560
      ],
      "parameters": {
        "jsCode": "// Format product list response with categorization and pagination\nconst response = $input.first();\n\nif (response.json && response.json.data) {\n  const products = response.json.data;\n  \n  // Group products by category\n  const categories = {};\n  products.forEach(product => {\n    const category = product.category || 'Others';\n    if (!categories[category]) {\n      categories[category] = [];\n    }\n    categories[category].push(product);\n  });\n  \n  // Create menu for categories\n  let message = '\ud83d\udecd\ufe0f *Product Category List*\\n\\n';\n  const buttons = [];\n  const buttonRow = [];\n  \n  Object.keys(categories).forEach((category, index) => {\n    const count = categories[category].length;\n    message += `${index + 1}. ${category} (${count} products)\\n`;\n    \n    buttonRow.push({\n      text: `${category} (${count})`,\n      callbackData: `category_${category.replace(/\\s+/g, '_').toLowerCase()}`\n    });\n    \n    // Add row every 2 buttons\n    if (buttonRow.length === 2) {\n      buttons.push([...buttonRow]);\n      buttonRow.length = 0;\n    }\n  });\n  \n  // Add remaining button if any\n  if (buttonRow.length > 0) {\n    buttons.push(buttonRow);\n  }\n  \n  // Add navigation buttons\n  buttons.push([{\n    text: '\ud83d\udd19 Main Menu',\n    callbackData: 'main_menu'\n  }]);\n  \n  return {\n    json: {\n      success: true,\n      message: message,\n      buttons: buttons,\n      categories: categories\n    }\n  };\n} else {\n  return {\n    json: {\n      success: false,\n      message: '\u274c *Failed to Load Product List*\\n\\n\ud83d\udd0d An error occurred while retrieving product data\\n\ud83d\udca1 Please try again in a few moments',\n      buttons: [[{\n        text: '\ud83d\udd04 Try Again',\n        callbackData: 'list_products'\n      }, {\n        text: '\ud83d\udd19 Main Menu',\n        callbackData: 'main_menu'\n      }]]\n    }\n  };\n}"
      },
      "typeVersion": 2
    },
    {
      "id": "afb9ab0d-2fb6-4b69-8d26-bdebe8196f92",
      "name": "Send Product Categories",
      "type": "n8n-nodes-base.telegram",
      "position": [
        768,
        560
      ],
      "parameters": {
        "text": "={{ $json.message }}",
        "chatId": "={{ $('Telegram Trigger').item.json.message?.chat?.id || $('Telegram Trigger').item.json.callback_query?.message?.chat?.id }}",
        "replyMarkup": {
          "type": "inlineKeyboard",
          "values": "={{ $json.buttons }}"
        },
        "additionalFields": {}
      },
      "credentials": {
        "telegramApi": {
          "name": "<your credential>"
        }
      },
      "typeVersion": 1.2
    },
    {
      "id": "ed41f33f-964c-4c36-a444-c28ea7fdafc0",
      "name": "Deposit Information",
      "type": "n8n-nodes-base.telegram",
      "position": [
        -64,
        752
      ],
      "parameters": {
        "text": "\ud83d\udcb8 *Request Deposit*\n\n\ud83d\udccb To make a deposit, please contact admin with the following information:\n\n\ud83d\udc64 Username: `{{DIGIFLAZZ_USERNAME}}`\n\ud83d\udcb0 Amount: _[Mention the amount you want to deposit]_\n\ud83c\udfe6 Method: _[Bank Transfer / E-Wallet / etc]_\n\n\ud83d\udcde **Admin Contact:**\n\ud83d\udcf1 Telegram: @digiflazzadmin\n\ud83d\udcf2 WhatsApp: 08123456789\n\ud83d\udce7 Email: user@example.com\n\n\u23f0 **Operating Hours:**\nMonday - Friday: 08:00 - 17:00 WIB\nSaturday: 08:00 - 14:00 WIB\n\n\ud83d\udca1 *Tips:* Include transfer proof screenshot for faster processing",
        "chatId": "={{ $json.message?.chat?.id || $json.callback_query?.message?.chat?.id }}",
        "replyMarkup": {
          "type": "inlineKeyboard",
          "values": [
            [
              {
                "text": "\ud83d\udcb0 Check Balance",
                "callbackData": "check_balance"
              },
              {
                "text": "\ud83d\udccb Main Menu",
                "callbackData": "main_menu"
              }
            ]
          ]
        },
        "additionalFields": {}
      },
      "credentials": {
        "telegramApi": {
          "name": "<your credential>"
        }
      },
      "typeVersion": 1.2
    },
    {
      "id": "2e672107-c44d-4e5b-82bf-e2cd03182b2c",
      "name": "Topup Menu",
      "type": "n8n-nodes-base.telegram",
      "position": [
        -64,
        944
      ],
      "parameters": {
        "text": "\ud83d\udcb3 *Prepaid Topup Transaction*\n\nSelect product type for topup:",
        "chatId": "={{ $json.message?.chat?.id || $json.callback_query?.message?.chat?.id }}",
        "replyMarkup": {
          "type": "inlineKeyboard",
          "values": [
            [
              {
                "text": "\ud83d\udcf1 Mobile Credit",
                "callbackData": "topup_pulsa"
              },
              {
                "text": "\ud83d\udcf6 Data Package",
                "callbackData": "topup_data"
              }
            ],
            [
              {
                "text": "\u26a1 PLN Token",
                "callbackData": "topup_pln"
              },
              {
                "text": "\ud83c\udfae Game Voucher",
                "callbackData": "topup_game"
              }
            ],
            [
              {
                "text": "\ud83d\udcb0 E-Wallet",
                "callbackData": "topup_ewallet"
              },
              {
                "text": "\ud83d\udcfa TV Voucher",
                "callbackData": "topup_tv"
              }
            ],
            [
              {
                "text": "\ud83d\udd19 Main Menu",
                "callbackData": "main_menu"
              }
            ]
          ]
        },
        "additionalFields": {}
      },
      "credentials": {
        "telegramApi": {
          "name": "<your credential>"
        }
      },
      "typeVersion": 1.2
    },
    {
      "id": "7b95428d-2374-4b09-8041-eec0b4de3df7",
      "name": "Check Bill Menu",
      "type": "n8n-nodes-base.telegram",
      "position": [
        -64,
        1136
      ],
      "parameters": {
        "text": "\ud83c\udff7\ufe0f *Check Postpaid Bills*\n\nSelect the type of bill you want to check:",
        "chatId": "={{ $json.message?.chat?.id || $json.callback_query?.message?.chat?.id }}",
        "replyMarkup": {
          "type": "inlineKeyboard",
          "values": [
            [
              {
                "text": "\u26a1 PLN Postpaid",
                "callbackData": "checkbill_pln"
              },
              {
                "text": "\ud83d\udcf1 Telkom",
                "callbackData": "checkbill_telkom"
              }
            ],
            [
              {
                "text": "\ud83d\udcfa Cable TV",
                "callbackData": "checkbill_tv"
              },
              {
                "text": "\ud83c\udf10 Internet",
                "callbackData": "checkbill_internet"
              }
            ],
            [
              {
                "text": "\ud83d\udcb0 Credit Card",
                "callbackData": "checkbill_cc"
              },
              {
                "text": "\ud83c\udfe6 Multifinance",
                "callbackData": "checkbill_finance"
              }
            ],
            [
              {
                "text": "\ud83d\udca7 PDAM",
                "callbackData": "checkbill_pdam"
              },
              {
                "text": "\ud83d\udcfb Radio",
                "callbackData": "checkbill_radio"
              }
            ],
            [
              {
                "text": "\ud83d\udd19 Main Menu",
                "callbackData": "main_menu"
              }
            ]
          ]
        },
        "additionalFields": {}
      },
      "credentials": {
        "telegramApi": {
          "name": "<your credential>"
        }
      },
      "typeVersion": 1.2
    },
    {
      "id": "2a430daf-17d2-4873-a39b-d3efb301a019",
      "name": "Pay Bill Menu",
      "type": "n8n-nodes-base.telegram",
      "position": [
        -64,
        1328
      ],
      "parameters": {
        "text": "\ud83d\udcb0 *Pay Bills*\n\nSelect the type of bill you want to pay:",
        "chatId": "={{ $json.message?.chat?.id || $json.callback_query?.message?.chat?.id }}",
        "replyMarkup": {
          "type": "inlineKeyboard",
          "values": [
            [
              {
                "text": "\u26a1 PLN Postpaid",
                "callbackData": "paybill_pln"
              },
              {
                "text": "\ud83d\udcf1 Telkom",
                "callbackData": "paybill_telkom"
              }
            ],
            [
              {
                "text": "\ud83d\udcfa Cable TV",
                "callbackData": "paybill_tv"
              },
              {
                "text": "\ud83c\udf10 Internet",
                "callbackData": "paybill_internet"
              }
            ],
            [
              {
                "text": "\ud83d\udcb0 Credit Card",
                "callbackData": "paybill_cc"
              },
              {
                "text": "\ud83c\udfe6 Multifinance",
                "callbackData": "paybill_finance"
              }
            ],
            [
              {
                "text": "\ud83d\udca7 PDAM",
                "callbackData": "paybill_pdam"
              },
              {
                "text": "\ud83d\udcfb Radio",
                "callbackData": "paybill_radio"
              }
            ],
            [
              {
                "text": "\ud83d\udd19 Main Menu",
                "callbackData": "main_menu"
              }
            ]
          ]
        },
        "additionalFields": {}
      },
      "credentials": {
        "telegramApi": {
          "name": "<your credential>"
        }
      },
      "typeVersion": 1.2
    },
    {
      "id": "0bc59035-ccc6-4a29-990e-01ec85a2825e",
      "name": "Process Topup Selection",
      "type": "n8n-nodes-base.code",
      "onError": "continueRegularOutput",
      "position": [
        192,
        944
      ],
      "parameters": {
        "jsCode": "// Extract callback data and prepare topup transaction\nconst callbackData = $('Telegram Trigger').item.json.callback_query.data;\nconst productType = callbackData.replace('topup_', '');\n\n// Set user state for awaiting input\nconst userId = $('Telegram Trigger').item.json.callback_query.from.id;\n\nlet message = '';\nlet inputPrompt = '';\n\nswitch(productType) {\n  case 'pulsa':\n    message = '\ud83d\udcf1 *Mobile Credit Topup*\\n\\n\u2139\ufe0f Enter the mobile number to be topped up:\\n\\n*Format:* 08123456789\\n*Example:* 081234567890';\n    inputPrompt = 'Enter mobile number:';\n    break;\n  case 'data':\n    message = '\ud83d\udcf6 *Data Package Topup*\\n\\n\u2139\ufe0f Enter mobile number for data package:\\n\\n*Format:* 08123456789\\n*Example:* 081234567890';\n    inputPrompt = 'Enter mobile number:';\n    break;\n  case 'pln':\n    message = '\u26a1 *PLN Token Topup*\\n\\n\u2139\ufe0f Enter PLN meter number:\\n\\n*Format:* 12345678901\\n*Example:* 12345678901 (11 digits)';\n    inputPrompt = 'Enter PLN meter number:';\n    break;\n  case 'game':\n    message = '\ud83c\udfae *Game Voucher Topup*\\n\\n\u2139\ufe0f Enter game User ID:\\n\\n*Format:* 123456789\\n*Example:* Mobile Legends: 123456789 (1234)';\n    inputPrompt = 'Enter User ID:';\n    break;\n  case 'ewallet':\n    message = '\ud83d\udcb0 *E-Wallet Topup*\\n\\n\u2139\ufe0f Enter e-wallet mobile number:\\n\\n*Format:* 08123456789\\n*Example:* 081234567890';\n    inputPrompt = 'Enter mobile number:';\n    break;\n  case 'tv':\n    message = '\ud83d\udcfa *TV Voucher Topup*\\n\\n\u2139\ufe0f Enter customer number:\\n\\n*Format:* 12345678\\n*Example:* 12345678';\n    inputPrompt = 'Enter customer number:';\n    break;\n  default:\n    message = '\u274c Unknown product type';\n}\n\nreturn {\n  json: {\n    message: message,\n    productType: productType,\n    userId: userId,\n    step: 'awaiting_number',\n    inputPrompt: inputPrompt\n  }\n};\n\n// Enhanced input validation and session management\nconst messageText = $('Telegram Trigger').item.json.message?.text;\nconst userId = $('Telegram Trigger').item.json.message?.from?.id;\n\n// Validation functions\nfunction validatePhoneNumber(phone) {\n  const phoneRegex = /^(\\+62|62|0)([0-9]{9,12})$/;\n  return phoneRegex.test(phone.replace(/[-\\s]/g, ''));\n}\n\nfunction validatePLNNumber(pln) {\n  const plnRegex = /^[0-9]{11,12}$/;\n  return plnRegex.test(pln);\n}\n\nfunction validateAmount(amount) {\n  const num = parseFloat(amount.replace(/[^\\d]/g, ''));\n  return num >= 10000 && num <= 10000000; // 10k - 10M\n}\n\n// Session state management (simple in-memory for demo)\n// In production, use Redis or database\nconst userSessions = global.userSessions || (global.userSessions = {});\n\nreturn {\n  json: {\n    validation: {\n      validatePhoneNumber,\n      validatePLNNumber,\n      validateAmount\n    },\n    session: userSessions[userId] || {},\n    userId: userId,\n    messageText: messageText\n  }\n};"
      },
      "typeVersion": 2
    },
    {
      "id": "fdb35679-50ed-4f18-b967-546af8dfa98b",
      "name": "Process Check Bill Selection",
      "type": "n8n-nodes-base.code",
      "onError": "continueRegularOutput",
      "position": [
        192,
        1136
      ],
      "parameters": {
        "jsCode": "// Extract callback data and prepare check bill inquiry\nconst callbackData = $('Telegram Trigger').item.json.callback_query.data;\nconst billType = callbackData.replace('checkbill_', '');\n\n// Set user state for awaiting input\nconst userId = $('Telegram Trigger').item.json.callback_query.from.id;\n\nlet message = '';\nlet inputPrompt = '';\n\nswitch(billType) {\n  case 'pln':\n    message = '\u26a1 *Check PLN Postpaid Bill*\\n\\n\u2139\ufe0f Enter PLN Customer ID:\\n\\n*Format:* 123456789012\\n*Example:* 123456789012 (12 digits)';\n    inputPrompt = 'Enter PLN Customer ID:';\n    break;\n  case 'telkom':\n    message = '\ud83d\udcf1 *Check Telkom Bill*\\n\\n\u2139\ufe0f Enter Telkom phone number:\\n\\n*Format:* 021xxxxxxx\\n*Example:* 02112345678';\n    inputPrompt = 'Enter phone number:';\n    break;\n  case 'tv':\n    message = '\ud83d\udcfa *Check Cable TV Bill*\\n\\n\u2139\ufe0f Enter TV customer number:\\n\\n*Format:* 12345678\\n*Example:* 12345678';\n    inputPrompt = 'Enter customer number:';\n    break;\n  case 'internet':\n    message = '\ud83c\udf10 *Check Internet Bill*\\n\\n\u2139\ufe0f Enter Internet customer number:\\n\\n*Format:* 123456789\\n*Example:* 123456789';\n    inputPrompt = 'Enter customer number:';\n    break;\n  case 'cc':\n    message = '\ud83d\udcb0 *Check Credit Card Bill*\\n\\n\u2139\ufe0f Enter credit card number:\\n\\n*Format:* 4xxx-xxxx-xxxx-xxxx\\n*Example:* 4111-1111-1111-1111';\n    inputPrompt = 'Enter card number:';\n    break;\n  case 'finance':\n    message = '\ud83c\udfe6 *Check Multifinance Bill*\\n\\n\u2139\ufe0f Enter contract number:\\n\\n*Format:* 123456789\\n*Example:* 123456789';\n    inputPrompt = 'Enter contract number:';\n    break;\n  case 'pdam':\n    message = '\ud83d\udca7 *Check PDAM Bill*\\n\\n\u2139\ufe0f Enter PDAM customer number:\\n\\n*Format:* 123456789\\n*Example:* 123456789';\n    inputPrompt = 'Enter customer number:';\n    break;\n  default:\n    message = '\u274c Unknown bill type';\n}\n\nreturn {\n  json: {\n    message: message,\n    billType: billType,\n    userId: userId,\n    step: 'awaiting_customer_id',\n    inputPrompt: inputPrompt\n  }\n};\n\n// Enhanced input validation and session management\nconst messageText = $('Telegram Trigger').item.json.message?.text;\nconst userId = $('Telegram Trigger').item.json.message?.from?.id;\n\n// Validation functions\nfunction validatePhoneNumber(phone) {\n  const phoneRegex = /^(\\+62|62|0)([0-9]{9,12})$/;\n  return phoneRegex.test(phone.replace(/[-\\s]/g, ''));\n}\n\nfunction validatePLNNumber(pln) {\n  const plnRegex = /^[0-9]{11,12}$/;\n  return plnRegex.test(pln);\n}\n\nfunction validateAmount(amount) {\n  const num = parseFloat(amount.replace(/[^\\d]/g, ''));\n  return num >= 10000 && num <= 10000000; // 10k - 10M\n}\n\n// Session state management (simple in-memory for demo)\n// In production, use Redis or database\nconst userSessions = global.userSessions || (global.userSessions = {});\n\nreturn {\n  json: {\n    validation: {\n      validatePhoneNumber,\n      validatePLNNumber,\n      validateAmount\n    },\n    session: userSessions[userId] || {},\n    userId: userId,\n    messageText: messageText\n  }\n};"
      },
      "typeVersion": 2
    },
    {
      "id": "6e617253-ce99-4ab5-bac5-c4b22bda1ec8",
      "name": "Process Pay Bill Selection",
      "type": "n8n-nodes-base.code",
      "onError": "continueRegularOutput",
      "position": [
        192,
        1328
      ],
      "parameters": {
        "jsCode": "// Extract callback data and prepare pay bill transaction\nconst callbackData = $('Telegram Trigger').item.json.callback_query.data;\nconst billType = callbackData.replace('paybill_', '');\n\n// Set user state for awaiting input\nconst userId = $('Telegram Trigger').item.json.callback_query.from.id;\n\nlet message = '';\nlet inputPrompt = '';\n\nswitch(billType) {\n  case 'pln':\n    message = '\u26a1 *Pay PLN Postpaid Bill*\\n\\n\u2139\ufe0f Enter PLN Customer ID:\\n\\n*Format:* 123456789012\\n*Example:* 123456789012 (12 digits)\\n\\n\ud83d\udca1 *Tips:* Make sure to check the bill before paying';\n    inputPrompt = 'Enter PLN Customer ID:';\n    break;\n  case 'telkom':\n    message = '\ud83d\udcf1 *Pay Telkom Bill*\\n\\n\u2139\ufe0f Enter Telkom phone number:\\n\\n*Format:* 021xxxxxxx\\n*Example:* 02112345678\\n\\n\ud83d\udca1 *Tips:* Make sure to check the bill before paying';\n    inputPrompt = 'Enter phone number:';\n    break;\n  case 'tv':\n    message = '\ud83d\udcfa *Pay Cable TV Bill*\\n\\n\u2139\ufe0f Enter TV customer number:\\n\\n*Format:* 12345678\\n*Example:* 12345678\\n\\n\ud83d\udca1 *Tips:* Make sure to check the bill before paying';\n    inputPrompt = 'Enter customer number:';\n    break;\n  case 'internet':\n    message = '\ud83c\udf10 *Pay Internet Bill*\\n\\n\u2139\ufe0f Enter Internet customer number:\\n\\n*Format:* 123456789\\n*Example:* 123456789\\n\\n\ud83d\udca1 *Tips:* Make sure to check the bill before paying';\n    inputPrompt = 'Enter customer number:';\n    break;\n  case 'cc':\n    message = '\ud83d\udcb0 *Pay Credit Card Bill*\\n\\n\u2139\ufe0f Enter credit card number:\\n\\n*Format:* 4xxx-xxxx-xxxx-xxxx\\n*Example:* 4111-1111-1111-1111\\n\\n\ud83d\udca1 *Tips:* Make sure to check the bill before paying';\n    inputPrompt = 'Enter card number:';\n    break;\n  case 'finance':\n    message = '\ud83c\udfe6 *Pay Multifinance Bill*\\n\\n\u2139\ufe0f Enter contract number:\\n\\n*Format:* 123456789\\n*Example:* 123456789\\n\\n\ud83d\udca1 *Tips:* Make sure to check the bill before paying';\n    inputPrompt = 'Enter contract number:';\n    break;\n  case 'pdam':\n    message = '\ud83d\udca7 *Pay PDAM Bill*\\n\\n\u2139\ufe0f Enter PDAM customer number:\\n\\n*Format:* 123456789\\n*Example:* 123456789\\n\\n\ud83d\udca1 *Tips:* Make sure to check the bill before paying';\n    inputPrompt = 'Enter customer number:';\n    break;\n  default:\n    message = '\u274c Unknown bill type';\n}\n\nreturn {\n  json: {\n    message: message,\n    billType: billType,\n    userId: userId,\n    step: 'awaiting_customer_id_pay',\n    inputPrompt: inputPrompt\n  }\n};\n\n// Enhanced input validation and session management\nconst messageText = $('Telegram Trigger').item.json.message?.text;\nconst userId = $('Telegram Trigger').item.json.message?.from?.id;\n\n// Validation functions\nfunction validatePhoneNumber(phone) {\n  const phoneRegex = /^(\\+62|62|0)([0-9]{9,12})$/;\n  return phoneRegex.test(phone.replace(/[-\\s]/g, ''));\n}\n\nfunction validatePLNNumber(pln) {\n  const plnRegex = /^[0-9]{11,12}$/;\n  return plnRegex.test(pln);\n}\n\nfunction validateAmount(amount) {\n  const num = parseFloat(amount.replace(/[^\\d]/g, ''));\n  return num >= 10000 && num <= 10000000; // 10k - 10M\n}\n\n// Session state management (simple in-memory for demo)\n// In production, use Redis or database\nconst userSessions = global.userSessions || (global.userSessions = {});\n\nreturn {\n  json: {\n    validation: {\n      validatePhoneNumber,\n      validatePLNNumber,\n      validateAmount\n    },\n    session: userSessions[userId] || {},\n    userId: userId,\n    messageText: messageText\n  }\n};"
      },
      "typeVersion": 2
    },
    {
      "id": "f74d13ac-93ec-42f7-9faa-e59ae4107784",
      "name": "Send Topup Input Prompt",
      "type": "n8n-nodes-base.telegram",
      "position": [
        384,
        944
      ],
      "parameters": {
        "text": "={{ $json.message }}",
        "chatId": "={{ $('Telegram Trigger').item.json.callback_query?.message?.chat?.id }}",
        "replyMarkup": {
          "type": "inlineKeyboard",
          "values": [
            [
              {
                "text": "\u274c Cancel",
                "callbackData": "new_transaction"
              },
              {
                "text": "\ud83d\udd19 Main Menu",
                "callbackData": "main_menu"
              }
            ]
          ]
        },
        "additionalFields": {}
      },
      "credentials": {
        "telegramApi": {
          "name": "<your credential>"
        }
      },
      "typeVersion": 1.2
    },
    {
      "id": "b4755d61-45f8-4b61-b569-91f6637fa535",
      "name": "Send Check Bill Input Prompt",
      "type": "n8n-nodes-base.telegram",
      "position": [
        384,
        1136
      ],
      "parameters": {
        "text": "={{ $json.message }}",
        "chatId": "={{ $('Telegram Trigger').item.json.callback_query?.message?.chat?.id }}",
        "replyMarkup": {
          "type": "inlineKeyboard",
          "values": [
            [
              {
                "text": "\u274c Cancel",
                "callbackData": "check_bills"
              },
              {
                "text": "\ud83d\udd19 Main Menu",
                "callbackData": "main_menu"
              }
            ]
          ]
        },
        "additionalFields": {}
      },
      "credentials": {
        "telegramApi": {
          "name": "<your credential>"
        }
      },
      "typeVersion": 1.2
    },
    {
      "id": "c36b29d2-73d0-4b87-9b7e-1c2a053aea45",
      "name": "Send Pay Bill Input Prompt",
      "type": "n8n-nodes-base.telegram",
      "position": [
        384,
        1328
      ],
      "parameters": {
        "text": "={{ $json.message }}",
        "chatId": "={{ $('Telegram Trigger').item.json.callback_query?.message?.chat?.id }}",
        "replyMarkup": {
          "type": "inlineKeyboard",
          "values": [
            [
              {
                "text": "\u274c Cancel",
                "callbackData": "pay_bills"
              },
              {
                "text": "\ud83d\udd19 Main Menu",
                "callbackData": "main_menu"
              }
            ]
          ]
        },
        "additionalFields": {}
      },
      "credentials": {
        "telegramApi": {
          "name": "<your credential>"
        }
      },
      "typeVersion": 1.2
    },
    {
      "id": "92ffd1c4-6cb2-4328-a12d-b771ea582357",
      "name": "Transaction History",
      "type": "n8n-nodes-base.telegram",
      "position": [
        -64,
        1552
      ],
      "parameters": {
        "text": "\ud83d\udcc8 *Transaction History*\n\nTransaction history for the last 7 days:",
        "chatId": "={{ $json.message?.chat?.id || $json.callback_query?.message?.chat?.id }}",
        "replyMarkup": {
          "type": "inlineKeyboard",
          "values": [
            [
              {
                "text": "\ud83d\udcb0 Check Balance",
                "callbackData": "check_balance"
              },
              {
                "text": "\ud83d\udd19 Main Menu",
                "callbackData": "main_menu"
              }
            ]
          ]
        },
        "additionalFields": {}
      },
      "credentials": {
        "telegramApi": {
          "name": "<your credential>"
        }
      },
      "typeVersion": 1.2
    },
    {
      "id": "c2752415-3b20-4988-be7a-4fea731b2fe2",
      "name": "Process Deposit Information",
      "type": "n8n-nodes-base.code",
      "onError": "continueRegularOutput",
      "position": [
        192,
        752
      ],
      "parameters": {
        "jsCode": "// Process deposit request information\nconst userId = $('Telegram Trigger').item.json.callback_query?.from?.id;\nconst username = $('Telegram Trigger').item.json.callback_query?.from?.username || 'user';\n\nconst message = `\ud83d\udcb8 *Request Deposit - Complete Information*\n\n\ud83d\udccb **Required Information:**\n\u2022 Username: \\`{{DIGIFLAZZ_USERNAME}}\\`\n\u2022 Telegram ID: \\`${userId}\\`\n\u2022 Username: @${username}\n\n\ud83d\udcb0 **Deposit Methods:**\n\ud83c\udfe6 Bank Transfer (BCA, Mandiri, BRI, BNI)\n\ud83d\udcb3 E-Wallet (OVO, DANA, GoPay, ShopeePay)\n\ud83c\udfea Convenience Store (Alfamart, Indomaret)\n\n\ud83d\udcde **Contact Admin:**\n\ud83d\udcf1 Telegram: @digiflazzadmin\n\ud83d\udcf2 WhatsApp: +1234567890\n\ud83d\udce7 Email: user@example.com\n\n\u23f0 **Processing Time:**\n\u2022 Bank Transfer: 1-15 minutes\n\u2022 E-Wallet: Instant\n\u2022 Convenience Store: 1-24 hours\n\n\ud83d\udca1 **Tips:**\n\u2022 Minimum deposit: Rp 50,000\n\u2022 Include your username in transfer notes\n\u2022 Send transfer proof for faster processing`;\n\nreturn {\n  json: {\n    message: message,\n    success: true\n  }\n};"
      },
      "typeVersion": 2
    },
    {
      "id": "3862bfa3-98f2-476e-a35e-4b3698073e4f",
      "name": "Send Deposit Information",
      "type": "n8n-nodes-base.telegram",
      "position": [
        384,
        752
      ],
      "parameters": {
        "text": "={{ $json.message }}",
        "chatId": "={{ $('Telegram Trigger').item.json.callback_query?.message?.chat?.id }}",
        "replyMarkup": {
          "type": "inlineKeyboard",
          "values": [
            [
              {
                "text": "\u274c Cancel",
                "callbackData": "new_transaction"
              },
              {
                "text": "\ud83d\udd19 Main Menu",
                "callbackData": "main_menu"
              }
            ]
          ]
        },
        "additionalFields": {}
      },
      "credentials": {
        "telegramApi": {
          "name": "<your credential>"
        }
      },
      "typeVersion": 1.2
    },
    {
      "id": "a1517503-b1e2-414e-81c4-c29d2d3d90b4",
      "name": "Process Trancation History Information",
      "type": "n8n-nodes-base.code",
      "onError": "continueRegularOutput",
      "position": [
        192,
        1552
      ],
      "parameters": {
        "jsCode": "// Generate MD5 signature for transaction history\nconst crypto = require('crypto');\nconst username = '{{DIGIFLAZZ_USERNAME}}';\nconst apiKey = '{{DIGIFLAZZ_API_KEY}}';\nconst command = 'history';\n\nconst signature = crypto.createHash('md5').update(username + apiKey + command).digest('hex');\n\nreturn {\n  json: {\n    cmd: 'history',\n    username: username,\n    sign: signature,\n    start_date: new Date(Date.now() - 7*24*60*60*1000).toISOString().split('T')[0], // 7 days ago\n    end_date: new Date().toISOString().split('T')[0] // today\n  }\n};"
      },
      "typeVersion": 2
    },
    {
      "id": "254c70d2-1307-4bf5-84aa-20efb571c154",
      "name": "Send Transaction Information",
      "type": "n8n-nodes-base.telegram",
      "position": [
        384,
        1552
      ],
      "parameters": {
        "text": "={{ $json.message }}",
        "chatId": "={{ $('Telegram Trigger').item.json.callback_query?.message?.chat?.id }}",
        "replyMarkup": {
          "type": "inlineKeyboard",
          "values": [
            [
              {
                "text": "\u274c Cancel",
                "callbackData": "new_transaction"
              },
              {
                "text": "\ud83d\udd19 Main Menu",
                "callbackData": "main_menu"
              }
            ]
          ]
        },
        "additionalFields": {}
      },
      "credentials": {
        "telegramApi": {
          "name": "<your credential>"
        }
      },
      "typeVersion": 1.2
    },
    {
      "id": "034d39ee-eceb-4049-a3e9-2dfd98af03ae",
      "name": "Process Menu",
      "type": "n8n-nodes-base.code",
      "onError": "continueRegularOutput",
      "position": [
        144,
        176
      ],
      "parameters": {
        "jsCode": "// Loop over input items and add a new field called 'myNewField' to the JSON of each one\nfor (const item of $input.all()) {\n  item.json.myNewField = 1;\n}\n\nreturn $input.all();"
      },
      "typeVersion": 2
    },
    {
      "id": "de28f03f-0cb6-4fcb-879f-10cebfbab73a",
      "name": "Send Menu Information",
      "type": "n8n-nodes-base.telegram",
      "position": [
        336,
        176
      ],
      "parameters": {
        "text": "={{ $json.message }}",
        "chatId": "={{ $('Telegram Trigger').item.json.callback_query?.message?.chat?.id }}",
        "replyMarkup": {
          "type": "inlineKeyboard",
          "values": [
            [
              {
                "text": "\u274c Cancel",
                "callbackData": "new_transaction"
              },
              {
                "text": "\ud83d\udd19 Main Menu",
                "callbackData": "main_menu"
              }
            ]
          ]
        },
        "additionalFields": {}
      },
      "credentials": {
        "telegramApi": {
          "name": "<your credential>"
        }
      },
      "typeVersion": 1.2
    },
    {
      "id": "5efd4173-86f0-4832-a337-230e8943d6d6",
      "name": "Process Welcome",
      "type": "n8n-nodes-base.code",
      "onError": "continueRegularOutput",
      "position": [
        144,
        -16
      ],
      "parameters": {
        "jsCode": "// Loop over input items and add a new field called 'myNewField' to the JSON of each one\nfor (const item of $input.all()) {\n  item.json.myNewField = 1;\n}\n\nreturn $input.all();"
      },
      "typeVersion": 2
    },
    {
      "id": "b4217d6a-3aa3-4c26-a85a-2d9fd3a3af38",
      "name": "Send Welcome",
      "type": "n8n-nodes-base.telegram",
      "position": [
        336,
        -16
      ],
      "parameters": {
        "text": "={{ $json.message }}",
        "chatId": "={{ $('Telegram Trigger').item.json.callback_query?.message?.chat?.id }}",
        "replyMarkup": {
          "type": "inlineKeyboard",
          "values": [
            [
              {
                "text": "\u274c Cancel",
                "callbackData": "new_transaction"
              },
              {
                "text": "\ud83d\udd19 Main Menu",
                "callbackData": "main_menu"
              }
            ]
          ]
        },
        "additionalFields": {}
      },
      "credentials": {
        "telegramApi": {
          "name": "<your credential>"
        }
      },
      "typeVersion": 1.2
    },
    {
      "id": "7daf6540-2b6b-46f7-946f-c0dc7ec03190",
      "name": "Execute Transaction API",
      "type": "n8n-nodes-base.httpRequest",
      "onError": "continueRegularOutput",
      "position": [
        736,
        992
      ],
      "parameters": {
        "url": "https://api.digiflazz.com/v1/transaction",
        "method": "POST",
        "options": {
          "timeout": 30000
        },
        "sendBody": true,
        "sendHeaders": true,
        "bodyParameters": {
          "parameters": [
            {}
          ]
        },
        "headerParameters": {
          "parameters": [
            {
              "name": "Content-Type",
              "value": "application/json"
            }
          ]
        }
      },
      "typeVersion": 4.2
    },
    {
      "id": "cc088e6d-3611-411d-99c8-e0311aad801f",
      "name": "Bill Inquiry API",
      "type": "n8n-nodes-base.httpRequest",
      "onError": "continueRegularOutput",
      "position": [
        736,
        1184
      ],
      "parameters": {
        "url": "https://api.digiflazz.com/v1/inquiry",
        "method": "POST",
        "options": {
          "timeout": 30000
        },
        "sendBody": true,
        "sendHeaders": true,
        "bodyParameters": {
          "parameters": [
            {}
          ]
        },
        "headerParameters": {
          "parameters": [
            {
              "name": "Content-Type",
              "value": "application/json"
            }
          ]
        }
      },
      "typeVersion": 4.2
    },
    {
      "id": "58a3cb4b-e01d-4ce0-9b0c-d8ed8a68bda4",
      "name": "Sticky Note",
      "type": "n8n-nodes-base.stickyNote",
      "position": [
        -864,
        336
      ],
      "parameters": {
        "width": 400,
        "height": 2288,
        "content": "## Digiflazz Management \u2014 Telegram Bot (n8n)\n\n**Install & Usage Guide**\n\n## What this workflow does\n\nA Telegram bot to manage your PPOB business:\n\n* Check **deposit balance**\n* Browse **product price list**\n* Start **prepaid topups**\n* **Check** and **pay** postpaid bills\n* Show **transaction history**\n  (Inline keyboards + message/callback handling are included.)\n\n## Prerequisites\n\n* n8n up and running (self-hosted or desktop).\n* A **Telegram Bot Token** (create via @BotFather).\n* A **Digiflazz** account with **Username** and **API Key**.\n\n## Environment variables (set in n8n)\n\n* `DIGIFLAZZ_USERNAME` = your Digiflazz username\n* `DIGIFLAZZ_API_KEY` = your Digiflazz API key\n\n> n8n \u2192 Settings (or container env) \u2192 add the vars \u2192 restart if needed.\n\n## Install steps\n\n1. **Import** the workflow JSON into n8n.\n2. Open **Telegram Trigger** \u2192 select your **Telegram credentials**.\n\n   * Updates listened: `message` & `callback_query` (already configured).\n3. **Activate** the workflow.\n4. On Telegram, DM your bot and send `/start`.\n\n## How to use (commands & buttons)\n\n* `/start` \u2192 Welcome & quick actions.\n* `/menu` \u2192 Main menu:\n\n  * **\ud83d\udcb0 Check Balance** \u2192 calls `cek-saldo` and formats status with traffic-light icons (Red < Rp100k, Yellow < Rp500k, Green \u2265 Rp500k). Timestamp uses **Asia/Jakarta**.\n  * **\ud83d\udecd\ufe0f Product List** \u2192 calls `price-list`, groups by category, renders inline buttons.\n  * **\ud83d\udcb3 Prepaid Topup** \u2192 choose product type (Pulsa/Data/PLN/Game/E-Wallet/TV). Bot prompts for the required number/ID.\n  * **\ud83c\udff7\ufe0f Check Bills** / **\ud83d\udcb0 Pay Bills** \u2192 choose bill type, bot prompts for customer ID; workflow prepares inquiry/payment call.\n  * **\ud83d\udcb8 Deposit** \u2192 shows admin contact & deposit tips.\n  * **\ud83d\udcc8 History** \u2192 scaffold provided for last 7 days.\n\n## Under the hood (API & signing)\n\n* **MD5 signature** is built in Code nodes using Node\u2019s `crypto`, e.g.\n  `md5(username + apiKey + 'pricelist' | 'depo' | 'history')`.\n* HTTP nodes hit Digiflazz endpoints: `cek-saldo`, `price-list`, `transaction`, `inquiry`.\n* Switch router maps `/start`, `/menu`, and inline `callback_data` to the right branch.\n\n## Customize\n\n* Update admin contacts/text in **Telegram** nodes to your details.\n* Map additional product/bill flows and payload fields as needed.\n* For production, replace the simple in-memory session in Code nodes with **Redis/DB**.\n\n## Notes & gaps\n\n* **Transaction History** and **category-level product clicks** are scaffolded; add the missing HTTP calls/routers if you want full results in chat.\n* Keep your API key in env vars\u2014**never** hard-code in nodes.\n\n**Quick test**\n\n1. Send `/start` \u2192 tap **\ud83d\udcb0 Check Balance**.\n2. Tap **\ud83d\udecd\ufe0f Product List** \u2192 see grouped categories.\n3. Tap **\ud83d\udcb3 Prepaid Topup** \u2192 follow prompts.\n\n"
      },
      "typeVersion": 1
    }
  ],
  "active": false,
  "settings": {
    "executionOrder": "v1"
  },
  "versionId": "0e51bd46-1467-478c-9f89-9183327ab66d",
  "connections": {
    "Main Menu": {
      "main": [
        [
          {
            "node": "Process Menu",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "Topup Menu": {
      "main": [
        [
          {
            "node": "Process Topup Selection",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "Process Menu": {
      "main": [
        [
          {
            "node": "Send Menu Information",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "Pay Bill Menu": {
      "main": [
        [
          {
            "node": "Process Pay Bill Selection",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "Check Bill Menu": {
      "main": [
        [
          {
            "node": "Process Check Bill Selection",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "Process Welcome": {
      "main": [
        [
          {
            "node": "Send Welcome",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "Welcome Message": {
      "main": [
        [
          {
            "node": "Process Welcome",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "Get Products API": {
      "main": [
        [
          {
            "node": "Format Product List",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "Telegram Trigger": {
      "main": [
        [
          {
            "node": "Main Command Router",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "Check Balance API": {
      "main": [
        [
          {
            "node": "Format Balance Response",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "Deposit Information": {
      "main": [
        [
          {
            "node": "Process Deposit Information",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "Format Product List": {
      "main": [
        [
          {
            "node": "Send Product Categories",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "Main Command Router": {
      "main": [
        [
          {
            "node": "Welcome Message",
            "type": "main",
            "index": 0
          }
        ],
        [
          {
            "node": "Main Menu",
            "type": "main",
            "index": 0
          }
        ],
        [
          {
            "node": "Generate Balance Signature",
            "type": "main",
            "index": 0
          }
        ],
        [
          {
            "node": "Generate Product Signature",
            "type": "main",
            "index": 0
          }
        ],
        [
          {
            "node": "Topup Menu",
            "type": "main",
            "index": 0
          }
        ],
        [
          {
            "node": "Deposit Information",
            "type": "main",
            "index": 0
          }
        ],
        [
          {
            "node": "Check Bill Menu",
            "type": "main",
            "index": 0
          }
        ],
        [
          {
            "node": "Pay Bill Menu",
            "type": "main",
            "index": 0
          }
        ],
        [
          {
            "node": "Transaction History",
            "type": "main",
            "index": 0
          }
        ],
        [
          {
            "node": "Process Topup Selection",
            "type": "main",
            "index": 0
          }
        ],
        [
          {
            "node": "Process Check Bill Selection",
            "type": "main",
            "index": 0
          }
        ],
        [
          {
            "node": "Process Pay Bill Selection",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "Transaction History": {
      "main": [
        [
          {
            "node": "Process Trancation History Information",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "Format Balance Response": {
      "main": [
        [
          {
            "node": "Send Balance Result",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "Process Topup Selection": {
      "main": [
        [
          {
            "node": "Send Topup Input Prompt",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "Send Topup Input Prompt": {
      "main": [
        [
          {
            "node": "Execute Transaction API",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "Send Deposit Information": {
      "main": [
        [
          {
            "node": "Execute Transaction API",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "Generate Balance Signature": {
      "main": [
        [
          {
            "node": "Check Balance API",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "Generate Product Signature": {
      "main": [
        [
          {
            "node": "Get Products API",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "Process Pay Bill Selection": {
      "main": [
        [
          {
            "node": "Send Pay Bill Input Prompt",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "Send Pay Bill Input Prompt": {
      "main": [
        [
          {
            "node": "Bill Inquiry API",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "Process Deposit Information": {
      "main": [
        [
          {
            "node": "Send Deposit Information",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "Process Check Bill Selection": {
      "main": [
        [
          {
            "node": "Send Check Bill Input Prompt",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "Send Check Bill Input Prompt": {
      "main": [
        [
          {
            "node": "Bill Inquiry API",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "Process Trancation History Information": {
      "main": [
        [
          {
            "node": "Send Transaction Information",
            "type": "main",
            "index": 0
          }
        ]
      ]
    }
  }
}