Node-RED integration
Connect Node-RED to an existing open-wa Easy API session with the current v5 nodes.
@open-wa/node-red connects Node-RED to an already running open-wa Easy API instance. The current package is 5.1.0 and registers exactly three node types: the owa-server configuration node, Command, and Listen. It does not provide separate Send, Receive, Session, or Media nodes.
Prerequisites
- Node-RED 5.x and Node.js available on the machine that runs the flow.
- An authenticated open-wa session with Easy API enabled.
- The Easy API base URL, for example
http://127.0.0.1:8080. - The Easy API key if the session was started with
--api-key.
Install the supported package
Install into the Node-RED user directory so Node-RED can load it from its palette:
cd ~/.node-red
npm install @open-wa/node-red@5.1.0
node-redOpen http://127.0.0.1:1880, choose Manage palette, and confirm the @open-wa/node-red package is installed. The package name is @open-wa/node-red; the older @open-wa/node-red-contrib-wa-automate guide describes a different package and palette.
Connect to Easy API
Start an Easy API session separately. This loopback example requires Node-RED and Easy API to run on the same machine. Replace the API-key placeholder with a local secret before running it; for remote access, follow the network and security guidance and use an API address reachable from the Node-RED host.
export OPENWA_API_KEY="replace-with-your-api-key"
npx @open-wa/wa-automate@5.1.0 --session-id sales --host 127.0.0.1 --port 8080 --api-key "$OPENWA_API_KEY"In Node-RED, add the owa-server configuration node and fill these fields:
| Field | Value |
|---|---|
| Name | A label such as sales Easy API. |
| URL | The Easy API base URL, such as http://127.0.0.1:8080. |
| Key | The same value passed to --api-key; leave empty only when the API has no key. |
The node creates a SocketClient for that URL. In v5 the client uses HTTP RPC for commands and the event stream for listeners; the old node help text mentioning --socket is stale for this package.
Current palette
owa-server configuration node
Stores name, url, and optional key. It reports connected, disconnected, and connection-error status and keeps the client available to the flow.
Command
The visible palette label is Command and the runtime type is cmd. It loads command names from /meta/basic/commands, then calls the selected method through the configured server. Set method and JSON args in the node, or provide msg.method and msg.args at runtime. A command waits for the server connection and defaults to a 30-second timeout; set timeout to -1 only when an unbounded call is intentional.
For sendText, the argument object is:
{
"to": "1234567890@c.us",
"content": "Hello from Node-RED"
}Listen
The visible palette label is Listen and the runtime type is listen. It loads listener names from /meta/basic/listeners, registers one listener against the server, and emits received data as msg.payload. Use onMessage for inbound message events; the listener is stopped when the node closes.
Importable echo flow
Import this JSON from Node-RED's menu (Import → Clipboard). Edit the url and key on the owa-server configuration node before deploying. The flow listens for onMessage and sends pong only when an inbound text message is exactly ping, ignoring letter case and surrounding spaces. It sends a WhatsApp reply, so deploy it only when you intend to reply to matching messages.
[
{
"id": "openwa-tab",
"type": "tab",
"label": "open-wa echo",
"disabled": false,
"info": "Echo inbound messages through the v5 Easy API client"
},
{
"id": "openwa-server",
"type": "owa-server",
"name": "sales Easy API",
"url": "http://127.0.0.1:8080",
"key": "REPLACE_WITH_API_KEY"
},
{
"id": "openwa-listen",
"type": "listen",
"z": "openwa-tab",
"name": "incoming messages",
"server": "openwa-server",
"listener": "onMessage",
"x": 170,
"y": 120,
"wires": [["openwa-format"]]
},
{
"id": "openwa-format",
"type": "function",
"z": "openwa-tab",
"name": "make echo command",
"func": "const message = msg.payload || {};\nif (!message.from || typeof message.body !== 'string' || message.body.trim().toLowerCase() !== 'ping') return null;\nmsg.method = 'sendText';\nmsg.args = { to: message.from, content: 'pong' };\nreturn msg;",
"outputs": 1,
"x": 390,
"y": 120,
"wires": [["openwa-command"]]
},
{
"id": "openwa-command",
"type": "cmd",
"z": "openwa-tab",
"name": "sendText",
"server": "openwa-server",
"method": "sendText",
"args": "{}",
"timeout": "30",
"x": 610,
"y": 120,
"wires": [["openwa-debug"]]
},
{
"id": "openwa-debug",
"type": "debug",
"z": "openwa-tab",
"name": "send result",
"active": true,
"tosidebar": true,
"complete": "payload",
"x": 820,
"y": 120,
"wires": []
}
]The REPLACE_WITH_API_KEY value is a placeholder, not a secret to commit. This node stores key as an ordinary flow property, not as a declared Node-RED credential. Do not commit or share an exported flow containing a real key, and restrict access to the Node-RED editor and flow exports. Confirm that the owa-server URL and key match the running Easy API.
Troubleshooting
For the canonical readiness and authentication checks, see Readiness and authentication checks.
| Symptom | Command or observation | Expected result | Next action |
|---|---|---|---|
owa-server stays disconnected | curl -sS http://127.0.0.1:8080/health | HTTP 200 means the API is reachable; check connected and session.ready for the WhatsApp session state. /health is public and does not check the API key. | On connection refusal, start Easy API or correct URL and port. If the session is not ready, complete authentication before debugging Node-RED. Check a configured key with the metadata request below. |
Metadata request is 401 | curl -i -H "X-API-Key: $OPENWA_API_KEY" http://127.0.0.1:8080/meta/basic/commands | The response lists command metadata. | Put the same key in owa-server → Key; an empty or different key is rejected. |
Command shows “Waiting for socket connection” | Check the owa-server status and the metadata request above. | The server node connects and the command list loads. | Correct the node URL or key, then redeploy. If Easy API is reachable but the session is not ready, finish WhatsApp authentication first. |
A matching ping gets no reply | Check the Listen node status and /meta/basic/listeners response. | The node should show listening, and onMessage should be listed. | Confirm the message body is ping, the session is ready, and the Command node uses sendText. Other messages are intentionally ignored by this flow. |
sendText times out | Inspect the Command status | It reports a timeout after the configured seconds. | Check the chat ID (@c.us or @g.us), session readiness, and Easy API logs; increase timeout only for a known slow operation. |
Related
Was this helpful?
Your answer includes the page path and docs version.
