n8n තුළ WhatsApp AI agent එක: පිළිතුර ඔබේ workflow එක ලියයි
automation එකක් POST කරයි ගනුදෙනුකරුගේ message එක, අත්සන් කර, chat එකේ මෑත පණිවිඩ 10ක් දක්වා සමඟ, n8n Webhook node එකට. AI Agent node එක පිළිතුර ලියයි, Respond to Webhook node එක {"reply": "..."} තත්පර 20ක් ඇතුළත ආපසු දෙයි, ඒ පෙළ WhatsApp Business අංකයෙන් යවයි, ඒ අංකය යෙදුමේ දිගටම ක්රියා කරයි. මන්දගාමී agent එකක් ඇත්නම්, Meta හි webhook කෙලින්ම ලැබී Graph API හරහා පිළිතුරු දෙයි.
easyCoexistence ඔබ දැනටමත් යෙදුමේ භාවිතා කරන WhatsApp Business අංකය Coexistence හරහා Meta හි Cloud API වෙත සම්බන්ධ කර එහි automations ධාවනය කරයි.
Call my webhook step එක ඔබේ workflow එකේ පිළිතුර එනතෙක් රැඳී සිටින කාලය, ඉන් පසු step එක අසාර්ථක වේ.
history හි යවන chat එකේ මෑත පණිවිඩ උපරිම ගණන, පැරණිම පළමුව, ධාවනය ආරම්භ කළ පණිවිඩයෙන් අවසන් වේ.
එක WhatsApp text එකක් ලෙස යවන පිළිතුරක අක්ෂර ගණන; ඊට වැඩි කොටස කපා දමනු ලැබේ.
Webhook step එකක් අසාර්ථක වන විට එකම automation එකට යවන අසාර්ථක ඊමේල් දෙකක් අතර කෙටිම කාලය.
n8n Cloud හි Code node එකේ crypto සහ moment ඉඩ දෙන දේ; self-hosted n8n හි crypto සක්රිය කරන්නේ NODE_FUNCTION_ALLOW_BUILTIN මගිනි.
ගනුදෙනුකරුගේ අවසන් පණිවිඩයෙන් පසු customer service window එක; ඉන් පසු Meta පිළිගන්නේ template පණිවිඩ පමණි.
WhatsApp පණිවිඩයක් n8n AI agent එකට කෙසේ ළඟා වේද?
automation එකක් හරහා, අංකය මත. අංකය එහි පණිවිඩ easyCoexistence හරහා ලැබිය යුතුය (“Through easyCoexistence” mode එක), එවිට Meta ඒවා මෙතැනට යවයි. trigger එක A message arrives වන සහ step එක Call my webhook වන automation එකක් පණිවිඩය ඔබේ n8n Production URL එකට POST කරයි. workflow එක එම HTTP ප්රතිචාරය තුළම පිළිතුර ලබා දෙන අතර, ඒ පෙළ ඔබේ අංකයෙන් WhatsApp පණිවිඩයක් ලෙස ගනුදෙනුකරුට යයි.
n8n කැඳවීමට පෙර, ධාවනය දැනටමත් ආරක්ෂක පරීක්ෂා පසු කර ඇත. Meta නැවත යවන delivery එකක් දෙවන ධාවනයක් ආරම්භ නොකරයි, යෙදුමේ ඔබ ටයිප් කළ පිළිතුරක් එම chat එකේ automation එක විරාම කරයි (පෙරනිමියෙන් පැය 4), සහ පිළිතුර ගමන් කරන්නේ ගනුදෙනුකරුගේ අවසන් පණිවිඩයෙන් පැය 24ක් ඇතුළතදී පමණි. ඔබේ workflow එක තීරණය කරන්නේ කුමක් කිව යුතුද යන්න පමණි.
easyCoexistence n8n Webhook node එකට කුමක් යවයි?
JSON POST එකක්, User-Agent easyCoexistence-automations/1, X-EC-Event automation.step ලෙස සහ X-EC-Signature header එකක්. message හි ගනුදෙනුකරුගේ පෙළ, නැතහොත් මාධ්ය සඳහා [image] (caption සමඟ) වැනි placeholder එකක්; හඬ පණිවිඩයක් පැමිණෙන්නේ [voice message] ලෙසිනි, OpenAI හෝ OpenRouter යතුරක් සුරැකි විට එහි වචන සමඟ. history හි chat එකේ මෑත පණිවිඩ 10ක් දක්වා, පැරණිම පළමුව, එක් එක් පණිවිඩයට direction එකක් සමඟ: ගනුදෙනුකරු සඳහා in, automation එකේ පිළිතුර සඳහා out, දුරකථනයෙන් පුද්ගලයෙකු ලියන පණිවිඩ සඳහා echo. එය ආවරණය කරන්නේ ගිණුමේ රඳවා ගැනීමේ කාලය (දින 30, 90 හෝ 365, පෙරනිමියෙන් 90) සඳහා තබාගත් පණිවිඩ, සහ අංකයේ පණිවිඩ easyCoexistence හරහා පැමිණෙද්දී ලැබුණු ඒවා පමණි.
Editor එකේ Try it panel එකෙන් කරන test එකක් එම POST යවයි, නමුත් dry_run true ලෙස, හිස් history එකක්, Test customer නමැති 15550000000 නියැදි contact එක සහ test_ වලින් ආරම්භ වන message id එකක් සමඟ. කිසිවෙකුට කිසිවක් යවනු නොලැබේ, නමුත් ඔබේ workflow එක සැබවින්ම ධාවනය වේ, එබැවින් dry_run true වන විට orders සෑදීම වැනි side effects මඟ හරින්න.
{
"event": "automation.step",
"dry_run": false,
"automation": { "id": "b7e0c3a2-5d1f-4c8e-9a6b-2f4d8e1c7a90", "name": "Send to my system" },
"run_id": "0d9f6a41-8c2e-4b7a-a315-6e9c2b8d4f17",
"channel": {
"type": "whatsapp",
"connection_id": "3f2a9c1e-7b4d-4e8a-9c2f-1a2b3c4d5e6f",
"phone": "+1 631-555-0142",
"phone_number_id": "106540352242922"
},
"connection": { "id": "3f2a9c1e-7b4d-4e8a-9c2f-1a2b3c4d5e6f", "phone": "+1 631-555-0142", "phone_number_id": "106540352242922" },
"contact": { "id": "5511987654321", "wa_id": "5511987654321", "name": "Ana Souza" },
"message": {
"id": "wamid.HBgNNTUxMTk4NzY1NDMyMRUCABIYFjNFQjBDNzE4RjQ2QjI5RDkxQTNFAA==",
"type": "text",
"text": "Do you have gluten-free bread today?",
"at": "2026-11-11T14:02:11.000Z"
},
"history": [
{ "direction": "in", "text": "Hi! Are you open today?", "at": "2026-11-11T13:58:40.000Z" },
{ "direction": "out", "text": "Hi Ana! Yes, until 8 pm.", "at": "2026-11-11T13:58:45.000Z" },
{ "direction": "in", "text": "Do you have gluten-free bread today?", "at": "2026-11-11T14:02:11.000Z" }
]
}n8n හි signature එක කෙසේ පරීක්ෂා කරන්නද?
Webhook node එකට ඊළඟින් Code node එකක් එක් කරන්න. X-EC-Signature කියවන්නේ t=<unix seconds>,v1=<hex> ලෙසිනි, මෙහි v1 යනු t, dot එක සහ body එක මත HMAC-SHA256 වන අතර, automation එකේ Signing secret සමඟ යතුරු කර ඇත. එය පිටපත් කිරීමට, සුරැකි automation එක විවෘත කර එහි Call my webhook step එක තෝරන්න. සෑම automation එකකටම තමන්ගේම secret එකක් ඇති අතර MCP tools එය කිසිවිට ආපසු නොදෙන නිසා, ඔබේ AI විසින් සාදන ලද automation එකකටත් dashboard එකෙන් එක පිටපතක් අවශ්යයි. New secret බොත්තමක් එය ප්රතිස්ථාපනය කරන අතර පැරණි එක වහාම ක්රියා නොකරයි, සහ එය දැකිය හැක්කේ ගිණුමේ හිමිකරුට පමණි, ආරාධිත කණ්ඩායම් සාමාජිකයෙකුට නොවේ.
t ඔබේ ඔරලෝසුවෙන් මිනිත්තු 5කට වැඩියෙන් ඈත නම් ප්රතික්ෂේප කරන්න, සංසන්දනය constant-time ලෙස කරන්න, අසාර්ථක වූ විට throw කරන්න: එවිට workflow එක Respond to Webhook ට පෙර දෝෂ වේ, n8n 500 පිළිතුරු දෙයි, කිසිවක් යවනු නොලැබේ. n8n Cloud හි Code node වල crypto module ට ඉඩ දෙයි; self-hosted n8n හට NODE_FUNCTION_ALLOW_BUILTIN=crypto අවශ්යයි. IF node එක සමඟ Crypto node හි Hmac action එකත් ක්රියා කරයි, නමුත් IF සංසන්දනය constant-time නොවේ.
// n8n Code node, mode "Run Once for Each Item", placed right after the Webhook node.
// n8n Cloud allows require('crypto'); self-hosted needs NODE_FUNCTION_ALLOW_BUILTIN=crypto.
const crypto = require('crypto');
const SECRET = 'whsec_...'; // the automation's Signing secret, from its editor page
const m = /^t=(\d+),v1=([0-9a-f]{64})$/.exec($json.headers['x-ec-signature'] || '');
if (!m) throw new Error('Missing X-EC-Signature');
if (Math.abs(Date.now() / 1000 - Number(m[1])) > 300) throw new Error('Stale signature');
// The body was signed as compact JSON, which JSON.stringify rebuilds from the parsed body.
const mac = crypto.createHmac('sha256', SECRET).update(`${m[1]}.${JSON.stringify($json.body)}`).digest();
if (!crypto.timingSafeEqual(mac, Buffer.from(m[2], 'hex'))) throw new Error('Bad signature');
return { json: $json.body }; // event, dry_run, contact, message, history...AI Agent node සහ පිළිතුර කෙසේ සකසන්නද?
AI Agent node එකේ User Message field එකට ගනුදෙනුකරුගේ පෙළ දෙන්න, ඉතිරි සියල්ල System Message එකට: ව්යාපාරය කවුද, උද්ධෘත කළ හැකි කරුණු, ස්වරය, සහ history හි මෑත chat එක, එවිට අනුගාමි ප්රශ්නයක් අර්ථවත් වේ. ඔබට අවශ්ය chat model එක සහ order එකක් සොයන HTTP Request tool වැනි tools එක් කරන්න.
අවසානයේ Respond to Webhook node එකක් තබන්න, එය JSON සමඟ පිළිතුරු දෙයි සහ agent හි පෙළ reply නම් field එකේ තබයි. easyCoexistence එය trim කරයි, හිස් හෝ string නොවන reply එකක් නොසලකා හරියි, සහ ඉතිරි දේ අක්ෂර 4,096 දක්වා එක WhatsApp text එකක් ලෙස යවයි, එබැවින් markdown වෙනුවට සරල වාක්ය ඉල්ලන්න.
AI Agent node
Prompt: Define below
Prompt (User Message): {{ $json.message.text }}
Options > System Message:
You answer WhatsApp messages for Bloom Café, 12 Baker St, open Tue to Sun 8:00 to 20:00.
Reply in 1 to 3 short sentences, in the customer's language, as plain text.
Never invent prices or stock. If unsure, say a person will reply here soon.
Recent chat, oldest first:
{{ $json.history.map(h => (h.direction === 'in' ? 'Customer: ' : 'Business: ') + h.text).join('\n') }}
Chat Model: your OpenAI, Anthropic or OpenRouter model
Tools (optional): an HTTP Request tool that looks up orders
Respond to Webhook node
Respond With: JSON
Response Body: { "reply": {{ $json.output.toJsonString() }} }workflow එක මන්දගාමී, අසාර්ථක හෝ හිස් ප්රතිඵලයක් ලබා දුන්නොත් කුමක් වේද?
සෑම ප්රතිඵලයක්ම automation එකේ Runs tab එකේ step එකේ output හෝ දෝෂය සමඟ සටහන් වේ, එබැවින් මේ සිදුවීම්වලින් කුමක් සිදුවීද යන්න ඔබට බැලිය හැක:
- තත්පර 20ක් ඇතුළත පිළිතුරක් නැත: step එක Webhook did not answer සමඟ අසාර්ථක වේ, කිසිවක් යවනු නොලැබේ, ධාවනය Failed ලෙස පෙන්වයි.
- 2xx නොවන status එකක්, redirects ඇතුළුව: step එක Webhook answered HTTP සහ කේතය සමඟ අසාර්ථක වේ.
- reply string එකක් නොමැති 2xx: ධාවනය Done වන අතර, step එක HTTP 200, no reply පෙන්වයි, ගනුදෙනුකරුට ස්වයංක්රීය කිසිවක් නොලැබේ.
- අසාර්ථක ධාවනයක් ඔබට ඊමේල් කරයි, එවිට ඔබට එම ගනුදෙනුකරුට ඔබම පිළිතුරු දිය හැක, එක් automation එකකට පැය 6කට වරක් වැඩිම එක වරක්.
- දුරකථනයෙන් විරාම කාලය (පෙරනිමියෙන් පැය 4, Advanced යටතේ සකසන්න) ඇතුළත ඔබ පිළිතුරු දුන් chat එකක් n8n කැඳවීමට පෙර
human_activeලෙස මඟ හැරේ. - ඉක්මන් පණිවිඩ කිහිපයක් ධාවන කිහිපයක් ආරම්භ කරයි. Call my webhook ට පෙර 1-minute Wait එකක් එක් වරක් පමණක් පිළිතුරු දෙයි, මන්ද එම automation එක තෝරන අලුත් පණිවිඩයක් රැඳී සිටින ධාවනය අභිබවා යයි.
Meta හි webhook කෙලින්ම n8n වෙත ලබා ගත යුත්තේ කවදාද?
agent එකට තත්පර 20ට වඩා අවශ්ය වූ විට, workflow එක සෑම event එකක්ම (statuses, ඔබේ දුරකථන පිළිතුරු, media ids) දැකිය යුතු විට, කිසිදු පියවරක් ආවරණය නොකරන දෙයක්, උදාහරණයක් ලෙස Flow එකක් හෝ catalog පණිවිඩයක්, යවන විට, හෝ ව්යාපාරය මාස 6ක history import එක ඉල්ලන විට, ඒ මඟින් සම්බන්ධ කිරීමෙන් පැය 24ක් ඇතුළත සුරැකි සෘජු destination එකට පමණක් යයි. Direct mode එකෙන් අංකය සඳහා automations නතර කරයි: Meta එහි payload එක කෙලින්ම n8n වෙත යවන අතර easyCoexistence කිසිවිට පණිවිඩ නොදකී.
n8n හි, සාමාන්ය Webhook node එක භාවිතා කරන්න, WhatsApp Trigger node එක නොව, එය ඔබේම Meta app සහ එහි secret අපේක්ෂා කරයි. Allow Multiple HTTP Methods සක්රිය කරන්න, එවිට එක දිගු අහඹු path එකක් Meta හි GET handshake සහ POST ඉල්ලීම් දෙකම ගනී, GET ට raw hub.challenge එක text ලෙස පිළිතුරු දෙන්න, සහ එම Production URL එක verify token එකක් සමඟ set_webhook_destination හරහා සුරකින්න. ඉන් පසු පිළිතුරු යන්නේ send endpoint එකට HTTP Request node එකකිනි, සහ dedupe එක, දුරකථන විරාමය සහ පැය 24 පරීක්ෂාව ඔබේ වගකීම බවට පත් වේ.
| Call my webhook (Automations on) | Direct webhook (automations off) | |
|---|---|---|
| Who calls n8n | easyCoexistence, when the automation matches | Meta, for every event on the number |
| Time to answer | 20 seconds, reply in the response | No limit: send later through the Graph API |
| Authentication | X-EC-Signature with the automation's secret | A long random secret in the URL path |
| Guards | Dedupe, phone pause and 24-hour check built in | Yours to write |
| What n8n can send | Text in the reply; the other steps of the automation can send buttons, files and templates | Any Cloud API message type, templates included |
| History import | Not available | If saved within 24 hours of connecting |
| Kept by easyCoexistence | Message text for your retention period (90 days by default), run logs 30 days | Nothing |
එය සකසන ආකාරය
- Turn on automations for the numberOn the number's page, the Automations and incoming messages card shows Automations on or Direct to your server. Click Turn on automations if needed; numbers connected without a webhook URL start with automations on.
- Build and publish the workflowWebhook node (POST, Respond: Using 'Respond to Webhook' Node), Code node, AI Agent node, Respond to Webhook node. Publish or activate it and copy the Production URL.
- Create the automation, switched OffIn Automations, click New automation and pick Send to my system under Start from an example. Paste the Production URL into Webhook URL, set the switch to Off so it does not answer customers yet, and click Save.
- Copy the Signing secret into n8nSelect the Call my webhook step of the saved automation, copy Signing secret and paste it into the Code node.
- Test, then switch it OnClick Test, type a sample message in Try it and press Run test: n8n runs with dry_run true and the result shows the reply. When it reads right, switch the automation On and save.
සාමාන්ය වැරදි
- webhook node එකේ Respond option එක Immediately ලෙස තැබීම. n8n වහාම Workflow got started පිළිතුරු දෙයි, ධාවනය HTTP 200 ලොග් කරයි, පිළිතුරක් නැත, ගනුදෙනුකරුට කිසිවක් නොලැබේ. Using 'Respond to Webhook' Node තෝරන්න.
- /webhook-test/ ඇති Test URL එක ඇලවීම. එය ක්රියා කරන්නේ editor එක test event එකක් බලාපොරොත්තුවෙන් සිටින විටය පමණි; automations වලට අවශ්ය වන්නේ ප්රකාශිත workflow එකේ Production URL එකයි.
- අංකයේ forward secret සමඟ සත්යාපනය කිරීම. Call my webhook අත්සන් කර ඇත්තේ automation එකේම Signing secret එකෙනි; forward secret එක අත්සන් කරන්නේ forward කළ events පමණි, එබැවින් සැබෑ steps පරීක්ෂාව අසමත් වේ.
- පිළිතුර වෙනත් ආකාරයකින් ලබා දීම. top-level string එකක් reply ලෙස named JSON body එකක් පමණක් යවනු ලැබේ; {"output": "..."} හෝ text/plain body එකක් no reply ලෙස ලොග් වේ.
එහි Call my webhook step එක ගනුදෙනුකරුගේ පණිවිඩය n8n වෙත යවා පිළිතුර ආපසු ලබා දෙයි, dedupe එක, ඔබ දුරකථනයෙන් පිළිතුරු දෙන විට විරාමය සහ පැය 24 පරීක්ෂාව ඇතුළත්ව, ධාවනයකට අමතර ගාස්තුවක් නොමැතිව. අංකයකට මාසිකව US$ 9 සිට US$ 0.75 දක්වා, අංක එකතු කරන තරමට පහළ යයි, පළමු දින 3ක් නොමිලේ.
නිතර අසන ප්රශ්න
ChatGPT හෝ Claude මට මෙම automation එක සාදා දිය හැකිද?
ඔව්. easyCoexistence connector එක එකතු කර, ඔබේ අංකයේ පැමිණෙන පණිවිඩ ඔබේ n8n URL එකට යවන automation එකක් ඉල්ලන්න; AI විසින් call_webhook step සහිත create_automation ඇමතුමක් කර, පසුව test_automation ඇමතුමක් කරයි. test එක සමත් වන තෙක් automation එක disabled ලෙස සාදන්න කියන්න. Signing secret එක MCP හරහා ආපසු නොලැබෙන නිසා, එය automation පිටුවෙන් පිටපත් කරන්න.
workflow එකට රූප, buttons හෝ templates යැවිය හැකිද?
reply field එක හරහා නොවේ, එය පෙළ පමණක් රැගෙන යයි. ඒ වෙනුවට automation එකට එය කරන්න දෙන්න: Send a picture or file, Ask a question with buttons සහ Send a template වැනි පියවර Call my webhook ට පෙර හෝ පසු තැබිය හැක. වෙනත් පණිවිඩ වර්ග සඳහා, HTTP Request node එකකින් Cloud API වෙත යවන්න, get_api_credentials ආපසු දෙන send endpoint එක සහ token එක සමඟ, සහ ගනුදෙනුකරු දෙවරක් පිළිතුරු නොලබන පිණිස reply එකක් ආපසු නොදෙන්න.
එක් workflow එකකින් අංක කිහිපයකට පිළිතුරු දිය හැකිද?
ඔව්. අංකයකට එක automation එක බැගින්, එකම Production URL එකට යොමු කර channel.phone_number_id හෝ automation.id මත ශාඛා කරන්න. සෑම automation එකකටම තමන්ගේම Signing secret ඇත, එබැවින් අත්සන පරීක්ෂා කිරීමට පෙර automation.id අනුව secret එක තෝරන්න.
self-hosted n8n ක්රියා කරයිද?
ඔව්, එහි Production URL එක පොදු HTTPS නම්. easyCoexistence URL එක සුරකින විටත්, සෑම ඇමතුමට පෙරත් http, localhost, පුද්ගලික සහ අභ්යන්තර ලිපිනයන් ප්රතික්ෂේප කරයි, සහ redirects අනුගමනය නොකරයි.
තවදුරටත් කියවන්න
ආරම්භ කිරීමට සූදානම්ද?
WhatsApp Coexistence මිනිත්තු කිහිපයකින් සකසන්න, මාස ගණනකින් නොව. යෙදුම දුරකථනයේ දිගටම ක්රියා කරයි.
නොමිලේ trial කාලය ආරම්භ කරන්නසත්යාපනය කළේ