Messenger
A messenger for your site with three spaces: Home (your team, a way to write, your latest news and your links), Messages (every conversation a person has had with you) and News (your Pagebee changelog). Your team's faces show who's online, and prompts like "Any questions about plans?" open on the pages you choose. Every conversation goes to your Pagebee inbox, the iPhone app and the conversations API. It's set up in code, by your agent or by you, and it stores nothing about a visitor until they write to you.
Install
Push a config for the site (below), then add one tag to every page:
<script defer src="https://api.pagebee.ai/messenger.js" data-site="pb_pk_your_site_key"></script>It is separate from the analytics script and about 4 KB gzipped. The panel (home, messages and news, about 6.5 KB) loads only when someone opens the messenger or already has a conversation. The launcher only appears on the site's own hostnames (the same hostname rules as analytics) and only once a config is pushed.
Configure it in code
Keep the config in your repo, for example pagebee.messenger.json, and push it when it changes. Every push is a new version; pushing the same config again changes nothing, and pushing an older one rolls back.
{
"look": { "accent": "#E06A8E", "position": "bottom-right", "team_name": "Kiln" },
"greeting": "Ask us anything. We usually reply within a few hours.",
"reply_time": "Usually replies within a few hours",
"hours": { "timezone": "Europe/London", "weekdays": "09:00-17:30" },
"ask_for_email": "when-offline",
"hide_on": ["/checkout/*"],
"routing": [{ "when": { "path": "/pricing*" }, "tag": "sales" }],
"spaces": ["home", "messages", "news"],
"home": {
"heading": "Hi there",
"links": [{ "label": "Help centre", "url": "/docs", "description": "Guides for every part of Kiln" }],
"wishlist": true
},
"team": { "members": ["maya@kiln.app", "sam@kiln.app"], "show_faces": true },
"prompts": [
{
"id": "pricing",
"path": "/pricing",
"after_seconds": 20,
"message": "Any questions about plans? I can help you pick.",
"from": "sam@kiln.app",
"only_when_online": true
}
]
}Ask your agent ("add the Pagebee messenger to this site") and it calls apply_messenger_config with a dev key. Or push it yourself:
curl -X PUT https://api.pagebee.ai/api/properties/<site id>/messenger \
-H "Authorization: Bearer pb_ak_your_dev_key" \
-H "Content-Type: application/json" \
-d "{\"config\": $(cat pagebee.messenger.json)}"| Field | Meaning |
|---|---|
enabled | false hides the launcher everywhere without removing the tag |
look.accent | The launcher and header colour, a hex like #E06A8E |
look.position | bottom-right or bottom-left |
look.team_name | The name in the header. Defaults to the site's name |
greeting | The first message people see, up to 280 characters |
reply_time | The line under the name while you're around |
hours | When you're around, per time zone: weekdays and weekends as 09:00-17:30. Outside them the messenger says you're away |
ask_for_email | always before the first message, when-offline (the default) or never |
hide_on | Paths where the launcher is hidden, with * for any run of characters |
routing | Tags a new conversation by the page it started on |
spaces | The tabs, in order: home, messages, news. News shows when the site's changelog is on and has entries |
home.heading | The big line at the top of Home |
home.links | Up to six links: label, url (https, or a path on your site) and an optional description |
home.wishlist | A "Request a feature" card when the site has a wishlist board. On by default |
team.members | Who shows, by their Pagebee emails, in order. Leave out for everyone with "show me in the messenger" on |
team.show_faces | Faces and who's online in the header |
prompts | Up to 20 prompts, below |
The dashboard shows the live config under the site's settings, but doesn't edit it: your repo is the source.
Prompts
A prompt is a short message from your team that opens beside the launcher on the pages you choose. Clicking it opens a new conversation that starts with the prompt, so the person only has to answer.
| Field | Meaning |
|---|---|
id | Your name for it, in lower case with hyphens. Its numbers are kept under this id |
message | Up to 280 characters |
path | The page it shows on, with * for any run of characters, like /pricing or /docs/* |
after_seconds | Seconds on the page before it shows. Default 15 |
scroll_percent | Only once this much of the page has been scrolled, 1 to 100 |
from | The teammate it comes from, by Pagebee email. Leave out for whoever's online, else the team |
only_when_online | Only when someone on the team is online, so "we're here" is true |
enabled | false keeps it in the config but stops it showing |
Prompts trigger on the page someone is reading and nothing else, so nothing is stored to target anyone. A prompt shows at most once per page view. Someone who has already started a conversation and closes a prompt doesn't see it again, because their messenger already keeps their conversations.
Each prompt counts how often it was shown, opened and how many conversations it started, per day, with no people in the numbers. See them under the site's settings, or ask your agent: get_messenger_config returns the last 30 days.
Your team in the messenger
Each person who can answer (owners, admins and members) has a messenger profile: a name (people see the first word), a title, a picture, on-call hours and an away switch. Set your own under Settings, Messenger team, or have your agent set anyone's from code with update_teammate_profile:
{ "email": "sam@kiln.app", "title": "Support", "avatar_url": "https://kiln.app/team/sam.jpg", "hours": { "timezone": "Europe/London", "weekdays": "09:00-17:30" } }Someone shows as online, with a green dot, while they're using Pagebee (the dashboard or the iPhone app) inside their on-call hours, unless they've switched to away. Outside their hours they never show as online, even with Pagebee open. The messenger is only ever given a first name, a title, a picture and whether they're online: never an email or an id. list_teammates shows the whole team as the messenger sees it.
Several conversations
People can start a new conversation from Home or Messages, and see every one they've had with you. Each conversation they start on a device keeps its own token there, and conversations from the same device stay one contact in your inbox. Signed-in people (below) see their conversations on any device.
Signed-in people
To show people their conversations on any device, sign an identity token on your server with the site's identity secret (Settings, Messenger, Show identity secret; or the MCP tool get_messenger_identity_secret) and pass it to the page.
import crypto from "node:crypto";
function identityToken(user: { id: string; email: string; name: string }) {
const b64 = (o: object) => Buffer.from(JSON.stringify(o)).toString("base64url");
const head = b64({ alg: "HS256", typ: "JWT" });
const body = b64({ sub: user.id, email: user.email, name: user.name, exp: Math.floor(Date.now() / 1000) + 86400 });
const sig = crypto.createHmac("sha256", process.env.PAGEBEE_IDENTITY_SECRET!).update(`${head}.${body}`).digest("base64url");
return `${head}.${body}.${sig}`;
}<script>
window.pagebeeMessenger = window.pagebeeMessenger || { q: [] };
pagebeeMessenger.q.push(["identify", "<token from your server>"]);
</script>sub (your user id) and exp are required, and exp can be at most 30 days ahead. email, name and traits (plan, company) are optional and show beside the conversation. A token that doesn't verify is ignored, so nobody can read another person's conversations by claiming their id. Call pagebeeMessenger.logout() when they sign out.
The JavaScript API
| Call | Does |
|---|---|
pagebeeMessenger.open(), .close(), .toggle() | Opens or closes the messenger, for your own "Contact us" button |
pagebeeMessenger.showSpace("news") | Opens it on a space: home, messages or news |
pagebeeMessenger.newConversation() | Opens it ready to write a new message |
pagebeeMessenger.hide(), .show() | Hides the launcher on this page |
pagebeeMessenger.identify(token) | Signs the person in, as above |
pagebeeMessenger.logout() | Forgets the identity and this device's conversations |
pagebeeMessenger.on("message", fn) | Calls fn when the team replies |
Privacy
- Nothing is stored on the visitor's device until they send a message. Then the messenger keeps a random token for each conversation they start, and the ids of prompts they've closed, in local storage, so they can come back to them. That storage is strictly needed for the chat they started, so it needs no consent banner.
- Prompts trigger on the current page only (its path, time on it and scroll depth) and count shown, opened and started per day with nobody in the numbers.
- Reading News records nothing.
- With each first message it sends the page, the referrer and the pages seen in that tab, with query strings removed. With Global Privacy Control or Do Not Track on, it sends the current page only.
- Conversations are never joined to your analytics. Pagebee still counts visitors without cookies and still can't tell you who an anonymous visitor was.
- Messages and emails are personal data that you control. Pagebee processes them for you under the DPA, and you can delete a conversation at any time through the API.