A CRM integration usually starts with one assumption: the phone number is the contact's ID. WhatsApp usernames break that assumption, because a webhook can now arrive with no number in it. This post shows which fields to read, how to match a person, what to do when their ID changes, and gives tested Node.js code for it. It is based on the WABB team's guide to WhatsApp CRM integration.

The short version

  • Every incoming message webhook can carry a business-scoped user ID (BSUID) in contacts[].user_id.
  • Usernames are rolling out gradually in 2026. For a username user the phone number may be left out.
  • Store both. Match on BSUID first, then on phone. Never match on a name.
  • A BSUID can change. The system webhook gives you previous_user_id.
  • Check the webhook signature and expect duplicate deliveries.
  • The number can be asked for with a request contact information button.
  • Outside the 24-hour window your CRM can only trigger approved templates.

Decide the direction first

An integration has two jobs, and each has its own failure:

  1. WhatsApp to CRM. A new chat creates or updates a record. The failure here is duplicates.
  2. CRM to WhatsApp. A stage change or a due date sends a message. The failure here is sending something WhatsApp will not accept, or sending to someone who never agreed.

Build the first one before the second. You cannot send well from records you cannot trust. The guide compares the routes: a built-in connector, an automation service, webhooks, a spreadsheet or your own code.

Source: WABB guide to WhatsApp CRM integration, checked 4 December 2026.

What arrives in the webhook

This is a text message, shortened from Meta's reference:

{ "contacts": [{ "profile": { "name": "Sheena Nelson" }, "wa_id": "16505551234", "user_id": "US.13491208655302741918" }], "messages": [{ "from": "16505551234", "from_user_id": "US.13491208655302741918", "timestamp": "1749416383", "type": "text", "text": { "body": "Does it come in another color?" } }] } 

Where each field goes:

  • contacts[].wa_id → Phone. May be absent for username users.
  • contacts[].user_id → BSUID. Add a field for it if the CRM has none.
  • contacts[].profile.name → Display name. A label, not an identifier.
  • contacts[].profile.username → Username. Only if the person set one, and they can change it.
  • messages[].text.body → Last message or note. Other message types have other objects.
  • messages[].timestamp → Last contact time, in Unix seconds.
  • statuses[].status → Delivery state. Sent, delivered and read arrive as separate webhooks.

Two more fields belong in the record although WhatsApp does not send them: the owner or stage, and consent (what the person agreed to, where and when).

Source: Meta for Developers, messages webhook reference; WABB guide, checked 4 December 2026.

Three cases your code will meet

Three webhook cases: no username gives BSUID and phone; username with the phone hidden gives username and BSUID; username with the phone visible gives all three.

Figure 1. What can identify the sender in each case.

The phone number is still included for a username user if any of these is true: you messaged or called that number in the last 30 days, you received a message or call from it in the last 30 days, or the person is in your contact book. Meta counts the 30 days per business phone number, so a second number of yours may not get the phone.

About the BSUID itself:

  • a two-letter country code, a period, then up to 128 alphanumeric characters
  • unique to your business portfolio and that user, so another portfolio cannot message it
  • regenerated if the user changes their phone number, which triggers a system message webhook

Treat it as an opaque string. Do not cut the country code off, and do not use a column sized for a phone number.

Source: Meta for Developers, business-scoped user IDs; WABB guide, checked 4 December 2026.

A matching order

Matching order: look up by BSUID, then by phone, otherwise create a new record; never match by name.

Figure 2. Our suggested lookup order. The code below adds the conflict cases.

The order is simple. The trouble is in the conflicts, and these are our design choices, not Meta rules:

  • BSUID matches one record and the phone another. Update the BSUID record and flag the pair for a person to merge.
  • Phone matches a record that holds a different BSUID. The number may now belong to someone else. Create a new record and flag it.
  • Phone matches a record with no BSUID. That is your old contact. Add the BSUID to it.
  • Empty values never match and never overwrite.

Normalise phone numbers to one format before you compare them, including the ones already in the CRM. The code below keeps digits only and assumes full numbers with the country code.

Source: WABB guide to WhatsApp CRM integration, checked 4 December 2026.

When the ID changes

A BSUID is regenerated when the user changes their phone number. Meta sends a system message through the messages webhook:

  • system.type: "user_changed_number" when the new number can be shared with you
  • system.type: "user_changed_user_id" when only the BSUID can

Both carry the new system.user_id and system.previous_user_id. The number change case says the previous value is omitted if it is not available. Use it to update the existing record, or the next message creates a second contact.

Source: Meta for Developers, business-scoped user IDs, system messages webhooks, checked 4 December 2026; background in the WABB guide.

Before you parse: signature and retries

  • Every POST has an X-Hub-Signature-256 header: an HMAC-SHA256 of the payload, keyed with your app secret. Compute it over the raw bytes and reject a mismatch.
  • Anything other than HTTP 200 is retried for up to 7 days, and retries can produce duplicates. Deduplicate on the message ID.
  • Updates can arrive in batches, so loop over entry, changes and messages.

Source: Meta for Developers, create a webhook endpoint and webhooks overview, checked 4 December 2026; WABB webhooks page.

The code

db is your own storage with findByBsuid, findByPhone, insert, update, flag, seen and markSeen.

const crypto = require("node:crypto"); // rawBody: the bytes exactly as received, before JSON parsing function validSignature(rawBody, header, appSecret) { const expected = Buffer.from( "sha256=" + crypto.createHmac("sha256", appSecret).update(rawBody).digest("hex") ); const received = Buffer.from(header || ""); return received.length === expected.length && crypto.timingSafeEqual(received, expected); } // one format for every phone you store or search: digits only const digits = (v) => (v ? String(v).replace(/\D/g, "") || null : null); function upsert(db, { bsuid, phone, name, username }) { const byId = bsuid ? db.findByBsuid(bsuid) : null; const byPhone = phone ? db.findByPhone(phone) : null; const known = { bsuid, phone, name, username }; // never overwrite a stored value with an empty one const patch = Object.fromEntries(Object.entries(known).filter(([, v]) => v)); if (byId) { // the same phone sits on another record: let a person decide if (byPhone && byPhone.id !== byId.id) db.flag(byId.id, byPhone.id); return db.update(byId.id, patch); } if (byPhone && (!byPhone.bsuid || !bsuid)) return db.update(byPhone.id, patch); const created = db.insert(patch); // same phone, different BSUID: possibly a reassigned number if (byPhone) db.flag(created.id, byPhone.id); return created; } function applyIdentityChange(db, system) { const old = system.previous_user_id && db.findByBsuid(system.previous_user_id); if (!old) return upsert(db, { bsuid: system.user_id, phone: digits(system.wa_id) }); // the old number may no longer be theirs, so replace it even with null return db.update(old.id, { bsuid: system.user_id, phone: digits(system.wa_id) }); } function handleWebhook(db, body) { for (const entry of body.entry || []) { for (const { value } of entry.changes || []) { for (const msg of value.messages || []) { if (db.seen(msg.id)) continue; // Meta retries, so expect duplicates if (msg.type === "system" && msg.system?.user_id) { applyIdentityChange(db, msg.system); } else if (msg.type !== "system") { const contacts = value.contacts || []; const c = contacts.find((x) => x.user_id === msg.from_user_id) || contacts[0] || {}; upsert(db, { bsuid: c.user_id || msg.from_user_id || null, phone: digits(c.wa_id || msg.from), name: c.profile?.name, username: c.profile?.username, }); } db.markSeen(msg.id); } } } } 

We ran it with Node 22 against an in-memory db and eight cases: signature, two people without phones, duplicate delivery, an old phone-only contact, a reassigned number, two conflicting records, a number change and a BSUID change without a phone. Not tested: live Meta traffic or an outside CRM. In production, add a unique index on the BSUID and on the message ID, because two requests can arrive at the same moment. It does not handle delivery statuses or parent BSUIDs.

This code is our example, published by WABB. Review it before you use it.

Test whatever tool you use

If you use a connector instead of code, send it these before you trust it:

  1. Two messages with different BSUIDs and no phone. You should get two contacts, not one.
  2. The same payload twice. You should get one record and one note.
  3. A new BSUID with a previous_user_id. The old contact should be updated.

If a tool builds the contact key from an empty phone field, the first test shows it. More on routes in the WABB CRM guide.

Asking for the number

Meta offers a REQUEST_CONTACT_INFO button. It can be added to utility and marketing templates or sent as an interactive message. If the person taps it, their number is shared in the chat and a contacts webhook delivers it. If you keep a contact book, the number is added there too.

Ask when you have a reason the person can see, for example "so our delivery partner can call you".

Authentication templates with one-tap, zero-tap or copy code cannot be sent to a BSUID. They need the phone number, so a login flow has to collect it.

Source: Meta for Developers, business-scoped user IDs, checked 4 December 2026; WABB guide.

Sending from the CRM

When a stage change should send a message, check two things before the call:

  1. Is the 24-hour window open? It opens and resets with each message from the customer. Inside it you can send ordinary messages. Outside it, only an approved template. See how template approval works.
  2. Did the person agree to this kind of message? WhatsApp requires opt-in before a business messages someone.

Marketing templates are charged per delivered message, so a loop that fires twice costs twice. Read what the API really costs before you automate a large segment.

Source: Meta, send messages; WhatsApp Business Messaging Policy; WABB guide, checked 4 December 2026.

If you do not want to build it

On WABB, ready integrations are on the Pro plan, ₹4,900 a month in India before Meta's message fees, under Settings → Integrations. Incoming webhooks are under Automation → Webhooks, and a flow can call your CRM through the Integration block with Add External HTTP Request. Run the three tests above against us too. Plans are on the pricing page.

Not sure which route fits? Send us the name of your CRM on WhatsApp and what should happen when a chat arrives, and we will tell you what can be connected and how.

Source: WABB guide to WhatsApp CRM integration and pricing page, checked 4 December 2026.

FAQ

Is the BSUID the same for every business? No. It is tied to one business portfolio and one user.

What if my CRM cannot store a BSUID? Add a custom text field. Do not put it in the phone field.

Can the phone number come back later? Yes, in the cases above, for example after you exchange messages or the person shares it.

Can I use the display name to merge records? No. Names repeat and can be changed.

Checklist

  • The CRM has a BSUID field that holds a long string
  • Lookup order is BSUID, then phone, and empty values never match
  • An empty value never overwrites a known one
  • Two phone-less test requests produce two records
  • previous_user_id updates the old record
  • The webhook signature is checked and message IDs are deduplicated
  • Consent is stored with the contact
  • Sends check the 24-hour window first

More from the same team

We build WABB, a platform on the WhatsApp Business API.