Signed-in customers
Signed-in customers can ask about their own orders and use tools marked “signed-in only”. Guests get product and policy answers, plus a “Sign in” bar. Your developer connects three things.

1. A token endpoint on your server
Section titled “1. A token endpoint on your server”When a customer is logged in, your server signs a short-lived visitor token with your visitor secret. The secret never leaves your server.
Token format
Section titled “Token format”An HS256 JWT with these claims:
| Claim | Value |
|---|---|
tid |
Your account id (shown in Settings) |
vid |
A stable id for this customer, e.g. customer-42. Their chat history follows it across devices. |
ext |
Your customer id. This makes the visitor signed in, and it is what your account API receives. |
ctx |
Optional JSON (≤ 8 KB) the assistant may use, e.g. { "name": "Ada", "plan": "pro" }. name is shown as “Signed in as Ada”. |
lang |
Optional language, e.g. tr |
ch |
Optional channel, default web |
iat, exp |
Issued and expiry time; at most 24 hours apart |
// Node.js, with the `jose` library (any JWT library works)import { SignJWT } from 'jose';
export async function chatToken(customer: { id: string; firstName: string }, locale: string) { return new SignJWT({ ctx: { name: customer.firstName }, ext: customer.id, lang: locale, tid: process.env.CHAT_ACCOUNT_ID, vid: `customer-${customer.id}`, }) .setProtectedHeader({ alg: 'HS256', typ: 'JWT' }) .setIssuedAt() .setExpirationTime('1h') .sign(new TextEncoder().encode(process.env.CHAT_VISITOR_SECRET));}// PHP, with firebase/php-jwtuse Firebase\JWT\JWT;$token = JWT::encode([ 'tid' => getenv('CHAT_ACCOUNT_ID'), 'vid' => 'customer-' . $customer->id, 'ext' => (string) $customer->id, 'ctx' => ['name' => $customer->firstname], 'lang' => 'en', 'iat' => time(), 'exp' => time() + 3600,], getenv('CHAT_VISITOR_SECRET'), 'HS256');Expose it on your own site, for example POST /chat-token: return { "token": "…" } for logged-in customers and 204 for guests.

2. Keep the chat in step with your login
Section titled “2. Keep the chat in step with your login”async function signInChat() { const res = await fetch('/chat-token', { method: 'POST', credentials: 'same-origin' }); if (res.status !== 200) return; // guest const { token } = await res.json(); window.Helpvane?.setToken(token);}
signInChat(); // on page load, after loginsetInterval(signInChat, 50 * 60 * 1000); // refresh before the token expires// after logout:window.Helpvane?.setToken(null);setToken(token) switches the chat to the customer and loads their latest conversation. setToken(null) returns to a fresh guest chat. The chat script may load after your code: wait for window.Helpvane, or render the embed with data-token when the page is generated for a logged-in customer.
3. The account API
Section titled “3. The account API”Build the account API: one endpoint that lists a customer’s orders and returns one order, always scoped to the customer id from the token.
4. Turn it on
Section titled “4. Turn it on”In Settings → Signed-in visitors:
- Sign-in URL: your login page.
{returnPath}becomes the current page’s path and query (for logins that accept a relative redirect),{returnUrl}the full URL. A relative URL such as/account/login?redirect={returnPath}works on every website you allowed. - Account API URL and timeout.
- Show the sign-in bar to guests.
If every visitor is identified by your site or app (a back office, a members-only area), also turn Settings → Guest sessions off. The widget then refuses to start an anonymous chat (403 on the session request, on every channel) and works only with the tokens your server mints.
Also set a signing secret in Settings → Escalation webhook: it signs the order look-ups, even if you do not use escalation.
Visitor context
Section titled “Visitor context”Guests can send context too (window.Helpvane.setContext({ page: 'cart' })), but it is unsigned. For signed-in customers, the signed ctx always wins over anything the page sends, so use the token for facts that matter (plan, tier) and for rules.
Checklist
Section titled “Checklist”- Logged out: the sign-in bar shows; your token endpoint returns 204.
- Logged in: “Signed in as …” and My orders appear; “where is my order?” shows order cards.
- Another customer’s order number returns “not found”.
- Logging out returns the chat to a guest.