Messenger automation issue

Describe the problem/error/question

Hi! I have an issue with my Messenger automation. I’m running it locally (via Docker) and using ngrok for tunneling. The workflow executes only once. I have the flow activated (top-right toggle is on).
When I send a message to the Messenger page, which is supported by the n8n automation, it replies only once. After that, the workflow stops working (I have to manually execute it again to respond to another message — even though the workflow is active the whole time).
Does anyone know how to fix this? I’ve watched a lot of tutorials on YouTube and my setup and schema are exactly the same.

What is the error message (if any)?

Only error message is from terminal, where ngrok is running (first execute return 200 code with success, next one 404).

Please share your workflow

<!-- Hey! The fastest way to find solutions is by using the 🔎 search function at the upper right.

If your question hasn't been asked before, please follow the template below. Skip the questions that are not relevant to you. -->

## Describe the problem/error/question

Hi! I have an issue with my Messenger automation. I'm running it locally (via Docker) and using ngrok for tunneling. The workflow executes only once. I have the flow activated (top-right toggle is on).
When I send a message to the Messenger page, which is supported by the n8n automation, it replies only once. After that, the workflow stops working (I have to manually execute it again to respond to another message — even though the workflow is active the whole time).
Does anyone know how to fix this? I’ve watched a lot of tutorials on YouTube and my setup and schema are exactly the same.

## What is the error message (if any)?

Only error message is from terminal, where ngrok is running (first execute return 200 code with success, next one 404). 
![Zrzut ekranu 2025-07-18 o 12.30.29|690x102](upload://hls4LD9yZyscB1WynyevvYsGDVA.png)


## Please share your workflow

{
  "nodes": [
    {
      "parameters": {
        "multipleMethods": true,
        "path": "=bf677959-dfc5-4803-bcd8-36f4aaac109f",
        "responseMode": "responseNode",
        "options": {}
      },
      "type": "n8n-nodes-base.webhook",
      "typeVersion": 2,
      "position": [
        240,
        -32
      ],
      "id": "97e61a3e-0963-4aed-bcdc-2cbcaecf4ae9",
      "name": "Webhook",
      "webhookId": "bf677959-dfc5-4803-bcd8-36f4aaac109f"
    },
    {
      "parameters": {
        "conditions": {
          "options": {
            "caseSensitive": true,
            "leftValue": "",
            "typeValidation": "strict",
            "version": 2
          },
          "conditions": [
            {
              "id": "4164e2db-d24b-4765-9519-47e6d2792256",
              "leftValue": "={{ $json.query['hub.mode'] }}",
              "rightValue": "subscribe",
              "operator": {
                "type": "string",
                "operation": "equals",
                "name": "filter.operator.equals"
              }
            },
            {
              "id": "daddbe5f-2a49-4576-bae1-a2b8a8bf4d56",
              "leftValue": "={{ $json.query['hub.verify_token'] }}",
              "rightValue": "aichatbot",
              "operator": {
                "type": "string",
                "operation": "equals",
                "name": "filter.operator.equals"
              }
            }
          ],
          "combinator": "and"
        },
        "options": {}
      },
      "type": "n8n-nodes-base.if",
      "typeVersion": 2.2,
      "position": [
        544,
        -48
      ],
      "id": "b8b0c07b-5936-4678-ac86-c25707041357",
      "name": "If"
    },
    {
      "parameters": {
        "respondWith": "text",
        "responseBody": "={{ $json.query['hub.challenge'] }}",
        "options": {}
      },
      "type": "n8n-nodes-base.respondToWebhook",
      "typeVersion": 1.4,
      "position": [
        816,
        -160
      ],
      "id": "4c0adbc4-405f-4d25-8ecb-c86ff83daec1",
      "name": "Respond to Webhook"
    },
    {
      "parameters": {
        "promptType": "define",
        "text": "=Odpowiadasz na następujące pytanie:{{ $json.body.entry[0].messaging[0].message.text }}. Korzystasz z informacji zawartych w. Na jego podstawie masz wygenerować odpowiedź dla klienta. Masz zachować środki grzecznościowe i pisać profesjonalnie. Odpowiadasz tylko na zadanie pytania. ",
        "options": {
          "systemMessage": "Jesteś pomocnym asystentem dla firmy produkującej domki modułowe mozal.pl. Twoim zadaniem jest odpowiedź na pytania  klientów. "
        }
      },
      "type": "@n8n/n8n-nodes-langchain.agent",
      "typeVersion": 2.1,
      "position": [
        656,
        144
      ],
      "id": "df42d2cf-5ce2-4bfd-9281-75ada47d6284",
      "name": "AI Agent"
    },
    {
      "parameters": {
        "sessionIdType": "customKey",
        "sessionKey": "={{ $json.body.entry[0].messaging[0].sender.id }}",
        "contextWindowLength": 10
      },
      "type": "@n8n/n8n-nodes-langchain.memoryBufferWindow",
      "typeVersion": 1.3,
      "position": [
        672,
        352
      ],
      "id": "2191cd05-8854-4576-8c6c-690fd0221fae",
      "name": "Simple Memory"
    },
    {
      "parameters": {
        "method": "POST",
        "url": "=https://graph.facebook.com/v23.0/{{ $('Webhook').item.json.body.entry[0].messaging[0].recipient.id }}/messages?access_token=EAAfyLlLlLR0BPMBfqhLdqjZBQnI9YF8FUlbT8GIhZBwUzZC0juZBW5NitWWBIVjRvPsO0mChr8WhtgW0SSxq6sOIqHbC283ZAVZCnIUDIILr7Kjn98MZBrpSqkHk0ltWvnRdw2yEs5t0AJgOJLFQOs9b4aUczkVgG3wBoT3FQEREQrNL23704XO6KiHh3fnQDxWZCZAy0Gkl0igZDZD",
        "sendBody": true,
        "specifyBody": "json",
        "jsonBody": "={\n  \"recipient\": {\n    \"id\": \"{{ $('Webhook').item.json.body.entry[0].messaging[0].sender.id }}\"\n  },\n  \"messaging_type\": \"RESPONSE\",\n  \"message\": {\n    \"text\": \n\"{{ $json.outputAI }}\"\n  }\n}",
        "options": {}
      },
      "type": "n8n-nodes-base.httpRequest",
      "typeVersion": 4.2,
      "position": [
        1216,
        144
      ],
      "id": "05503440-5ed6-4699-b6f1-592e832caed7",
      "name": "HTTP Request"
    },
    {
      "parameters": {
        "assignments": {
          "assignments": [
            {
              "id": "ff839087-3d40-4499-a5cc-a63fc8d9d2c4",
              "name": "outputAI",
              "value": "={{ $json.output.replace(/[\\r\\n]+/g, \"\") }}",
              "type": "string"
            }
          ]
        },
        "options": {}
      },
      "type": "n8n-nodes-base.set",
      "typeVersion": 3.4,
      "position": [
        1008,
        144
      ],
      "id": "0bb29983-e800-4614-889a-de159f29de0f",
      "name": "Edit Fields"
    },
    {
      "parameters": {
        "modelName": "models/gemini-2.0-flash-lite",
        "options": {}
      },
      "type": "@n8n/n8n-nodes-langchain.lmChatGoogleGemini",
      "typeVersion": 1,
      "position": [
        496,
        336
      ],
      "id": "e467945e-0b6b-46ea-8097-c50827dee7be",
      "name": "Google Gemini Chat Model",
      "credentials": {
        "googlePalmApi": {
          "id": "apIdqo2pSn279AQE",
          "name": "Google Gemini(PaLM) Api account"
        }
      }
    },
    {
      "parameters": {
        "url": "https://mozal.pl/pytania-i-odpowiedzi/",
        "options": {}
      },
      "type": "n8n-nodes-base.httpRequestTool",
      "typeVersion": 4.2,
      "position": [
        912,
        352
      ],
      "id": "139e702f-9f0b-4391-87f9-37e5dec022a2",
      "name": "HTTP Request1"
    }
  ],
  "connections": {
    "Webhook": {
      "main": [
        [
          {
            "node": "If",
            "type": "main",
            "index": 0
          }
        ],
        [
          {
            "node": "AI Agent",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "If": {
      "main": [
        [
          {
            "node": "Respond to Webhook",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "AI Agent": {
      "main": [
        [
          {
            "node": "Edit Fields",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "Simple Memory": {
      "ai_memory": [
        [
          {
            "node": "AI Agent",
            "type": "ai_memory",
            "index": 0
          }
        ]
      ]
    },
    "Edit Fields": {
      "main": [
        [
          {
            "node": "HTTP Request",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "Google Gemini Chat Model": {
      "ai_languageModel": [
        [
          {
            "node": "AI Agent",
            "type": "ai_languageModel",
            "index": 0
          }
        ]
      ]
    },
    "HTTP Request1": {
      "ai_tool": [
        [
          {
            "node": "AI Agent",
            "type": "ai_tool",
            "index": 0
          }
        ]
      ]
    }
  },
  "pinData": {},
  "meta": {
    "templateCredsSetupCompleted": true,
    "instanceId": "3a824ab7603bc9f6f3caa2291a5561749c83331d235cd8b014de0f1132fb190a"
  }
}


## Share the output returned by the last node

![Zrzut ekranu 2025-07-18 o 12.37.48|690x386](upload://aDpikTZCRnw6k51LjDdruiwJUs5.png)


## Information on your n8n setup
- **n8n version:** 1.102.4
- **Database (default: SQLite):** SQLite 
- **n8n EXECUTIONS_PROCESS setting (default: own, main):** I can't find it, I hope it doesn't matter
- **Running n8n via (Docker, npm, n8n cloud, desktop app):** docker, ngrok 
- **Operating system:** MacOSX Sequoia 15.5

Share the output returned by the last node

Information on your n8n setup

  • n8n version: 1.102.4
  • Database (default: SQLite): SQLite
  • n8n EXECUTIONS_PROCESS setting (default: own, main): I can’t find it, I hope it doesn’t matter
  • Running n8n via (Docker, npm, n8n cloud, desktop app): docker, ngrok
  • Operating system: MacOSX Sequoia 15.5

Ehy,
the issue happens because you’re using the test webhook. In test mode, n8n creates a temporary webhook that only works once or for a short time and then returns 404.

To fix it:
Activate your workflow by switching the toggle to ON in the editor.
Use the production webhook URL (without -test) and update it in your Facebook Messenger app settings.
Re-run the subscription/verification step on Facebook if needed.


Let me know if this solves your problem and mark the response as a solution.

In this way, you encourage users to give more and more punctual and precise answers within the community

2 Likes

Hi @xxzajacx, welcome to community.
The problem is because of you are using webhook-test path url, and that path is used by test webhook which only run when you’re executing it, even the workflow is not activated yet.

To solve this, you might change your url with webhook-test, to webhook, or you can simplify it with copy the Production URL in your webhook node

1 Like

this helped me a lot

1 Like

@Gallo_AIA @cutecatcode thank you a lot, do everything as u say and the problem was fixed, all working correctly (without stability, cuz it sends a lot of messages and spam in answer for one question, but its probably my bad and I will search a solution).
Thanks :wink:

1 Like