OpenWA Simple Integration N8N Workflow A developer created an n8n workflow integrating OpenWA with WhatsApp to build an AI bot with three varieties: personal contact, group message, and group message with @agent mention. The workflow uses an Ollama chat model (llama3.2:3b) with memory and sends responses via OpenWA API. | { | | | "name": "WhatsApp AI Bot — 3 Varieties", | | | "nodes": | | | { | | | "parameters": { | | | "httpMethod": "POST", | | | "path": "wa-webhook", | | | "options": {} | | | }, | | | "id": "321adc8a-c16f-4b60-baa3-3c51d7f748d6", | | | "name": "WA Webhook", | | | "type": "n8n-nodes-base.webhook", | | | "typeVersion": 2.1, | | | "position": 112, 544 , | | | "webhookId": "49cae27c-b557-4d0c-a7ab-101a3d83c8ac" | | | }, | | | { | | | "parameters": { | | | "method": "POST", | | | "url": "=http://openwa-api:2785/api/sessions/{{ $ 'WA Webhook' .item.json.body.sessionId }}/messages/send-text", | | | "authentication": "genericCredentialType", | | | "genericAuthType": "httpHeaderAuth", | | | "sendHeaders": true, | | | "headerParameters": { | | | "parameters": { "name": "Content-Type", "value": "=application/json" } | | | }, | | | "sendBody": true, | | | "bodyParameters": { | | | "parameters": | | | { "name": "chatId", "value": "={{ $json.chatId }}" }, | | | { "name": "text", "value": "={{ $json.output }}" } | | | | | | }, | | | "options": {} | | | }, | | | "id": "52d1f993-69fb-461b-abf6-e683c288e505", | | | "name": "Send WhatsApp Message", | | | "type": "n8n-nodes-base.httpRequest", | | | "typeVersion": 4.4, | | | "position": 1632, 544 , | | | "credentials": { "httpHeaderAuth": { "id": "REPLACE ME", "name": "OpenWA API Key" } } | | | }, | | | { | | | "parameters": { "model": "llama3.2:3b", "options": {} }, | | | "type": "@n8n/n8n-nodes-langchain.lmChatOllama", | | | "typeVersion": 1, | | | "position": 1008, 784 , | | | "id": "f731fc8d-6965-45a3-82bc-0ffe634a1173", | | | "name": "Ollama Chat Model", | | | "credentials": { "ollamaApi": { "id": "REPLACE ME", "name": "Ollama account" } } | | | }, | | | { | | | "parameters": { | | | "sessionIdType": "customKey", | | | "sessionKey": "={{ $json.body.data.chatId }}", | | | "contextWindowLength": 30 | | | }, | | | "type": "@n8n/n8n-nodes-langchain.memoryBufferWindow", | | | "typeVersion": 1.4, | | | "position": 1184, 816 , | | | "id": "d29aeafc-0398-477c-9757-e0cb25799ac4", | | | "name": "Simple Memory" | | | }, | | | { | | | "parameters": { | | | "conditions": { | | | "options": { "caseSensitive": true, "leftValue": "", "typeValidation": "strict", "version": 3 }, | | | "conditions": { | | | "id": "6c1bd14c-82d9-4e84-9710-f7cff64ff5e7", | | | "leftValue": "={{ $json.body.data.contact.pushName }}", | | | "rightValue": "YourContactName", | | | "operator": { "type": "string", "operation": "equals" } | | | } , | | | "combinator": "and" | | | }, | | | "options": {} | | | }, | | | "type": "n8n-nodes-base.if", | | | "typeVersion": 2.3, | | | "position": 544, 288 , | | | "id": "5d673758-ca77-4362-88b8-4f1c7c657332", | | | "name": "Variety 1: Personal Contact" | | | }, | | | { | | | "parameters": { | | | "conditions": { | | | "options": { "caseSensitive": true, "leftValue": "", "typeValidation": "strict", "version": 3 }, | | | "conditions": { | | | "id": "447c3290-2b09-4bd5-9a20-87373df3dc3d", | | | "leftValue": "={{ $json.body.data.isGroup }}", | | | "rightValue": true, | | | "operator": { "type": "boolean", "operation": "equals" } | | | } , | | | "combinator": "and" | | | }, | | | "options": {} | | | }, | | | "type": "n8n-nodes-base.if", | | | "typeVersion": 2.3, | | | "position": 560, 512 , | | | "id": "360ee92f-467a-4feb-85c5-7688834a3b1b", | | | "name": "Variety 2: Group Message" | | | }, | | | { | | | "parameters": { | | | "conditions": { | | | "options": { "caseSensitive": true, "leftValue": "", "typeValidation": "strict", "version": 3 }, | | | "conditions": | | | { | | | "id": "424bfcff-ef4a-4911-bdea-44eb2c4cc52e", | | | "leftValue": "={{ $json.body.data.isGroup }}", | | | "rightValue": true, | | | "operator": { "type": "boolean", "operation": "equals" } | | | }, | | | { | | | "id": "f60b4be0-1c7b-4ecd-bf65-2b3124897963", | | | "leftValue": "={{ $json.body.data.body }}", | | | "rightValue": "@agent", | | | "operator": { "type": "string", "operation": "contains" } | | | } | | | , | | | "combinator": "and" | | | }, | | | "options": {} | | | }, | | | "type": "n8n-nodes-base.if", | | | "typeVersion": 2.3, | | | "position": 560, 736 , | | | "id": "b9545930-1ec0-435b-8d9a-3c757ac35f17", | | | "name": "Variety 3: @agent Mention" | | | }, | | | { | | | "parameters": { | | | "assignments": { | | | "assignments": | | | { "id": "be20df00-04bc-46aa-8f26-462af1db0dcb", "name": "output", "value": "={{ $json.output }}", "type": "string" }, | | | { "id": "c58843cc-e1ec-4803-97c0-b3dc97557d32", "name": "chatId", "value": "={{ $ 'WA Webhook' .item.json.body.data.chatId }}", "type": "string" } | | | | | | }, | | | "options": {} | | | }, | | | "type": "n8n-nodes-base.set", | | | "typeVersion": 3.4, | | | "position": 1424, 544 , | | | "id": "f021c824-6573-4ecb-a2ee-cc6c4c8cdd01", | | | "name": "Set Message and ID" | | | }, | | | { | | | "parameters": { | | | "promptType": "define", | | | "text": "={{ $json.body.data.body }}", | | | "options": { "systemMessage": "You are a helpful assistant." } | | | }, | | | "type": "@n8n/n8n-nodes-langchain.agent", | | | "typeVersion": 3.1, | | | "position": 1072, 512 , | | | "id": "19742472-9a7b-4e65-8cff-a43a37065a4b", | | | "name": "Simple Agent" | | | } | | | , | | | "pinData": {}, | | | "connections": { | | | "WA Webhook": { | | | "main": | | | { "node": "Variety 1: Personal Contact", "type": "main", "index": 0 }, | | | { "node": "Variety 2: Group Message", "type": "main", "index": 0 }, | | | { "node": "Variety 3: @agent Mention", "type": "main", "index": 0 } | | | | | | }, | | | "Ollama Chat Model": { "ai languageModel": { "node": "Simple Agent", "type": "ai languageModel", "index": 0 } }, | | | "Simple Memory": { "ai memory": { "node": "Simple Agent", "type": "ai memory", "index": 0 } }, | | | "Variety 3: @agent Mention": { "main": { "node": "Simple Agent", "type": "main", "index": 0 } }, | | | "Set Message and ID": { "main": { "node": "Send WhatsApp Message", "type": "main", "index": 0 } }, | | | "Simple Agent": { "main": { "node": "Set Message and ID", "type": "main", "index": 0 } } | | | }, | | | "active": false, | | | "settings": { "executionOrder": "v1" } | | | } |