Connect an n8n workflow to WhatsApp
Este conteúdo não está disponível em sua língua ainda.
Your n8n workflow receives each WhatsApp message, decides the reply, and sends it back through Wabery. You use two standard n8n nodes. There is no community node to install.
Webhook → your logic or AI Agent → HTTP Request
Before you start
Section titled “Before you start”- A Wabery account. Sign up for the n8n path to open the n8n checklist directly.
- n8n Cloud, or self-hosted n8n reachable on a public HTTPS URL.
- Your own phone with WhatsApp, to test through the shared sandbox.
You do not need a Meta account or a new number to test.
What it costs
Section titled “What it costs”- Testing on Wabery’s number (the sandbox): each message your workflow sends costs Meta’s rate for the customer’s country, paid from your Wabery wallet. Receiving is free. New accounts start with $1 of credit, so you need no card to test. After that, you add funds with a card, from $10. See Wabery sandbox.
- Your own number: Meta bills your WhatsApp Business Account directly, by its own price list. Wabery adds no markup. See WhatsApp pricing.
- Your Wabery plan: Free includes one number of your own and 1,000 messages a month, sent and received, sandbox included. At the limit, replies pause until your allowance resets. Pro ($15/month) adds more numbers, messages, teammates and draft projects. See plans.
- n8n and your AI provider bill you as they do today. Wabery charges nothing for AI when your workflow writes the replies.
Start from the workflow file (optional)
Section titled “Start from the workflow file (optional)”Download the workflow, then in n8n choose Import from file. It contains the three nodes below, already connected. The Write reply node returns a fixed message so you can prove the loop before adding AI. You still need to add your Wabery key as a credential (step 4) and publish the workflow.
1. Add the Webhook node
Section titled “1. Add the Webhook node”-
Add a Webhook node. Set HTTP Method to
POST. -
Set Respond to
Immediately. Wabery waits up to 10 seconds for a 2xx response, so do not make it wait for your AI. -
Under Options, add Only Run If with this expression:
{{ $json.body.payload.test !== true }}When you save the webhook, Wabery sends a setup event with
payload.test: trueand fake IDs. With this option, n8n answers it with200but does not run your reply nodes.
n8n puts the Wabery event under body. The fields you will use are
body.payload.text, body.payload.channel_id, and
body.payload.conversation_id. See the event shape
for every field.
2. Publish and connect the webhook
Section titled “2. Publish and connect the webhook”- Publish the workflow.
- Copy the Webhook node’s Production URL. The Test URL only works while the editor is listening.
- In Wabery’s checklist, paste it and choose Save and test webhook.
Expected result: Wabery shows a delivered test with response 200. Saving
also creates a signing secret and switches the project to external routing, so
Wabery’s hosted agent and automations stay off for this project.
3. Write the reply
Section titled “3. Write the reply”Add the nodes that decide what to say after the Webhook node.
- To prove the loop first, use an Edit Fields (Set) node that sets a
string field named
output, for exampleThanks for your message! You wrote: {{ $json.body.payload.text }}. - To use AI, add an AI Agent node with your own model credentials and
pass it
{{ $json.body.payload.text }}. It also writes its answer tooutput.
Charges for your AI model come from your AI provider, not from Wabery.
4. Add the HTTP Request node
Section titled “4. Add the HTTP Request node”Create the reply key in Wabery’s checklist first. It starts with wab_live_ and
is shown once, so store it in n8n straight away.
| Setting | Value |
|---|---|
| Method | POST |
| URL | https://api.wabery.com/v1/messages |
| Authentication | Generic Credential Type |
| Generic Auth Type | Bearer Auth |
| Bearer Token | Your raw wab_live_... key. Do not type Bearer; n8n adds it. |
| Send Body | On |
| Body Content Type | JSON |
| Specify Body | Using Fields Below |
Add these body fields:
| Name | Value |
|---|---|
channel_id |
{{ $('Webhook').item.json.body.payload.channel_id }} |
conversation_id |
{{ $('Webhook').item.json.body.payload.conversation_id }} |
text |
{{ $json.output }} |
The ID expressions point at the Webhook node by name, so they still work after an AI or logic node changes the current item. If you rename the Webhook node, use the new name in both expressions.
Publish the workflow again after you change it.
5. Test the full loop in the sandbox
Section titled “5. Test the full loop in the sandbox”- In the checklist, open Try the full conversation in WhatsApp.
- Join the sandbox from your phone with the code shown.
- Send a customer-style message, such as
Is my order ready?.
Expected result: your phone receives the reply from your workflow, the n8n Executions tab shows a successful run, and the checklist marks the step complete once Wabery records your API reply.
Go live on your own number
Section titled “Go live on your own number”When the sandbox test passes:
- Go to Channels in Wabery and connect WhatsApp. Meta asks you to choose or create a business account and verify the number by text or call. See Connect WhatsApp.
- Keep the same workflow, webhook URL, and key. Messages to the connected number now reach your workflow.
- Meta bills its fees on your own number directly to your WhatsApp Business Account. Your plan’s monthly messages still apply: 1,000 sent and received on Free. See WhatsApp pricing and the Wabery plans.
- Free-form replies work within 24 hours of the customer’s last message. Outside that window, send an approved template.
Verify signatures before production
Section titled “Verify signatures before production”Every delivery carries x-wabery-signature: sha256= followed by an HMAC
SHA-256 of the raw request body, made with your project’s signing secret. The
n8n Webhook node does not check it for you. Before real customers write in:
- Treat the n8n Production URL as a secret. Anyone who has it can start your workflow.
- Put a small verifying endpoint in front of n8n. It checks the signature against the raw body and forwards only valid events to your n8n URL. The Node.js example shows the check.
- Skip duplicates: retries reuse the same
x-wabery-delivery-idheader.
Troubleshooting
Section titled “Troubleshooting”| What you see | What to do |
|---|---|
Wabery’s test shows 404 |
The workflow is not published, or you pasted the Test URL. Publish and use the Production URL. |
| Wabery’s test shows a timeout | Set Respond to Immediately. Wabery waits up to 10 seconds. |
| Your reply nodes ran on the setup test and failed | Add Only Run If (or an If node) so payload.test events stop at the Webhook. |
HTTP Request returns 401 |
Paste the raw wab_live_ key into the Bearer Auth credential, with no quotes and no Bearer prefix. |
HTTP Request returns 400 |
Check that channel_id, conversation_id, and text are filled. An empty text usually means the field is not called output. |
Referenced node doesn't exist |
You renamed the Webhook node. Update both ID expressions. |
| No execution appears when you message the sandbox | Confirm you joined the sandbox for this project and the webhook test passed. Check Recent deliveries in Wabery for the response code. |
| A message was answered twice | Wabery retried after a slow or failed response. Respond immediately and skip repeated x-wabery-delivery-id values. |
Using Make, Zapier, or your own code instead? See Connect your external agent.