Wait For Telegram Response - no webhook

    Poll Telewgram for a response to a message sent by a bot

    Shared 11/9/2025

    396 views

    Visual Workflow

    JSON Code

    {
      "id": "4P8H2RU4oIHlQJN0",
      "meta": {
        "instanceId": "9a93705676cef812bba4609ac2e211f44c4c6a4ffff0d6ade780528db2a298ee"
      },
      "name": "WaitTelegramResponse",
      "tags": [],
      "nodes": [
        {
          "id": "e90b1b18-027e-4b4b-952c-8f5303b3277f",
          "name": "If1",
          "type": "n8n-nodes-base.if",
          "position": [
            1600,
            352
          ],
          "parameters": {
            "options": {},
            "conditions": {
              "options": {
                "version": 2,
                "leftValue": "",
                "caseSensitive": true,
                "typeValidation": "strict"
              },
              "combinator": "and",
              "conditions": [
                {
                  "id": "1feb8bfc-8917-441d-b72a-4073aafaea22",
                  "operator": {
                    "type": "object",
                    "operation": "exists",
                    "singleValue": true
                  },
                  "leftValue": "={{ $json.message }}",
                  "rightValue": 0
                },
                {
                  "id": "41516f0f-aceb-448f-b2f7-32f92d64a9c7",
                  "operator": {
                    "type": "number",
                    "operation": "notEmpty",
                    "singleValue": true
                  },
                  "leftValue": "={{ $json.message.update_id }}",
                  "rightValue": ""
                }
              ]
            }
          },
          "typeVersion": 2.2
        },
        {
          "id": "36b70875-fab1-4d41-b221-5ab75aafb726",
          "name": "Wait",
          "type": "n8n-nodes-base.wait",
          "position": [
            1216,
            576
          ],
          "webhookId": "687560eb-478d-47e2-8b45-30e4d80267a5",
          "parameters": {
            "amount": 1
          },
          "typeVersion": 1.1
        },
        {
          "id": "0f3f1c3e-8950-45c6-81f5-a5a3cbe2cd3e",
          "name": "If",
          "type": "n8n-nodes-base.if",
          "position": [
            1216,
            352
          ],
          "parameters": {
            "options": {},
            "conditions": {
              "options": {
                "version": 2,
                "leftValue": "",
                "caseSensitive": true,
                "typeValidation": "strict"
              },
              "combinator": "and",
              "conditions": [
                {
                  "id": "d85fb54f-a182-44c0-a17b-0da64a181822",
                  "operator": {
                    "type": "boolean",
                    "operation": "false",
                    "singleValue": true
                  },
                  "leftValue": "={{ $json.ok }}",
                  "rightValue": ""
                }
              ]
            }
          },
          "typeVersion": 2.2
        },
        {
          "id": "790ed43a-33f0-44bc-96b3-4c02a4bcb2e2",
          "name": "Retrieve Response Message",
          "type": "n8n-nodes-base.code",
          "position": [
            1424,
            352
          ],
          "parameters": {
            "mode": "runOnceForEachItem",
            "jsCode": "if ($json.result.length > 0 && $json.result[$json.result.length - 1].message.message_id > $('Receive Telegram Message to Wait for a Response').item.json.result.message_id) {\n  return {'message': $json.result[$json.result.length - 1] };\n}\n\nreturn {'message': undefined };"
          },
          "typeVersion": 2
        },
        {
          "id": "3cd45444-88d2-4f02-8105-1721e76dbecb",
          "name": "Poll Telegram",
          "type": "n8n-nodes-base.httpRequest",
          "position": [
            1008,
            352
          ],
          "parameters": {
            "url": "https://api.telegram.org/bot<BOT-ID>/getUpdates",
            "options": {}
          },
          "typeVersion": 4.2
        },
        {
          "id": "c055762a-8fe7-4141-a639-df2372f30060",
          "name": "Receive Telegram Message to Wait for a Response",
          "type": "n8n-nodes-base.executeWorkflowTrigger",
          "position": [
            816,
            352
          ],
          "parameters": {
            "inputSource": "jsonExample",
            "jsonExample": "{\n    \"ok\": true,\n    \"result\": {\n      \"message_id\": 123,\n      \"from\": {\n        \"id\": 123456789,\n        \"is_bot\": true,\n        \"first_name\": \"MyBot\",\n        \"username\": \"my_bot\"\n      },\n      \"chat\": {\n        \"id\": 123456789,\n        \"first_name\": \"First\",\n        \"last_name\": \"Last\",\n        \"username\": \"FirstLast\",\n        \"type\": \"private\"\n      },\n      \"date\": 123456789,\n      \"text\": \"SOme text requiring a response\",\n.       \"link_preview_options\": {\n        \"is_disabled\": true\n      }\n    }\n  }"
          },
          "typeVersion": 1.1
        },
        {
          "id": "168c6574-89a2-4189-90c9-14578cfaed9b",
          "name": "Extract Response Text",
          "type": "n8n-nodes-base.code",
          "position": [
            1808,
            352
          ],
          "parameters": {
            "mode": "runOnceForEachItem",
            "jsCode": "return { 'response': $json.message.message.text }"
          },
          "typeVersion": 2
        }
      ],
      "active": false,
      "pinData": {},
      "settings": {
        "executionOrder": "v1"
      },
      "versionId": "311acb7b-d6a1-4cbf-bf01-68a72c42e9ba",
      "connections": {
        "If": {
          "main": [
            [
              {
                "node": "Poll Telegram",
                "type": "main",
                "index": 0
              }
            ],
            [
              {
                "node": "Retrieve Response Message",
                "type": "main",
                "index": 0
              }
            ]
          ]
        },
        "If1": {
          "main": [
            [
              {
                "node": "Extract Response Text",
                "type": "main",
                "index": 0
              }
            ],
            [
              {
                "node": "Wait",
                "type": "main",
                "index": 0
              }
            ]
          ]
        },
        "Wait": {
          "main": [
            [
              {
                "node": "Poll Telegram",
                "type": "main",
                "index": 0
              }
            ]
          ]
        },
        "Poll Telegram": {
          "main": [
            [
              {
                "node": "If",
                "type": "main",
                "index": 0
              }
            ]
          ]
        },
        "Extract Response Text": {
          "main": [
            []
          ]
        },
        "Retrieve Response Message": {
          "main": [
            [
              {
                "node": "If1",
                "type": "main",
                "index": 0
              }
            ]
          ]
        },
        "Receive Telegram Message to Wait for a Response": {
          "main": [
            [
              {
                "node": "Poll Telegram",
                "type": "main",
                "index": 0
              }
            ]
          ]
        }
      }
    }