Skip to main content
User identification lets you securely pass user information to the chat widget. This enables personalized conversations, linking chats to your user records, and showing user context to your support team.

How it works

  1. Your frontend requests a token from your backend
  2. Your backend generates a short-lived JWT signed with your chatbot’s secret
  3. Your frontend passes the token to the widget
  4. Replyful verifies the token and links the conversation to the user

Get your chatbot secret

Each chatbot has its own signing secrets.
  1. Go to your Replyful dashboard
  2. Navigate to Settings → Developers → Secrets
  3. Create a secret for your chatbot and copy it
A chatbot can have several active secrets at once, so you can rotate: create the new one, switch your backend to it, then archive the old one.
Keep the secret on your server. Never expose it in client-side code.
Breaking change: tokens must include an exp (expiry) claim. Replyful rejects tokens without one, and the widget fires identity-failed. A token without an expiry never stops working, so anyone who copies one could sign in as that user for good.

Generate a token on your backend

Create an API endpoint that generates a signed JWT for authenticated users.
Install the jsonwebtoken package:
Create a token endpoint:

Call identify from your frontend

After a user logs in, fetch the token from your backend and pass it to the widget:
You can call identify before the widget has loaded; it’s applied once the chat is ready. Once loaded, identify returns a Promise that resolves to the result instead of throwing: To act on the result, wait for the chat to be ready:
The same outcomes also fire as the identity-verified and identity-failed events. See the JavaScript API.

React example

Require identification

By default, visitors can chat before they are identified. If your chatbot should only serve signed-in users, for example inside your product, you can make identification mandatory:
  1. In your Replyful dashboard, open Channels → Chat and pick your chatbot.
  2. Open the Embed tab and turn on Require identification.
The message box then stays locked until identify succeeds, and Replyful refuses messages to the AI agent from visitors who haven’t been identified. This applies everywhere the chatbot is installed, so only turn it on when every page that shows it calls identify. Use a separate chatbot for pages with anonymous visitors.

Token payload

Replyful treats a signed email as proven. It can link the visitor to an existing contact with that address, and the AI agent can use it to look up their data through your API tools. Leave it out if your sign-up flow doesn’t confirm the address. Without a signed email, Replyful has no address to send replies to when the visitor asks for a human, and a signed-in visitor can’t type one in. A typed address is unproven, and attaching it to a verified user would let anyone claim someone else’s inbox. If you want email follow-ups for signed-in users, include their verified email in the token. Other claims are ignored and not stored.

Security best practices

  1. Never expose your chatbot secret in client-side code
  2. Generate tokens server-side only to prevent tampering
  3. Always set an expiration, and keep it short (1 hour recommended)
  4. Only sign email addresses you have verified
  5. Authenticate users before generating tokens
  6. Use HTTPS for all API requests
The widget handles missing or invalid tokens gracefully — users can still chat anonymously.