Skip to main content
Twenty minutes, and your logged-in customers stop introducing themselves to your agent every time.
1

Store the secret

From the agent’s Channels page, under Recognise signed-in customers.
.env.local
Note which one has NEXT_PUBLIC_. The public key is meant to reach the browser. The identity secret must never. Prefixing it would publish the one thing that stops any visitor forging any customer’s identity.
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
Because it is a server component it re-renders per request, so signing in and out is picked up without any client-side work.
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, call identify afterwards instead:
app/api/agent-identity/route.ts
This route signs whoever is in the session. Never let it sign an id taken from a query string or a request body — that would hand any visitor a valid signature for any customer, which is precisely what the HMAC exists to prevent.

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.