1
Store the secret
From the agent’s Channels page, under Recognise signed-in customers.
.env.local
2
Write a server component
It renders the tag, and signs on the server.
app/_components/agent-widget.tsx
The digest is over the id alone. Not the id plus the email, not a JSON
blob — just the id, as a string, exactly as it is rendered into
data-user-id. A mismatch here is the most common reason signing silently
does nothing.3
Mount it in the layout
app/layout.tsx
4
Check it actually worked
Sign in, open the page, and view source. You should see
data-user-id and
data-user-hmac.Then check the important thing: search the page source for your secret.
It must not be there. If it is, you prefixed it with NEXT_PUBLIC_.Finally, open the agent’s Contacts page. Your test user should appear as
a named contact rather than an anonymous visitor.Single-page apps
If you sign in without a page load, callidentify afterwards instead:
app/api/agent-identity/route.ts
What you get from it
- The agent greets them by name and does not ask who they are.
- Their website chat and their WhatsApp messages become one customer with one history.
- Your actions can trust the customer id, so “where is my order” needs no interrogation.