{ "name": "Telegram Approval", "nodes": [ { "parameters": { "updates": [ "callback_query", "message" ], "additionalFields": {} }, "type": "n8n-nodes-base.telegramTrigger", "typeVersion": 1.2, "position": [ -1728, -320 ], "id": "4c150b2d-770c-4a74-9df3-004be4f6a944", "name": "Telegram Trigger", "webhookId": "eeb72c47-01de-451e-b2b6-3cd8c11ff1d7", "credentials": { "telegramApi": { "id": "VXVmxxPXgnlOCO0Z", "name": "NOAH" } } }, { "parameters": { "method": "POST", "url": "=https://dealhunter.app.n8n.cloud/webhook-waiting/{{ $json.execution_id }}", "sendBody": true, "bodyParameters": { "parameters": [ { "name": "approved", "value": "={{ $json.approval }}" }, { "name": "feedback", "value": "={{ $json.feedback }}" } ] }, "options": {} }, "type": "n8n-nodes-base.httpRequest", "typeVersion": 4.3, "position": [ -832, -320 ], "id": "2d72f432-d922-4400-8b93-6cb9a3b70a03", "name": "HTTP Request" }, { "parameters": { "assignments": { "assignments": [ { "id": "67f0375d-032e-472b-b0cf-b066365801fc", "name": "feedback", "value": "={{ $json.message.text }}", "type": "string" }, { "id": "7bc184cf-96b6-4a7a-b55a-5f581265ef76", "name": "approval", "value": "={{ $json.callback_query.data }}", "type": "boolean" }, { "id": "e3a0083a-848d-440b-bcda-f9054344e31c", "name": "message.id", "value": "={{ $json.callback_query.message.from.id }}", "type": "number" }, { "id": "0df775e8-c7ef-4221-8361-c52963039c8f", "name": "execution_id", "value": "={{ $json.callback_query.data }}", "type": "string" } ] }, "options": { "ignoreConversionErrors": true } }, "type": "n8n-nodes-base.set", "typeVersion": 3.4, "position": [ -1280, -224 ], "id": "0feceaf6-ad30-437b-baf0-d441a3b3e6e4", "name": "Approval data" }, { "parameters": { "conditions": { "options": { "caseSensitive": true, "leftValue": "", "typeValidation": "strict", "version": 3 }, "conditions": [ { "id": "5a63f9f0-5f59-4c99-b8e5-de28b674d240", "leftValue": "={{ $json.message.text }}", "rightValue": "", "operator": { "type": "string", "operation": "exists", "singleValue": true } } ], "combinator": "and" }, "options": {} }, "type": "n8n-nodes-base.if", "typeVersion": 2.3, "position": [ -1504, -320 ], "id": "5a113d6c-e305-4dd1-a965-5153beb3215e", "name": "If" }, { "parameters": { "assignments": { "assignments": [ { "id": "2606ed8b-11f6-4291-aaab-705dc226e0ef", "name": "feedback", "value": "={{ $json.message.text }}", "type": "string" }, { "id": "0221d2d7-a0d2-4920-b6cb-c7362510c813", "name": "execution_id", "value": "={{ $json.message.reply_to_message.reply_markup.inline_keyboard[0][1].callback_data }}", "type": "string" } ] }, "options": {} }, "type": "n8n-nodes-base.set", "typeVersion": 3.4, "position": [ -1280, -416 ], "id": "0df60af7-c1c0-4637-9219-c3d4d58b715e", "name": "Feedback" }, { "parameters": { "jsCode": "// This loop ensures the code runs for every item in the current execution\nreturn items.map(item => {\n // 1. Get the data from the previous \"Approval data\" node\n // We use item.json.execution_id to match your Set node exactly\n const rawExecutionData = item.json.execution_id || \"\";\n const feedbackText = item.json.feedback || \"\";\n\n // 2. Split \"5051, true\" by the comma\n const parts = rawExecutionData.split(',').map(p => p.trim());\n\n // 3. Return the structured object n8n needs\n return {\n json: {\n id: \"\", \n approval: parts[1] || \"\", // This will be \"true\" or \"false\"\n feedback: feedbackText, // This will be your Telegram message text\n execution_id: parts[0] || \"\" // This will be \"5051\"\n }\n };\n});" }, "type": "n8n-nodes-base.code", "typeVersion": 2, "position": [ -1056, -224 ], "id": "c0ff717e-8aba-4291-8e97-665738cebb74", "name": "Extract approval data" }, { "parameters": { "jsCode": "// This loop ensures the code runs for every item in the current execution\nreturn items.map(item => {\n // 1. Get the raw data (e.g., \"5051, true\")\n const rawExecutionData = item.json.execution_id || \"\";\n const feedbackText = item.json.feedback || \"\";\n\n // 2. Split by comma and take the first part only\n const parts = rawExecutionData.split(',').map(p => p.trim());\n\n // 3. Return the structured object without the \"approval\" key\n return {\n json: {\n id: \"\", \n feedback: feedbackText,\n execution_id: parts[0] || \"\" // This captures just the number (e.g., \"5051\")\n }\n };\n});" }, "type": "n8n-nodes-base.code", "typeVersion": 2, "position": [ -1056, -416 ], "id": "896cf799-6f07-4a26-95a8-9369366f5aa3", "name": "Extract feedback data" } ], "pinData": {}, "connections": { "Telegram Trigger": { "main": [ [ { "node": "If", "type": "main", "index": 0 } ] ] }, "Approval data": { "main": [ [ { "node": "Extract approval data", "type": "main", "index": 0 } ] ] }, "If": { "main": [ [ { "node": "Feedback", "type": "main", "index": 0 } ], [ { "node": "Approval data", "type": "main", "index": 0 } ] ] }, "Feedback": { "main": [ [ { "node": "Extract feedback data", "type": "main", "index": 0 } ] ] }, "Extract approval data": { "main": [ [ { "node": "HTTP Request", "type": "main", "index": 0 } ] ] }, "Extract feedback data": { "main": [ [ { "node": "HTTP Request", "type": "main", "index": 0 } ] ] } }, "active": false, "settings": { "executionOrder": "v1", "availableInMCP": false }, "versionId": "aabe84b1-536f-409c-a6ac-0b5660fd27f3", "meta": { "templateCredsSetupCompleted": true, "instanceId": "23830929e6c018b604abb710d12ca57ce411c63a552f9a21234ab1d153211b0b" }, "id": "Ni6gHH8zDC2gA2zw", "tags": [] }