Skip to Content
GuidesDevelopersResources
Website and widget

Recognize your signed-in customers (verified visitors)

Your server signs a token that says which customer is signed in. Botello verifies it and unlocks the actions reserved for verified visitors.

On requestThe Botello team turns this feature on for your workspace. Contact us to get it.
Plans
All plans
Roles
Owner, Admin
Channels
Website
In the admin
Integrations › Developers › Verified visitors

In the chat, anyone can type “I am jeanne@example.com”. So that a customer signed in on your site can safely look up their orders or their appointments, your server signs a small identity token (a JWT) that says who is signed in. The widget passes it to Botello, which verifies the signature. Actions marked Verified visitors only then use the e-mail or ID guaranteed by your site, never a value typed in the chat.

Best for

A customer area (orders, returns, appointments, loyalty) where the assistant needs to read personal data of the signed-in customer, and only theirs.

Before you start

  • Developer tools are enabled by the Botello team for your workspace. If not, write to support@botello.ch.
  • You are Owner or Admin of the workspace.
  • Your site has a server-side login system that knows which customer is signed in.
  • The widget is installed: see Embed code and options.

How it works

  1. Your server signs an HS256 token with your workspace’s identity secret. The secret never leaves your server.
  2. Your page gives the token to the widget: window.BotelloSettings.identityToken or window.Botello.identify(token).
  3. The widget passes the token to its iframe via postMessage, never in a URL. The token accompanies every visitor message.
  4. Botello verifies the token on every message. If it is valid, the visitor is verified for that message: reserved actions are offered, and the verified_email, verified_phone and verified_customer_id values are filled in. The token is never stored.
  5. If it is invalid, nothing is blocked: the visitor chats normally, but unverified.

Set up

Turn it on and copy the secret

Open Integrations, Developers card, Configure. Under Verified visitors, click Turn on (create the secret). The secret is shown: it starts with botid_. Copy it into your server configuration, for example into the BOTELLO_IDENTITY_SECRET variable.

The Verified visitors section before activation: Off badge, Turn on (create the secret) button, then the steps 1. Sign the token on your server, 2. Give it to the widget and 3. Check a token

The secret stays on your server

Anyone who has this secret can impersonate any of your customers. Never put it in a page’s JavaScript code, in a mobile app or in a Git repository.

Sign the token on your server

When a customer is signed in, generate a token (see Sign the token). Keep the lifetime short: one hour is usually enough, 24 hours at most.

Give it to the widget

Before the Botello tag, or later with identify:

In your page
<!-- Before the Botello script -->
<script>
  window.BotelloSettings = { identityToken: "<?= $identityToken ?>" };
</script>
<script src="https://admin.botello.ch/widget.js" data-project-id="YOUR-CHATBOT-ID"></script>

<!-- Or later, e.g. after a login in a single-page app -->
<script>
  window.Botello.identify(identityToken);   // log in
  window.Botello.identify(null);            // log out
</script>

Check a token

Paste a token produced by your server into 3. Check a token, then click Check. Botello replies “Token accepted” with the identity it read, or the reason for the rejection. The token is not saved.

Reserve your actions for verified visitors

In your API actions, use a value provided by Botello (Customer's verified e-mail, Customer's verified phone or Verified customer id) and tick Verified visitors only. See Parameters and access.

The token

A standard three-part JWT, signed with HS256 (HMAC-SHA256) using the botid_… secret as the key, as is.

Header
{ "alg": "HS256", "typ": "JWT" }
Payload (claims)
{
  "sub": "12345",
  "email": "jeanne@example.com",
  "phone": "+41790000000",
  "name": "Jeanne Exemple",
  "iat": 1791364200,
  "exp": 1791367800
}

Prop

Type

Verification rules, in order:

  1. The token is 4 KB at most and has three base64url-encoded parts.
  2. The header algorithm is exactly HS256. Anything else (none, RS256…) is rejected.
  3. The HMAC-SHA256 signature of <header>.<payload> matches, compared in constant time.
  4. exp and iat are present; exp is in the future; iat (and nbf) are no more than 2 minutes in the future; exp - iat is 24 hours at most.
  5. At least one of sub, email, phone is usable.

Sign the token

No dependencies (node:crypto)
import crypto from 'node:crypto';

const b64url = (obj) => Buffer.from(JSON.stringify(obj)).toString('base64url');

export function botelloIdentityToken(customer) {
  const now = Math.floor(Date.now() / 1000);
  const header = b64url({ alg: 'HS256', typ: 'JWT' });
  const payload = b64url({
    sub: String(customer.id),   // your customer id
    email: customer.email,      // optional
    phone: customer.phone,      // optional, +41…
    name: customer.name,        // optional
    iat: now,
    exp: now + 3600,            // 1 h (24 h at most)
  });
  const signature = crypto
    .createHmac('sha256', process.env.BOTELLO_IDENTITY_SECRET) // "botid_…"
    .update(`${header}.${payload}`)
    .digest('base64url');
  return `${header}.${payload}.${signature}`;
}

With the jsonwebtoken library:

npm i jsonwebtoken
import jwt from 'jsonwebtoken';

const identityToken = jwt.sign(
  { sub: String(customer.id), email: customer.email },
  process.env.BOTELLO_IDENTITY_SECRET,
  { algorithm: 'HS256', expiresIn: '1h' }, // sets iat and exp
);

Check a token

The 3. Check a token tool tells you exactly why a token is rejected:

MessageReasonFix
“Malformed token (3 parts, exp and iat needed).”Not three parts, unreadable JSON, exp or iat missing, or over 4 KBCheck the base64url encoding and that iat and exp are present
“Algorithm refused: only HS256 is accepted.”alg is not HS256Sign with HS256
“Invalid signature: the token was not signed with this secret.”Wrong secret, or the secret has been renewed sinceCopy the current secret
“Token expired.”exp has passedGenerate a new token on every page, or refresh it
“Token dated in the future (server clock?).”iat or nbf more than 2 minutes in the futureSynchronize the server clock
“Lifetime too long: 24 h at most.”exp - iat exceeds 24 hShorten the lifetime
“The token does not say who the customer is (sub, email or phone).”No usable identifierAdd sub, or a valid email or phone
“Turn verified visitors on first.”No secret createdClick Turn on (create the secret)

Renew or turn off

  • Renew creates a new secret. Tokens signed with the old one are rejected immediately: all signed-in customers become unverified until their next token. Put the new secret on your server right away. Do this after a leak.
  • Turn off deletes the secret: no visitor is verified on the site any more, and reserved actions are no longer offered.
  • Show the secret displays the current secret again. Every display, renewal or deactivation is recorded in the audit log.

Security

  • Sign the token server side only, for the customer authenticated by your own session.
  • Keep the lifetime short. A stolen token only works until its exp.
  • Only include what the actions need: ID, e-mail, phone. The token can be read by anyone who sees it (it is signed, not encrypted).
  • The token is never placed in a URL, never stored by Botello, and never stored in the browser by the widget.
  • On WhatsApp, the sender’s number is guaranteed by the channel: verified_phone is filled in without a token.

Troubleshooting

What you seeLikely causeFix
The signed-in customer cannot use the reserved actionsThe token does not reach the widgetCheck that BotelloSettings is defined before the script, or call identify afterwards
The tool says “Token accepted” but the action is not calledThe action uses a verified value that is not in the token (for example verified_phone without phone)Add the data to the token, or use another verified value
Everything worked, then stoppedThe secret was renewedPut the new secret on your server
Works for an hour, then stopsThe token expired during the visitRegenerate it on every page, or call identify again with a fresh token

Frequently asked questions

Learn more

Was this page helpful?
Checked against the product on 14 November 2026 Suggest a fix

On this page