@open-wa/node-red 5.1.0 → 5.2.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +66 -39
- package/package.json +4 -4
package/README.md
CHANGED
|
@@ -1,72 +1,99 @@
|
|
|
1
1
|
# @open-wa/node-red
|
|
2
2
|
|
|
3
|
-
|
|
3
|
+
`@open-wa/node-red` connects Node-RED flows to an existing open-wa Easy API session. The current package is `5.1.0` and registers three node types: `owa-server`, `cmd`, and `listen`.
|
|
4
4
|
|
|
5
|
-
|
|
5
|
+
The integration keeps the Node-RED palette small and maps commands and events to the Easy API metadata endpoints. It uses `@open-wa/socket-client` as the compatibility client; v5 commands travel over HTTP RPC and runtime events use the client event stream.
|
|
6
6
|
|
|
7
|
-
##
|
|
7
|
+
## Quick start
|
|
8
8
|
|
|
9
|
-
|
|
9
|
+
Start Easy API separately, then install the package into Node-RED's user directory:
|
|
10
10
|
|
|
11
|
-
|
|
11
|
+
```bash
|
|
12
|
+
npx @open-wa/wa-automate@5.1.0 \
|
|
13
|
+
--session-id sales \
|
|
14
|
+
--port 8080 \
|
|
15
|
+
--api-key "$OPENWA_API_KEY"
|
|
12
16
|
|
|
13
|
-
|
|
17
|
+
cd ~/.node-red
|
|
18
|
+
npm install @open-wa/node-red@5.1.0
|
|
19
|
+
node-red
|
|
20
|
+
```
|
|
21
|
+
|
|
22
|
+
Open `http://127.0.0.1:1880`, choose **Manage palette**, and confirm `@open-wa/node-red` is installed. Add an **owa-server** configuration node with the Easy API URL and the same key passed to `--api-key`. Leave the key empty only when Easy API was started without one.
|
|
23
|
+
|
|
24
|
+
The configuration node keeps the `SocketClient` in Node-RED global context. It reports `connected`, `disconnected`, and connection-error states so a flow can distinguish a stopped API from a command failure.
|
|
14
25
|
|
|
15
26
|
## Node types
|
|
16
27
|
|
|
17
|
-
|
|
|
18
|
-
| --- | --- |
|
|
19
|
-
| `owa-server` |
|
|
20
|
-
| `cmd` |
|
|
21
|
-
| `listen` |
|
|
28
|
+
| Palette label | Runtime type | Behavior |
|
|
29
|
+
| --- | --- | --- |
|
|
30
|
+
| **owa-server** | `owa-server` | Stores `name`, `url`, and optional `key`, creates a `SocketClient`, and owns the connection lifecycle. |
|
|
31
|
+
| **Command** | `cmd` | Loads command metadata from `/meta/basic/commands`, then calls `client.ask(method, args)` with node or message values. |
|
|
32
|
+
| **Listen** | `listen` | Loads listener names from `/meta/basic/listeners`, subscribes with `client.listen(listener, callback)`, and emits event data as `msg.payload`. |
|
|
22
33
|
|
|
23
|
-
|
|
34
|
+
The visible labels are **Command** and **Listen**. Older guides that describe separate Send, Receive, Session, or Media nodes refer to `@open-wa/node-red-contrib-wa-automate`, which is a different package and palette.
|
|
24
35
|
|
|
25
|
-
|
|
36
|
+
## Configuration fields
|
|
26
37
|
|
|
27
38
|
### `owa-server`
|
|
28
39
|
|
|
29
|
-
- `name`: Node-RED display name
|
|
30
|
-
- `url`:
|
|
31
|
-
- `key`: Optional API key
|
|
40
|
+
- `name`: Node-RED display name.
|
|
41
|
+
- `url`: Easy API base URL, such as `http://127.0.0.1:8080`.
|
|
42
|
+
- `key`: Optional API key. The editor sends it as `X-API-Key` while loading command and listener metadata, and the client uses it for runtime requests.
|
|
32
43
|
|
|
33
44
|
### `cmd`
|
|
34
45
|
|
|
35
|
-
- `server`:
|
|
36
|
-
- `method`: Command
|
|
37
|
-
- `args`: JSON
|
|
38
|
-
- `
|
|
39
|
-
|
|
46
|
+
- `server`: The **owa-server** configuration node.
|
|
47
|
+
- `method`: Command name, such as `sendText`.
|
|
48
|
+
- `args`: JSON arguments. Message values in `msg.method` and `msg.args` take precedence; object-like `msg.payload` is merged when configured arguments are object-like.
|
|
49
|
+
- `timeout`: Seconds. Invalid or empty values fall back to 30 seconds; `-1` intentionally disables the command timeout.
|
|
50
|
+
|
|
51
|
+
For `sendText`, the command arguments can be an object:
|
|
52
|
+
|
|
53
|
+
```json
|
|
54
|
+
{
|
|
55
|
+
"to": "1234567890@c.us",
|
|
56
|
+
"content": "Hello from Node-RED"
|
|
57
|
+
}
|
|
58
|
+
```
|
|
40
59
|
|
|
41
60
|
### `listen`
|
|
42
61
|
|
|
43
|
-
- `server`:
|
|
44
|
-
- `listener`: Listener name
|
|
62
|
+
- `server`: The **owa-server** configuration node.
|
|
63
|
+
- `listener`: Listener name, for example `onMessage`.
|
|
45
64
|
- `name`: Node-RED display name.
|
|
46
65
|
|
|
47
|
-
|
|
66
|
+
The listener stops when its node closes or its server disconnects. A session that is not authenticated or ready cannot emit WhatsApp events even when Node-RED itself is running.
|
|
67
|
+
|
|
68
|
+
## Connection checks
|
|
69
|
+
|
|
70
|
+
Use the same URL and key outside Node-RED to separate API reachability, authentication, and session readiness:
|
|
71
|
+
|
|
72
|
+
```bash
|
|
73
|
+
curl -sS -D - \
|
|
74
|
+
-H "X-API-Key: $OPENWA_API_KEY" \
|
|
75
|
+
http://127.0.0.1:8080/health
|
|
48
76
|
|
|
49
|
-
-
|
|
50
|
-
-
|
|
51
|
-
|
|
52
|
-
|
|
77
|
+
curl -sS -D - \
|
|
78
|
+
-H "X-API-Key: $OPENWA_API_KEY" \
|
|
79
|
+
http://127.0.0.1:8080/meta/basic/commands
|
|
80
|
+
```
|
|
81
|
+
|
|
82
|
+
A connection refusal means the URL or process is wrong. `401` means the configured key is absent or different. A `200` health response with `connected: false` or `session.ready: false` means Node-RED can reach Easy API but the WhatsApp session still needs authentication or readiness work.
|
|
53
83
|
|
|
54
84
|
## Development
|
|
55
85
|
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
- `pnpm --filter @open-wa/node-red lint:fix`
|
|
64
|
-
- `pnpm --filter @open-wa/node-red test`
|
|
65
|
-
- `pnpm --filter @open-wa/node-red test:watch`
|
|
86
|
+
From the monorepo checkout:
|
|
87
|
+
|
|
88
|
+
```bash
|
|
89
|
+
pnpm --filter @open-wa/node-red dev
|
|
90
|
+
```
|
|
91
|
+
|
|
92
|
+
The package source lives under `integrations/node-red`; the published Node-RED entrypoints are the `dist/nodes/*` files declared in `package.json`.
|
|
66
93
|
|
|
67
94
|
## Documentation
|
|
68
95
|
|
|
69
|
-
See the [
|
|
96
|
+
See the [Node-RED guide](https://openwa.dev/docs/guides/node-red) for the importable echo flow and the full troubleshooting journey.
|
|
70
97
|
|
|
71
98
|
## License
|
|
72
99
|
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@open-wa/node-red",
|
|
3
|
-
"version": "5.
|
|
3
|
+
"version": "5.2.0",
|
|
4
4
|
"description": "Official @open-wa node-red integration.",
|
|
5
5
|
"publishConfig": {
|
|
6
6
|
"access": "public"
|
|
@@ -55,9 +55,9 @@
|
|
|
55
55
|
"yarpm": "^1.2.0"
|
|
56
56
|
},
|
|
57
57
|
"dependencies": {
|
|
58
|
-
"@open-wa/schema": "5.
|
|
59
|
-
"@open-wa/socket-client": "5.
|
|
60
|
-
"@open-wa/wa-automate-types-only": "5.
|
|
58
|
+
"@open-wa/schema": "5.2.0",
|
|
59
|
+
"@open-wa/socket-client": "5.2.0",
|
|
60
|
+
"@open-wa/wa-automate-types-only": "5.2.0"
|
|
61
61
|
},
|
|
62
62
|
"scripts": {
|
|
63
63
|
"add-node": "node ./utils/add-node.js",
|