Identify signed-in users
If visitors are signed in to your product, momo can attach each chat to the right contact, show your team who it is, and keep the person's history across devices.
How trust works
A browser can claim to be anyone, so momo only trusts an identity that is signed on your server. You compute an HMAC-SHA256 of the user id with a secret that only you and momo know.
- Without a valid signature the chat stays anonymous. Nothing is linked or stored.
- With a valid signature the contact is created or updated and the person sees their earlier chats on any device.
1. Create the secret
In your agent, open Channels > Website widget > Identity and create the secret. It is shown once; store it in your server's secrets, never in browser code. Keep Require verified identity on unless you have a reason to turn it off.
2. Sign the user id on your server
import { createHmac } from "node:crypto";
const userHash = createHmac("sha256", process.env.MOMO_IDENTITY_SECRET)
.update(String(user.id))
.digest("hex");
The result is lowercase hex.
3. Identify in the browser
<script>window.Momo = window.Momo || { q: [] };</script>
<script src="https://app.askmomo.eu/widget.js" data-key="PUBLIC_KEY" data-bot="AGENT_ID" async></script>
<script>
Momo.q ? Momo.q.push(["identify", {
userId: "42",
email: "ada@example.com",
name: "Ada Lovelace",
userHash: "HEX_FROM_YOUR_SERVER",
attributes: { plan: "Pro", appsCount: 3 }
}]) : Momo.identify({ /* same object */ });
</script>
| Call | What it does |
|---|---|
Momo.identify(user) | Sets the identity. userId is required. The same userId updates, a different one replaces. |
Momo.update(attributes) | Merges more attributes. |
Momo.reset() | Call on logout. Clears the identity, the open chat and remembered chats. |
For static pages you can use the attributes data-user-id, data-user-email, data-user-name and data-user-hash on the script tag instead.
Limits
An attribute name can be up to 40 characters, a value up to 500, with at most 30 attributes. Values are text, numbers or true/false.
From your server instead
You can also create or update the contact without a browser: Contacts API.