How it works
- Your frontend requests a token from your backend
- Your backend generates a short-lived JWT signed with your chatbot’s secret
- Your frontend passes the token to the widget
- Replyful verifies the token and links the conversation to the user
Get your chatbot secret
Each chatbot has its own signing secrets.- Go to your Replyful dashboard
- Navigate to Settings → Developers → Secrets
- Create a secret for your chatbot and copy it
Generate a token on your backend
Create an API endpoint that generates a signed JWT for authenticated users.- Node.js
- PHP
Install the Create a token endpoint:
jsonwebtoken package:Call identify from your frontend
After a user logs in, fetch the token from your backend and pass it to the widget: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:
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:- In your Replyful dashboard, open Channels → Chat and pick your chatbot.
- Open the Embed tab and turn on Require identification.
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
- Never expose your chatbot secret in client-side code
- Generate tokens server-side only to prevent tampering
- Always set an expiration, and keep it short (1 hour recommended)
- Only sign email addresses you have verified
- Authenticate users before generating tokens
- Use HTTPS for all API requests