Skip to content

Free, Open Source, Self-Hosted WhatsApp API Gateway

docs: add n8n community workflow example

Abhinav Rajbe3c592d7c67
diff --git a/docs/23-community-integrations.md b/docs/23-community-integrations.md
index 63615ecd0..55339d71c 100644
--- a/docs/23-community-integrations.md
+++ b/docs/23-community-integrations.md
@@ -13,6 +13,7 @@ Third-party integrations and adapters built by the community on top of OpenWA's
| Integration | Platform | Source | Notes |
| ------------------- | ------------------------------------------------------------- | ---------------------------------------------------------------------------------------------------------------------------------------------- | -------------------------------------------------------------------------------------------------------------------------------------- |
| **ioBroker.openwa** | [ioBroker](https://www.iobroker.net/) (home / IoT automation) | [ThorstenBoettler/ioBroker.openwa](https://github.com/ThorstenBoettler/ioBroker.openwa) · [npm](https://www.npmjs.com/package/iobroker.openwa) | Send text / image / video / audio / document messages to chats and groups through OpenWA's REST API, with Blockly blocks. Early stage. |
+| **n8n to Discord** | [n8n](https://n8n.io/) (workflow automation) | [docs/examples/n8n](./examples/n8n) | A minimal workflow template to receive OpenWA webhooks and post incoming messages to a Discord channel using built-in n8n HTTP nodes. |
Maintain an integration built on OpenWA and want it listed here? Open a PR adding a row (or an issue), including the repository link and a one-line description.
diff --git a/docs/examples/n8n/README.md b/docs/examples/n8n/README.md
new file mode 100644
index 000000000..624c88593
--- /dev/null
+++ b/docs/examples/n8n/README.md
@@ -0,0 +1,44 @@
+# n8n Workflow: OpenWA to Discord
+
+This example demonstrates how to receive OpenWA webhooks using n8n and forward incoming WhatsApp messages to a Discord channel using n8n's built-in HTTP Request node. No custom n8n node package is required.
+
+## Prerequisites
+
+1. An n8n instance.
+2. A Discord Webhook URL.
+3. OpenWA configured and running.
+
+## Setup
+
+1. **Import the Workflow**: Open n8n, click the "Import from file" option, and select the [`workflow.json`](./workflow.json) file.
+2. **Environment Variable**: The workflow expects a Discord webhook URL. Define it as an environment variable in n8n (`DISCORD_WEBHOOK_URL`), or manually paste your webhook URL into the URL field of the HTTP Request node.
+3. **Get the Webhook URL**: Activate the workflow and copy the **Production URL** from the OpenWA Webhook node (e.g., `https://n8n.example.com/webhook/openwa-discord`).
+4. **Register in OpenWA**: Send a POST request to your OpenWA server to register the webhook URL, subscribing to the `message.received` event.
+
+### API Key Scope
+
+The API key used to register the webhook in OpenWA needs the **`OPERATOR`** role (or higher, such as `ADMIN`). A `VIEWER` key cannot register webhooks.
+
+### Webhook Payload Expected
+
+This workflow expects the standard OpenWA webhook payload for the `message.received` event.
+
+```json
+{
+ "event": "message.received",
+ "timestamp": "2024-01-15T10:30:00Z",
+ "sessionId": "default",
+ "idempotencyKey": "a1b2c3d4e5f6...",
+ "deliveryId": "9f8e7d6c5b4a...",
+ "data": {
+ "id": "3EB0F5A2B4C...",
+ "chatId": "[email protected]",
+ "from": "[email protected]",
+ "body": "Hello!",
+ "type": "text",
+ "timestamp": 1705312200
+ }
+}
+```
+
+The workflow automatically extracts `{{ $json.body.data.from }}` and `{{ $json.body.data.body }}` to format the Discord message.
diff --git a/docs/examples/n8n/workflow.json b/docs/examples/n8n/workflow.json
new file mode 100644
index 000000000..836f1a0d1
--- /dev/null
+++ b/docs/examples/n8n/workflow.json
@@ -0,0 +1,52 @@
+{
+ "name": "OpenWA to Discord via Webhook",
+ "nodes": [
+ {
+ "parameters": {
+ "httpMethod": "POST",
+ "path": "openwa-discord",
+ "responseMode": "onReceived",
+ "options": {}
+ },
+ "name": "OpenWA Webhook",
+ "type": "n8n-nodes-base.webhook",
+ "typeVersion": 1,
+ "position": [ 250, 300 ]
+ },
+ {
+ "parameters": {
+ "method": "POST",
+ "url": "={{ $env.DISCORD_WEBHOOK_URL }}",
+ "sendBody": true,
+ "bodyParameters": {
+ "parameters": [
+ {
+ "name": "content",
+ "value": "=*New WhatsApp Message*\n**From:** `{{ $json.body.data.from }}`\n**Message:** {{ $json.body.data.body }}"
+ }
+ ]
+ },
+ "options": {}
+ },
+ "name": "Post to Discord",
+ "type": "n8n-nodes-base.httpRequest",
+ "typeVersion": 4,
+ "position": [ 450, 300 ]
+ }
+ ],
+ "connections": {
+ "OpenWA Webhook": {
+ "main": [
+ [
+ {
+ "node": "Post to Discord",
+ "type": "main",
+ "index": 0
+ }
+ ]
+ ]
+ }
+ },
+ "active": false,
+ "settings": {}
+}