Identified chat
Let customers who are signed in to your app see all their conversations without confirming their email.
By default, a customer confirms their email with a code to see their past conversations. If the customer is signed in to your app, your server can vouch for them instead. The widget then shows their conversations at once, and the inbox shows their name and photo.
How it works
- Your server creates a short-lived token for the signed-in user, signed with your identity secret.
- Your page passes the token to the widget with
SupportWidget.identify({ token }). - SI Desk checks the signature and shows that customer's conversations.
Step 1: Get your identity secret
Go to Settings › Business › Signed-in customers and set an Identity secret of at least 32 characters. Keep it on your server only. Anyone with the secret can open any customer's conversations.
Step 2: Create the token on your server
This Node function creates the token. The Install page has the same code to copy.
const crypto = require("node:crypto");
function sideskIdentityToken(user) {
const now = Math.floor(Date.now() / 1000);
const payload = {
v: 1,
sub: String(user.id), // your user's id
email: user.email,
name: user.name, // optional
picture: user.avatarUrl, // optional, https only
iat: now,
exp: now + 3600, // one hour at most
};
const body = Buffer.from(JSON.stringify(payload)).toString("base64url");
const signature = crypto
.createHmac("sha256", process.env.SIDESK_IDENTITY_SECRET)
.update(body)
.digest("base64url");
return body + "." + signature;
}
Step 3: Pass the token to the widget
Call these on every page load while the user is signed in. mythic is your Mythic pixel. The Install page shows its name for your business.
mythic.identify(user.id, { email: user.email, name: user.name });
SupportWidget.identify({ token });
When the user signs out, call mythic.reset(). This also starts a fresh chat.
The token's fields
| Field | Required | Meaning |
|---|---|---|
v | Yes | Always 1. |
email | Yes | The user's confirmed email. |
sub | Recommended | Your user's stable id. |
name | No | Shown in the inbox. |
picture | No | An https photo URL, shown in the inbox. |
iat, exp | Yes | When the token was made and when it expires, in Unix seconds. At most one hour apart. |
With or without sub
- With
sub: the customer's history follows their account. They see their account's conversations on any device, even after they change their email. - Without
sub: the customer sees every conversation for their email address.
A chat the customer started before signing in stays with them.