Web messenger
Add a chat launcher to your website or web app with one script tag, and tell it who's signed in.
AAgent44Updated 4 min read
On this page
In one minute#
The web messenger is a chat launcher for websites and web apps. Visitors message your team, get answers from the AI agent and search your help center without leaving the page. You add one script tag; there's nothing to build or bundle.
It runs in a frame served from your workspace's own address (https://<your workspace>.agent44.ai), so your page and the messenger never share cookies or storage. They talk only through postMessage, and each side checks where messages come from.
1. Install#
In Settings › Apps, add a web app and create its public SDK key. Use a web app's key, from the same workspace as the script's address: conversations it opens are marked as coming from the web.
Add the script before
</body>on every page. Settings › Inbox › Web messenger shows it with your workspace's address filled in:
<script src="https://yourworkspace.agent44.ai/messenger.js" data-key="a44_pub_YOUR_WEB_KEY" async></script>The launcher appears in the bottom corner. Its colour comes from your help center's brand colour, and its side, greeting and intro from Settings › Inbox › Web messenger. Changes show within about five minutes, without touching your site.
If your site sends a Content Security Policy, allow your workspace's address as a script source and a frame source.
2. Tell it who's signed in (optional)#
Without this, each browser is an anonymous visitor: the messenger makes a random id and keeps it in your site's localStorage. After sign-in, identify the user so their conversations follow them across devices and your apps:
<script>
window.agent44 = window.agent44 || function () { (window.agent44.q = window.agent44.q || []).push(arguments); };
// After sign-in:
window.agent44("identify", {
userId: "usr_7f3a9c2e41",
userHash: "<HMAC-SHA256 of the id, from your server>", // identity verification
email: "maya@example.com",
name: "Maya",
});
</script>The first line lets you call window.agent44 before the script has loaded; calls are queued and run in order once it has.
Read Identity and security first. userHash is the id's signature, computed on your server with your workspace's identity secret (Settings › Identity verification); the messenger sends it with every request. New workspaces start with Enforce on: until your server signs ids, a signed-in visitor is refused and the messenger carries on with them as an anonymous visitor (it logs the reason in the browser console). While Enforce is off, the userId is trusted as sent, so it must be an id nobody can guess, never an email or a counting number. Never put the secret itself in your page.
3. Control it from your page#
Call | What it does |
|---|---|
| Use this signed-in user. Every field is optional; send at least |
| Forget the user and start a new anonymous visitor, so the next person on this browser doesn't see their conversations. Call it when your user signs out. |
| Open the messenger. |
| Close it. |
| Open it on the Messages tab. |
| Open it on the Help tab. |
Escape closes it. On screens narrower than 480 px it opens full screen. When the team replies and the messenger is closed, the launcher shows the number of unread conversations.
Use your own button#
To open the messenger from a button or menu of your own instead of the round launcher, add data-launcher="hidden" to the script tag and call window.agent44("open") from your button. The messenger still loads in the background, so you can show unread replies yourself:
<script src="https://yourworkspace.agent44.ai/messenger.js" data-key="a44_pub_YOUR_WEB_KEY" data-launcher="hidden" async></script>
<script>
window.addEventListener("agent44:unread", (event) => {
// event.detail.count: conversations with replies the visitor hasn't read
document.querySelector("#help-badge").textContent = event.detail.count || "";
});
</script>Event on |
| When |
|---|---|---|
|
| The number of conversations with unread replies, whenever it's checked: when the page loads, then every 2 minutes while the messenger is closed and every 20 seconds while it's open, paused while the page is hidden (checked again when it shows). |
|
| The messenger opened or closed. |
What visitors see#
The messenger looks the same as the chat in agent44's Flutter SDK, in your help center's brand colour.
Home: your greeting, a "Send us a message" button with how fast the team usually replies (or that your AI agent answers right away), their latest conversation, your help center's featured articles, and any chats, announcements, posts and the latest changelog update you've published in Engagement for web apps.
Messages: their conversations, with attachments (images, PDFs and text files up to 10 MB) and a rating once a conversation is closed, if you ask for ratings.
Help: search across your help center, its featured articles, and AI answers for public help centers. Turn the tab off in Settings › Inbox › Web messenger.
Updates: your changelog, when its public page is on, each entry readable without leaving the messenger.
Try it without a site#
Open https://yourworkspace.agent44.ai/messenger?key=a44_pub_YOUR_WEB_KEY in a browser. The page runs the messenger on its own, which is handy for checking your settings. It only runs with a key from its own workspace.
Troubleshooting#
What you see | Why |
|---|---|
No launcher, and the console says to add | The script tag has no |
"This key belongs to another workspace, so the messenger can't open here." | The key is from a different workspace than the address in |
"This messenger's key isn't valid. It may have been revoked." | The key was revoked or mistyped. Create a new one in Settings › Apps. |
The script returns "No messenger here." | The workspace address in |