Whatsapp bot

Hi all,

I read the posts but I can’t find the solution to create a simple WhatsApp bot. I have already created a whatsapp bot with botpress but I want to use n8n to add the langchain feature (vectors store), the memory…

I guess that my starting node is a webhook (type : POST) but when I go to the Meta Developer Console to add the webhook, I need to add a url and a token. What is the token ?

Is n8n adapted to do a whatsapp chatbot ?

Thank you for your advice

Hi @romeo_roy, creating webhooks can be a bit tricky but this should still work fine with n8n. What’s important is that WhatsApp requires you to have two separate webhooks as per their docs: “Verification Requests” and “Event Notifications”. The verification request is a GET request, while the actual events come through in a POST request. The token can have any value, it’s only meant to verify the authenticity of requests coming from Meta/WhatsApp.

In n8n this means setting up two Webhooks nodes with the same path but different HTTP methods, similar to what I’ve describe here for Okta. This is how a WhatsApp event workflow could look like assuming you pick a token of foo?:

I’d suggest you activate this workflow straight away and then use your production URL (and check your execution data for the results). Facebook seems to occasionally re-verify your webhook and this would fail if your workflows is inactive (or you are relying on manual executions using the test URL of your webhook nodes).

You can then see each request in your execution data. A verification request will be processed in the upper branch:

Actual events come through on the bottom branch:

Once you have received your first event, you can simply copy the JSON payload into the n8n editor using the Copy to editor button in the upper right corner of your execution view and then build your full workflow from there.

Hope this helps!

1 Like

Thank you very much for your response.

1 Like

This topic was automatically closed 90 days after the last reply. New replies are no longer allowed.