Skip to main content
Version: v0.31.0

Build WhatsApp workflows with n8n

Connect OpenWA to n8n, an open-source workflow automation tool, using the official community nodes. By the end of this page you'll have the nodes installed, an OpenWA credential configured, and a working auto-reply workflow: an incoming WhatsApp message triggers a reply.

The package ships two nodes:

NodeTypeWhat it does
OpenWAActionCalls OpenWA operations as a workflow step — send messages, manage sessions, chats, contacts, groups, labels, templates, status, channels and webhooks, read a business catalog, convert media, drive presence, and manage autoreply rules
OpenWA TriggerTriggerStarts a workflow when a WhatsApp event arrives — messages, session, group, call, and presence events
Prerequisites
  • A running OpenWA gateway that n8n can reach over the network. See Installation.
  • A connected session that has finished pairing. See Your first session.
  • An API key from the dashboard. See the Authentication guide.
  • An n8n instance where you can install community nodes (self-hosted), version ≥ 1.85.0: the nodes need an n8n-workflow that exports NodeConnectionTypes (1.83.0 and later, which ships with n8n 1.85.0), and fail to load with an older copy.
  • An OpenWA server ≥ 0.16.0. The nodes are verified against v0.31.0.
The server floor is checked when the webhook is registered

Package 0.9.1 raised the required server from 0.10.9 to 0.14.0. Five of the events the Trigger offers — session.restriction, presence.update, call.accepted, call.rejected, and call.missed — do not exist in core before v0.14.0, and the gateway validates a webhook registration against its own event list. A Trigger subscribing to any of them against an older gateway is refused at registration with a 400, so the workflow fails to activate rather than activating and quietly never firing.

Package 0.9.2 raised it again, to 0.15.0, by offering group.join_request, which core has dispatched only since v0.15.0. Package 0.10.0 raises it once more, to 0.16.0, where the calls/link route the Call resource needs arrived. That is the floor this guide describes.

Install the nodes​

Install the community package on a self-hosted n8n instance.

From the n8n UI​

  1. In n8n, open Settings → Community Nodes.
  2. Click Install.
  3. Enter @rmyndharis/n8n-nodes-openwa and accept the community-node risk prompt.
  4. Restart n8n.

Manual install​

cd ~/.n8n/nodes
npm install @rmyndharis/n8n-nodes-openwa

Restart n8n after installing. Both nodes then appear in the node picker when you search for "OpenWA".

n8n Cloud

n8n Cloud only allows community nodes verified by n8n, and this package is not currently one of them. Use a self-hosted instance to run it.

Configure the OpenWA API credential​

Both nodes share one credential. Create it once and reuse it across every OpenWA node in your instance.

FieldRequiredDefaultDescription
Server URLYeshttp://localhost:2785Your OpenWA server URL, without /api. A trailing slash is harmless: the credential test and the nodes both drop it, and the nodes also trim surrounding whitespace. Use HTTPS in production (for example https://wa.yourserver.com).
API KeyYes—The API key from your OpenWA dashboard. The node sends it as the X-API-Key header on every request.

When you click Test in the credential dialog, n8n makes an authenticated GET /api/sessions request to your server. The test passes only if the key is valid, so a wrong key or unreachable server fails immediately.

Use a scoped key

Create a dedicated API key for n8n rather than reusing an admin key, so you can revoke it without disrupting other clients. See the Authentication guide.

Most reads work with a plain VIEWER key. Writes — sends, group changes, profile changes, and webhook management — need an OPERATOR-role key (the default role). An ADMIN key is needed for every API Key operation except Validate, which any valid key not restricted to selected chats may call, and for System → Get Settings, Get Audit Log, Get Stats Overview and Get Message Stats, plus Webhook → Get Delivery Failures and Redrive Delivery Failures. Since gateway v0.24.0 an ADMIN key is also needed for Session → Update Proxy and for Session → Create when a Proxy URL is set. Several reads are not VIEWER-reachable despite returning nothing but data: System → Search, Session → Get QR, Contact → Check Exists (v0.24.0+, as each call is an outbound WhatsApp query about a third party) and Get LID (v0.27.1+), Group → Get Invite Code (v0.23.5+, as the code lets anyone join the group), Template → List and Get, and Webhook → List, List All and Get all need OPERATOR, as does every Automation Rule operation, List and Get included. A VIEWER key is enough for the rest.

Some surfaces additionally refuse a session-scoped key whatever its role, because they carry no session dimension for the scope check to apply to: the API-key management operations, System → Get Settings, Get Stats Overview and Get Message Stats, and Session → Create and Update Proxy. Get Audit Log is the exception among the ADMIN reads: a session-scoped key is accepted there and simply sees a narrowed result. A 403 almost always means the key's role is too low or its scope too narrow, not that the request was malformed.

A key restricted to selected chats (allowedChats, v0.23.6+) fails the credential Test and cannot drive the Trigger: the test's GET /api/sessions, Session Name or ID, Label and Template dropdowns, Trigger webhook registration, and API Key > Validate remain closed. n8n still saves the credential, so supply the session UUID from an expression to use open action operations.

Since gateway v0.23.6, the Chat dropdown and Chat > List filter to allowed chats before pagination, and since v0.24.0 so do the Contact and Group dropdowns and list operations. Message > List is open only when Options > Chat Name or ID names an allowed chat, and Label > Get Chats returns only allowed chats (supply the label id from an expression). Gateway v0.25.0 also opens Group > Get, Get Settings and Update Settings for allowed groups (and v0.27.0 opens Group > Set Member Label) and scopes built-in System > Search to the key's chats; plugin search remains forbidden.

Session > Get Status, the sends, most message actions, other Chat operations, and selected Contact, Group, Label and Presence operations remain open for allowed chats. Group participant, invite-code and membership-request operations, Contact > Check Exists and Get LID, and message batch status/cancel remain closed. A send carrying Quoted Message ID is still refused except through Reply, which resolves the quote inside the authorized chat. See the n8n Node Reference for the complete list.

You can confirm the same credential by hand with curl before building a workflow. This hits the same send endpoint the Send Text operation uses, so a success here confirms both the credential and a connected session:

curl -X POST http://localhost:2785/api/sessions/8f3c2b1a-9d4e-4c7a-8b2f-1e6d5a4c3b2a/messages/send-text \
-H "X-API-Key: YOUR_API_KEY" \
-H "Content-Type: application/json" \
-d '{
"chatId": "628123456789@c.us",
"text": "Hello from OpenWA!"
}'

On success the gateway returns 201 Created with the message id and timestamp:

{
"messageId": "true_628123456789@c.us_3EB0123456789",
"timestamp": 1706868000
}

A 400 means the session id is unknown or the session was never started, or the body is invalid; without a quotedMessageId, this route does not answer 404. A 409 means an engine exists but is not connected yet, so the request never reached WhatsApp: wait for ready and retry. Since server v0.31.0 the exception is a 409 that says the message may or may not have been sent, because WhatsApp Web reloaded its page (whatsapp-web.js) or the connection was replaced or stopped (Baileys) while it was being sent: check the chat before sending again. Replace the UUID with your own session id — the id from the create response, not the name you gave it — and 628123456789@c.us with a real recipient chat id.

The OpenWA node (actions)​

The action node maps a Resource and Operation to one OpenWA call. Package 1.8.1 covers the nineteen resources below, spanning the operations workflows reach for most often. For field-level detail of every operation, see the n8n Node Reference.

ResourceOperationsWhat it covers
SessionCreate, Start, Stop, Force Kill, Log Out, Delete, Get QR, Request Pairing Code, Get Status, List All, Get Stats Overview, Get / Update Config, Get / Update ProxySession lifecycle, pairing, and per-session configuration
MessageSend Text / Image / Video / Audio / Document / Sticker / Location / Contact / Poll / Template / Product, Reply, React, Edit, Delete, Forward, Pin, Unpin, Star, Vote Poll, Click Button, Send Bulk, Get Batch Status, Cancel Batch, List, Get History, Get Reactions, Get Receipts, Get MediaEverything that sends or acts on a message
ContactCheck Exists, Get Info, Get LID, Get Phone, Get Profile Picture, Get Profile Pictures, List, List Blocked, Save, Delete, Block, UnblockContact lookup, the addressbook, and blocking
ChatList, Mark Read, Mark Unread, Delete, Clear Messages, Archive, Pin, Mute, Set StateConversations, their archive/pin/mute state, and typing or recording indicators
GroupList, Get, Create, Join, Get Join Info, Leave, Add / Remove / Promote / Demote Participants, Update Subject, Update Description, Set Member Label, Get Settings, Update Settings, Get Invite Code, Revoke Invite Code, Get / Approve / Reject Membership Requests, Get / Set / Delete PictureGroup administration, the join-approval queue, and the group picture
ProfileSet Name, Set Status, Set Picture, Delete PictureThe session's own WhatsApp profile
LabelList, Get, Create or Update, Delete, Get Chats, Get for Chat, Add to Chat, Remove From ChatWhatsApp Business labels
StatusList, Get by Contact, Get Media, Delete, Send Text, Send Image, Send Video, Send VoiceReading and posting Status (Stories)
TemplateList, Get, Create, Update, DeleteStored templates with {{variable}} placeholders
ChannelList, Get, Get Messages, Create, Subscribe, Unsubscribe, Delete, Mute, Demote Admin, Transfer OwnershipWhatsApp Channels, both the ones the session follows and the ones it owns
CallReject, Create LinkDeclining an incoming call, and sharing a call link
ObservabilityCheck, Check Liveness, Check ReadinessServer health probes
SystemGet Settings, Get Stats Overview, Get Message Stats, Get Session Stats, Get Audit Log, SearchServer-wide reporting and cross-session search
API KeyList, Get, Create, Update, Revoke, Delete, ValidateAPI-key administration
WebhookCreate, Get, List, List All, Update, Delete, Test, Get Delivery Failures, Redrive Delivery FailuresWebhook registration, delivery inspection and replay
Automation RuleList, Get, Create, Update, DeleteServer-side auto-reply rules
CatalogGet, List Products, Get ProductWhatsApp Business product catalog (Baileys sessions only)
MediaCheck Availability, Convert to Voice Note, Convert to VideoServer-side conversion into the formats WhatsApp plays
PresenceSubscribe, Get, Set Own PresencePresence subscription, per-chat reads, and the account's own presence

See the n8n Node Reference for the full field-level detail of every operation. A few endpoints are deliberately absent because the server cannot serve them: Send Catalog and PUT /api/settings were removed from the server in v0.19.0 (both always answered 501); settings are environment-derived and read-only, so System exposes a read alone; and /api/metrics authenticates with its own bearer token rather than the X-API-Key this credential carries. The Catalog resource works only against a Baileys session, since whatsapp-web.js answers 501 for every catalog call; sending a product from that catalog is Message → Send Product, not a Catalog operation.

The node is not a full mirror of the API either. Five server areas have no resource at all: plugin management, the infrastructure routes, Integration Fabric instance management, the Prometheus metrics scrape, and the plugin ingress receiver. The first three areas above are reachable with n8n's HTTP Request node using the same credential and an ADMIN key, apart from the public GET /api/infra/health. The metrics scrape takes its own METRICS_TOKEN bearer, and the ingress receiver is public and verifies the provider's signature, so the credential applies to neither. The complete endpoint list is in the API reference.

Base64 media needs a MIME type

When you send an image or document from a Base64 source, also set the MIME Type field (for example image/png or application/pdf) — OpenWA requires it for base64 payloads. The Binary source fills this in from the binary metadata, and the URL source needs nothing extra.

The OpenWA Trigger node (events)​

The trigger node starts a workflow when a WhatsApp event occurs. When you activate the workflow, the node registers a webhook in OpenWA pointing at n8n's webhook URL; when you deactivate it, that webhook is removed. You never manage the webhook by hand. Activation also removes any other webhook on the session that already uses the Trigger's URL, one made by hand included.

Select one or more events to subscribe to. Package 1.8.1 offers twenty-six events, every one the gateway dispatches through v0.31.0:

EventDescription
message.receivedNew incoming message
message.sentMessage successfully sent
message.ackMessage delivery or read acknowledgement (for messages the account sent since server v0.27.0; on Baileys since server v0.28.0 also fires delivered and read for group messages once every non-self member has delivered or read)
message.receiptPer-recipient delivery, read, or play receipt for a message the account sent to a group or a Status (Baileys only, server v0.26.0+; not included in *)
message.failedMessage failed to send
message.revokedMessage deleted for everyone (on Baileys since server v0.28.0 a non-admin group delete of another member's message is ignored)
message.editedMessage text, or a media message's caption, edited
message.reactionReaction added to or removed from a message; on Baileys since v0.23.6, one the account made from its phone in a one-to-one chat carries the account as senderId
poll.voteA voter changed their selection on a poll (server v0.26.0+ on whatsapp-web.js; on Baileys since server v0.30.2, and only for a poll whose creation message is still in the session's message store)
status.receivedA contact's Status (Story) is received
session.statusSession status changed
session.qrQR code generated for scanning
session.authenticatedSession authenticated
session.disconnectedSession lost connection
session.reconnect_loopSession stuck in a reconnect loop (once per 5 consecutive attempts)
session.restrictionWhatsApp places or lifts a restriction on the account (including Baileys kind: "passkey_required" since server v0.30.0)
presence.updateA subscribed chat's presence changes — Baileys only
event.responseA guest RSVPs to a WhatsApp event invitation; Baileys only, and only on server v0.25.0 and newer. See RSVP payloads
group.joinA participant joins a group the session belongs to, including the session itself when it is added or joins (Baileys since v0.23.6; whatsapp-web.js always)
group.leaveA participant leaves a group the session belongs to
group.updateA group's metadata changes (subject, description, settings). A participant joining or leaving is group.join or group.leave, and an admin promotion or demotion produces no event
group.join_requestSomeone asks to join a group the session administers; fires only when the group has admin approval enabled
call.receivedAn incoming WhatsApp call is detected
call.acceptedAn incoming call is answered — Baileys only
call.rejectedAn incoming call is declined, including by auto-reject — Baileys only
call.missedAn incoming call goes unanswered — Baileys only

Every event above except event.response, message.receipt, and poll.vote is available on any server this package supports: none of them needs a server newer than the package's ≥ 0.16.0 floor. event.response needs server v0.25.0 or newer, and message.receipt and poll.vote (added to the nodes in package 1.3.0) need server v0.26.0 or newer; a gateway older than v0.26.0 refuses a webhook registration naming either with 400, and on Baileys poll.vote reports nothing before v0.30.2. Apart from those three, a version named in a row marks a change in how the event behaves on that engine, not when the event became available.

group.join_request reached the package late: the gateway has dispatched it since core v0.15.0, but no node offered it until package 0.9.2. On 0.9.1 neither the Trigger nor the action node's Webhook → Create and Update operations can select it, because all three read one shared list. On 0.9.1, register that subscription by hand with n8n's HTTP Request node against POST /api/sessions/{sessionId}/webhooks, pointing it at an n8n Webhook node's URL, or upgrade the package.

Six events fire on one engine only

The three call-outcome events fire on Baileys only. whatsapp-web.js hooks the call collection's insert and sees no status at all, so it can report the ring but never how the call ended — a workflow triggered on call.missed simply never runs on a whatsapp-web.js session. call.received fires on both engines but is not reliable on whatsapp-web.js. One known cause is a WhatsApp Web build without the call hook the library patches; since v0.23.6 a session in that state logs a call_hook_missing warning when it reaches ready and can detect it. For dependable call events, run the gateway on Baileys (ENGINE_TYPE=baileys). The engine is instance-wide, and a session must be linked again under it unless it still holds a Baileys link from an earlier run.

Rejecting a call is Baileys-only too. Since v0.23.6, Call → Reject answers 501 on whatsapp-web.js, where it used to answer 200 without stopping the call from ringing, and the session's autoRejectCalls setting logs a failed auto-reject there instead of a successful one.

presence.update is also Baileys-only, and it stays silent until you subscribe the chat with POST /api/sessions/{sessionId}/presence/subscribe. whatsapp-web.js answers that route with 501.

event.response and message.receipt are Baileys-only as well: a Trigger subscribed to either on a whatsapp-web.js session is accepted at registration and never runs. poll.vote fires on both engines, on Baileys since server v0.30.2 and only for a poll whose creation message is still in the session's message store. Message → Vote Poll, which casts a vote, is still whatsapp-web.js only.

Signature verification​

The trigger has an optional Webhook Secret. When set, the secret is registered with OpenWA, and OpenWA signs every delivery to that webhook with HMAC-SHA256 in the X-OpenWA-Signature: sha256=<hex> header; a webhook registered without a secret is delivered unsigned. The node verifies each delivery against the raw request body and rejects any that fail with HTTP 401. Leave it empty to skip verification, in which case anyone who knows the Trigger's URL can start the workflow, so set one when n8n is reachable from outside.

Note

Changing or clearing the secret takes effect on the next activation. Deactivate and reactivate the workflow to re-register it. Before changing Server URL on a credential used by an active Trigger, deactivate the workflow while the original server is still configured and confirm its webhook was removed there, then switch servers and activate again.

Trigger payload​

The trigger emits one item per event. The event is wrapped in an envelope; the actual event data lives under data:

{
"event": "message.received",
"timestamp": "2024-01-15T10:30:00Z",
"sessionId": "default",
"idempotencyKey": "a1b2c3d4e5f6",
"deliveryId": "9f8e7d6c5b4a",
"data": {
"id": "3EB0F5A2B4C1",
"chatId": "628123456789@c.us",
"from": "628123456789@c.us",
"body": "Hello!",
"type": "text",
"timestamp": 1705312200
}
}

Reference fields in downstream nodes with n8n expressions — for example {{$json.data.body}} for the message text and {{$json.data.chatId}} for the chat to reply to.

A few notes from the payload contract:

  • Read message fields from data (data.body, data.chatId), and the message identifier from data.id — incoming payloads use id, not messageId.
  • type is engine-neutral: voice notes are voice, shared contacts are contact, and plain chats are text. On Baileys, since v0.23.6, a tapped WhatsApp Business button or list row is text as well, with the choice's id in data.button.id; see Output shape.
  • Forwarded messages carry data.isForwarded: true (omitted when not forwarded) and data.forwardingScore (when positive) on message.received, message.sent, and Message → Get History items since server v0.29.1 (stripped on revoked placeholders and not stored in Message → List rows).
  • Check Exists returns whatsappId, the chat id WhatsApp holds for the number, as <phone>@c.us on both engines since v0.26.0 (whatsapp-web.js answered an @lid id for a contact migrated to privacy-id addressing before). It can differ from the digits you sent.
Deduplicate retries

OpenWA guarantees at-least-once delivery: it retries a failed POST and replays anything a gateway crash stranded. Both carry the same idempotencyKey, so key your dedup step on that, not on deliveryId, which identifies one attempt and is re-minted on every replay. Use a Remove Duplicates node on idempotencyKey. The Trigger's own Deduplicate Deliveries toggle does the same where n8n saves its record, but from n8n 2.19.2 until n8n fixed it in 2.46 (the fix is in the source of 2.46.4 and later) n8n does not save the record, so the toggle has no effect there.

Example: auto-reply to incoming messages​

This is the smallest useful workflow — trigger on an incoming message, check the text, and reply.

  1. OpenWA Trigger — select your OpenWA API credential and subscribe to message.received.
  2. IF — condition: {{$json.data.body}} contains hello (case-insensitive).
  3. OpenWA → Send Text — on the true branch, configure:
    • Session Name or ID: pick your session from the dropdown, which lists the sessions on your server
    • Chat ID: {{$json.data.chatId}}
    • Message: Hi! Thanks for reaching out — how can we help?
  4. Activate the workflow. The trigger registers its webhook with OpenWA automatically.

Send "hello" to your WhatsApp number, and you'll get the reply within seconds.

On a Baileys session, since v0.23.6, messages that arrived while the session was offline are delivered as message.received once it reconnects, so this workflow also answers that backlog. To skip it, add a second IF condition on the message's age, for example {{ $now.toSeconds() - $json.data.timestamp }} is less than 300 (data.timestamp is in epoch seconds).

From here, swap the IF for a router to branch on keywords, append each new lead to Google Sheets before replying, or post a Slack alert when session.disconnected fires. The trigger gives you the inbound event; the action node sends the response.

Troubleshooting​

SymptomCauseFix
Credential Test failsServer unreachable, wrong key, a key restricted to selected chats (v0.23.6+), or a key whose allowedIps exclude the n8n hostConfirm the server is running and reachable from n8n, the key is correct, and Server URL has no /api. A 401 means the key is missing, unknown, revoked or expired. A 403 means a valid key was refused: its allowedIps exclude the host n8n calls from (gateway v0.24.0 and newer; older gateways answered 401), or it is restricted to selected chats, a valid key that this test cannot use; a session restriction alone does not fail the test. See Configure the OpenWA API credential for what such a key can still do.
Trigger fires once in the editor, then goes quietListen for test event registers n8n's test URL, which stops after a single deliveryActivate the workflow so the trigger registers its production URL.
Trigger never firesOpenWA can't reach n8n's webhook URLConfirm n8n's webhook URL is reachable from the gateway (check firewalls and proxies) and that the session is connected. Then ask the gateway which side dropped the event with GET /api/webhooks/delivery-failures?sessionId={sessionId} (ADMIN key): a row means OpenWA delivered and n8n rejected it, an empty list means the event never reached delivery.
A call.accepted, call.rejected, or call.missed trigger never runsThe session runs whatsapp-web.jsThose three outcomes are Baileys-only, and call.received is not reliable on whatsapp-web.js. For dependable call events, run the gateway on Baileys (ENGINE_TYPE=baileys). The engine is instance-wide, and a session must be linked again under it unless it still holds a Baileys link from an earlier run.
Workflow won't activate; webhook creation fails with 400The gateway doesn't know one of the selected events, or a field used in the Trigger's Filterssession.restriction, presence.update, and the three call outcomes need OpenWA ≥ 0.14.0, group.join_request needs ≥ 0.15.0, event.response needs ≥ 0.25.0, and message.receipt and poll.vote need ≥ 0.26.0. The kind filter field needs ≥ 0.23.4 and chatId ≥ 0.23.6. Upgrade the gateway, or deselect the events and drop the filter conditions it doesn't know.
Send Text fails or returns 400Unknown session id, session never started, or an invalid chat idPick a real session from the node's Session Name or ID dropdown, start it, and check the chat id format (628123456789@c.us). Since package 1.3.0 the node refuses a bare number without its @ domain before sending, and since server v0.26.0 the gateway refuses it with 400 as well (before v0.26.0 it answered 500 on Baileys).
Send Text returns 409An engine exists but is not connected, so the request never reached WhatsApp. On whatsapp-web.js the session can still read ready while WhatsApp Web reloads its pageWait for the session to reach ready, then retry. While the page reloads, the message says to retry every few seconds, and it can take a few minutes. Since server v0.31.0 a 409 that says the message may or may not have been sent is different: check the chat before sending again.
Message sends but never arrivesRecipient isn't on WhatsAppUse the Check Exists operation before sending to unverified numbers.

Next steps​