Send WhatsApp conversations to your CRM automatically
To send WhatsApp conversations to a CRM automatically, have incoming messages delivered as signed webhooks to your backend or a workflow tool, find or create the contact by phone number, and log the message as an activity on that contact. Use the WhatsApp message id as the activity's unique key, so a retried delivery updates the same record instead of creating a second one.
easyCoexistence connects the WhatsApp Business number you keep in the app to Meta's Cloud API through Coexistence.
Header on a forwarded POST carrying the delivery id, identical on each retry of that delivery.
Span of the 7 forward attempts, after about 1, 5, 30, 120, 360 and 1,440 minutes.
A Call my webhook step calls your URL once; a timeout or error fails the run and emails you.
Business-scoped user ID, such as US.13491208655302741918, sent in user_id and from_user_id beside or instead of the phone number.
How long the automation run log keeps the triggering message, the reply and each step.
Which events should reach the CRM?
Three kinds of message make up a conversation on a Coexistence number, and two routes carry them. The Forward URL, set per number, sends what customers write and what your team types in the WhatsApp Business app, as Meta's original events, retried until your CRM answers. Replies sent by automations reach Meta through the API, which reports them only as delivery statuses without text; to log their words, end the automation with a Call my webhook step, whose history includes the reply the run just sent. One endpoint can take both: the X-EC-Event header reads automation.step for the step and Meta's field name for forwards.
How do you match a WhatsApp sender to a CRM contact?
By phone number, normalised. WhatsApp sends digits with the country code and no plus sign, such as 5511987654321, in messages[].from on forwards and in contact.wa_id on the webhook step. CRM records typed by people hold +55 11 98765-4321 or (11) 98765-4321, so keep a dedicated property with the digits-only form and search on it. When nothing matches, create the contact with the WhatsApp profile name and the number.
Store the business-scoped user ID too. A user with a WhatsApp username who has not been in touch with your number for 30 days may arrive with only the BSUID in from_user_id and contacts[].user_id. Forwards carry it; the webhook step carries the phone number.
What should each CRM record hold?
A contact with the identifiers, and one activity per message with direction, text, time and a unique key. The map below shows where each value sits on either route. Message times on forwards are Unix seconds from Meta; the webhook step sends ISO dates. Media arrive as a type and an id on forwards and as placeholders such as [image] with the caption on the webhook step, so log a short label rather than trying to store the file.
| Forwarded event (value is Meta's) | Call my webhook step | |
|---|---|---|
| Contact phone | messages[].from | contact.wa_id |
| Contact name | contacts[].profile.name | contact.name |
| BSUID | contacts[].user_id, messages[].from_user_id | Not sent |
| Activity text | text.body, or the media type | message.text and history[].text |
| Direction | messages = in, smb_message_echoes = out | history[].direction: in, out or echo |
| Time | timestamp, Unix seconds | message.at and history[].at, ISO 8601 |
| Unique key | messages[].id (wamid) | message.id; run_id for history entries |
How do you keep retries from creating duplicates?
Answer fast, then key everything. A forward that does not get a 2xx within 10 seconds is retried with the same X-EC-Delivery id, up to 7 attempts; a CRM call that takes 12 seconds therefore runs twice unless the activity is upserted on the wamid. Reply 200 first and do the CRM work in a queue or background job.
The webhook step is not retried, and Meta's own repeated deliveries are filtered before an automation runs, so it calls you at most once per message. Its history entries carry no message id: key automated replies on run_id plus their position. Tests from Try it arrive with dry_run true and the sample contact 15550000000; skip them so test runs never create CRM records.
How does the receiver look in Node.js?
One Express route takes both event kinds. It reads the raw body, picks the secret by the X-EC-Event header, verifies X-EC-Signature, answers 200 at once and hands the work to a background function. The crm object stands for your CRM's API client: an upsert of the contact on the digits-only phone, and an upsert of the activity on its unique key. The same shape works for an n8n workflow, with a Code node for the signature and your CRM's nodes after it.
import express from "express";
import crypto from "node:crypto";
const FORWARD_SECRET = process.env.EC_FORWARD_SECRET; // the number's, shown once with the Forward URL
const STEP_SECRET = process.env.EC_STEP_SECRET; // the automation's Signing secret
function signed(req, secret) {
const m = /^t=(\d+),v1=([0-9a-f]{64})$/.exec(req.get("X-EC-Signature") || "");
if (!m || Math.abs(Date.now() / 1000 - Number(m[1])) > 300) return false;
const mac = crypto.createHmac("sha256", secret).update(m[1] + "." + req.body).digest();
return crypto.timingSafeEqual(mac, Buffer.from(m[2], "hex"));
}
const app = express();
app.post("/whatsapp/crm", express.text({ type: "application/json" }), (req, res) => {
const kind = req.get("X-EC-Event"); // automation.step, or Meta's field name for a forward
if (!signed(req, kind === "automation.step" ? STEP_SECRET : FORWARD_SECRET)) return res.status(401).end();
res.json({}); // no reply field: nothing is sent to the customer
handle(kind, JSON.parse(req.body)).catch(console.error);
});
async function handle(kind, body) {
if (kind === "messages") {
for (const m of body.value.messages ?? []) { // statuses are skipped
const c = (body.value.contacts ?? []).find((x) => x.wa_id === m.from);
const contact = await crm.upsertContact({ phone: m.from, bsuid: m.from_user_id, name: c?.profile?.name });
await crm.upsertActivity({ key: m.id, contact, direction: "in", text: m.text?.body ?? "[" + m.type + "]", at: new Date(m.timestamp * 1000) });
}
} else if (kind === "smb_message_echoes") {
for (const m of body.value.message_echoes ?? []) {
const contact = await crm.upsertContact({ phone: m.to, bsuid: m.to_user_id });
await crm.upsertActivity({ key: m.id, contact, direction: "out", text: m.text?.body ?? "[" + m.type + "]", at: new Date(m.timestamp * 1000) });
}
} else if (kind === "automation.step" && !body.dry_run) {
const contact = await crm.upsertContact({ phone: body.contact.wa_id, name: body.contact.name });
const sentAfter = body.history.filter((h) => h.direction === "out" && h.at >= body.message.at);
for (const [i, h] of sentAfter.entries()) {
await crm.upsertActivity({ key: body.run_id + ":" + i, contact, direction: "out", text: h.text, at: new Date(h.at) });
}
}
}
app.listen(3000);Can the CRM update the lead from what the AI learned?
Yes, in your workflow. The chat that arrives with a Call my webhook step holds the questions your AI asked and the customer's answers, so a model node in n8n or a call in your backend can extract need, budget, timing or location and write them to the lead's fields, then move its stage. Return no reply, since the customer already has the AI's message. When the workflow decides a lead is worth a call, it can create a task for a salesperson or alert the team. Or let easyCoexistence do the extracting: an agent or an AI saves details step writes need, budget and timing into the contact's fields, and a Call an API step can post them to your CRM with {{contact.budget}} style tokens in its body. The lead qualification page has the interview instructions and the payload for that setup.
How to set it up
- Send the number's messages through easyCoexistenceOn the number's page, the Where incoming messages go card must be set to Through easyCoexistence; choose it if it shows Straight to your system.
- Deploy the receiverPublish the endpoint or n8n workflow on public HTTPS, with the CRM upserts keyed on the phone and the message id.
- Save the Forward URLPaste the receiver's URL into Forward URL (optional), click Save forward URL and store the signing secret shown once.
- Log automated repliesIn each automation that replies, add Call my webhook as the last step with the same URL, save, and copy that automation's Signing secret.
- Check one real conversationWrite to the number from another phone, let the automation answer, reply from the app, and confirm three activities on the contact: in, automated out and phone out.
Common mistakes
- Searching the CRM on the free-text phone field. WhatsApp's digits-only format seldom matches what a person typed, and each miss creates a duplicate contact; search a normalised digits-only property.
- Calling the CRM before answering the forward. A CRM that takes longer than 10 seconds makes easyCoexistence retry, and without an upsert on the wamid the activity is logged twice.
- Logging only the forward and expecting automated replies in it. API sends come back as statuses without text; a Call my webhook step after the reply carries the words.
- Letting tests reach the CRM. Try it really calls your URL with dry_run true and the sample contact 15550000000; drop those events before any upsert.
Its Forward URL passes customer messages and phone replies to your CRM as Meta's original events, signed per number and retried for about 33 hours when the CRM is down, and a Call my webhook step adds the automated replies. Forwarding and automations are included in the plan. US$ 9 down to US$ 0.75 per number per month, falling as you add numbers, with the first 3 days free.
easyCoexistence is a multichannel API and MCP server that connects AI agents such as Claude and ChatGPT to WhatsApp, Instagram, TikTok, Facebook and more. On WhatsApp it uses Coexistence: the business keeps using its number in the WhatsApp Business app while the AI works through Meta's official API.
Frequently asked questions
Which CRMs does this work with?
Any CRM with an API, either through your own backend or through a workflow tool such as n8n, Make or Zapier that has nodes for it. HubSpot has a Communications object with a WhatsApp channel type built for logging these messages; the HubSpot page shows the call.
Can my team reply to customers from the CRM?
Only if the CRM sends through Meta's Cloud API with the number's send endpoint and token from get_api_credentials: free text within 24 hours of the customer's last message, an approved template after that. Those messages also appear in the app's chat thread on the phone.
Can past conversations be loaded into the CRM?
Only through Meta's history import, which sends up to 6 months of one-to-one chats to a direct webhook destination saved within 24 hours of connecting, once per connection. A number set to Through easyCoexistence logs from the moment forwarding starts.
What does easyCoexistence keep along the way?
Forwarded changes are queued for retries and removed after 7 days. On a number that goes through easyCoexistence, message text also stays for Conversations and AI context for the time you pick, 30, 90 or 365 days, and run logs are kept 30 days. The CRM holds the permanent record.
Keep reading
Ready to get started?
Set up WhatsApp Coexistence in minutes, not months. The app keeps working on the phone.
Start Free TrialVerified on