How to make n8n webhook catcher to answer with certain word?

I want to set webhook in service I use (https://vk.com/dev/callback_api - at bottom of page choose English).
I plan to use n8n as webhook receiver.
The service I use requires the confirmation of owning of webhook receiver.
It sends POST query and requires webhook receiver sends an answer containing certain word.

How to do this in n8n?

Hey @James-Frost, following the steps below should do it.

  • Paste the workflow below.

  • Copy the TEST URL and add it on VK (your server endpoint).

  • Copy the string you have to return to confirm the URL and paste it on the function node specifically on the property data.

  • Open the webhook node and hit execute.

  • Go to VK and push the confirm button. (This will hit the webhook node and verify the URL).

  • Now delete the function node and in the webhook node set the response mode to On Received.

  • Configure the events you want to receive from VK and connect the nodes you want to the webhook node.

  • Active the workflow.

    {
        "nodes": [
           {
            "parameters": {},
            "name": "Start",
            "type": "n8n-nodes-base.start",
            "typeVersion": 1,
            "position": [
              250,
              300
            ]
          },
          {
            "parameters": {
              "httpMethod": "POST",
              "path": "webhook",
              "options": {}
            },
            "name": "Webhook",
            "type": "n8n-nodes-base.webhook",
            "typeVersion": 1,
            "position": [
              490,
              300
            ]
          },
          {
            "parameters": {
              "functionCode": "return [{\n  json: { data: \"stringtobereturnend\" }\n}]"
            },
            "name": "Function",
            "type": "n8n-nodes-base.function",
            "typeVersion": 1,
            "position": [
              730,
              300
            ]
          }
        ],
        "connections": {
          "Webhook": {
            "main": [
              [
                {
                  "node": "Function",
                  "type": "main",
                  "index": 0
                }
              ]
            ]
          }
        }
      }
1 Like

Thanks a lot for answer, @RicardoE105!

But I understand not all steps :cry: :cry: :cry:

Paste the workflow below

Sorry for question, but where do I need to paste it? Can you please explain in more details?

Copy the TEST URL

Where can I find it?

Just create a new workflow, copy the code I sent before and just paste it on your workflow that will add the nodes automatically to your workflow so you do not have to start from scratch.

The test url can be found under webhook urls when you open the webhook node. Check the image below.

Btw. as you seem to be totally new to n8n here is a tutorial which uses webhooks:

and here a list of many different n8n tutorials:
https://n8n.io/tutorials

1 Like

Your help is invaluable, @RicardoE105!

Why to hit Execute in the webhook node before pushing the confirm button in VK?

1 Like

When you hit execute, you make the webhook listen for incoming requests, but keep in mind this is just for 2 min or until you cancel it manually. This is however enough time to make the verification. When you active the webhook (in the last step) it will stay active until you turn it inactive again.

Thank for explanation, @RicardoE105!