Skip to main content
Written for AI agents. This guide is meant to be read and executed by an AI coding agent acting on behalf of a person who owns a product. Steps marked 🧑 Human action required need the person: account sign-up, credentials, secret handling, production deploys and anything that changes who answers their customers. When you reach one, stop, tell the person exactly what to do and what to hand back to you, and continue only once you have it. Everything else you can do yourself.

What you will build

By the end, a visitor on the product’s website opens a chat launcher, is recognised as their signed-in account, and talks to an AI agent that answers with the product’s own data by calling the product’s MCP server with a token issued for that visitor only. Nothing in the flow uses a shared admin credential.
The platform pieces involved:

Human actions at a glance

Collect these up front so the person is not interrupted ten times: If you can drive a browser as the person (for example they are logged in to the dashboard in a session you control), you may perform the dashboard clicks yourself. Otherwise, hand them the exact clicks from each step.

Step 0: Gather inputs

Ask the person for, or discover from the product’s codebase:
  • Product name and the public site origin(s) where the chat will appear, e.g. https://app.acme.example.
  • MCP server URL of the product (Streamable HTTP, e.g. https://api.acme.example/mcp) and how it authenticates: usually Authorization: Bearer <token>. Confirm the product can mint a token scoped to one user with a limited lifetime. If it cannot yet, that is the first thing to build; see Step 6.
  • How users are identified in the product (the stable user id you will put in the sub claim).
  • Whether the chat should also work for anonymous visitors. Default for a product assistant: no.
Your MCP server must speak the Model Context Protocol over Streamable HTTP: JSON-RPC initialize, tools/list and tools/call on one URL. The platform passes the headers you return verbatim on every request, honours Mcp-Session-Id, and accepts plain JSON or data: SSE responses. Tool input schemas are normalised to what OpenRouter models accept, so standard JSON Schema is fine.

Step 1: Account, team and bot

🧑 Human action required. The person signs up or signs in at app.chatbotplatform.io and selects the team that should own the assistant. Ask them to confirm the team name back to you.
Then create the bot (dashboard, under Bots → Create Bot): give it the product’s name, e.g. “Acme Assistant”. A bot is created with a default Echo integration that replies You said: "…"; the agent you launch in Step 3 replaces it.

Step 2: Create the Web Widget channel

In the bot, open Channels → Add channel → Web Widget and fill in: Click Create Web Widget. The channel page opens; note three things on it for later:
  • the embed snippet (<script src="https://app.chatbotplatform.io/widget/widget.js" data-widget-key="…" async>),
  • the widget key under it,
  • the signing secret in the Signing secret block.
🧑 Human action required. Ask the person to copy the signing secret from the channel page into the product’s secret store as CHATBOT_WIDGET_SECRET. Do not paste it into chat logs or commit it.

Step 3: Launch the AI agent with the built-in test server

At the top of the channel page, Power this chat with an AI agent is open. Set:
  1. System prompt — start from the template (Use template) and add product context. Keep the line that tells the model to call whoami for identity questions; add one about your product’s tools, for example:
  2. Model — any tool-capable model from the OpenRouter list (for example openai/gpt-4o-mini). The preselected default is a free model; prefer a paid, tool-reliable one for production.
  3. OpenRouter API key — the field is shown only while the team has no key.
    🧑 Human action required. An OpenRouter API key is a billing credential and only a team owner or admin can save it. Ask the person to paste it here, or to add it under Agent loops → Settings in the dashboard, and to confirm when done.
  4. Tools for each visitor (MCP servers) — choose Built-in test server (Widget Identity) until my webhook is ready.
  5. Only the agent answers — leave ticked, so the default Echo integration (and any other webhook) is switched off.
🧑 Human action required. Show the person the prompt, the model and the Launch will summary (it lists exactly what changes, including which integrations get switched off). Launch only after they approve.
Click Launch agent. The platform creates an agentic-loop integration named AI agent on the bot (relaunching later updates it rather than duplicating it), disables competing integrations, saves the key, points MCP servers for conversations at the built-in test webhook and mints its secret. The section shows a Live badge.

Step 4: Smoke-test the pipeline

Still on the channel page, Test your web chat lists a readiness checklist (channel enabled, integration, OpenRouter key, MCP servers, identity). All rows should be green.
🧑 Human action required unless you can drive the browser: click Start test chat, which embeds the real widget signed in as the current dashboard user, and send What is my email address?
Expected: the bot calls whoami on the Widget Identity server and answers with the account’s email. Then open See the conversation in admin → MCP servers tab: MCP discovery webhook: OK and Widget Identity · Discovered · 2 tool(s). If the reply is You said: "…" the Echo integration still answers — relaunch with Only the agent answers ticked. If the bot says it cannot know, the conversation was started before discovery was configured — start a new one with the widget’s + button. You now have proof that identity → webhook → MCP → agent → reply works. The rest replaces the built-in test server with the product’s own.

Step 5: Build the MCP discovery webhook in the product

Add an endpoint to the product’s backend, e.g. POST /chatbot/mcp-servers. For every new conversation the platform POSTs a conversation.started event (and conversation.test when someone clicks Send test request). The endpoint must:
  1. Verify the signature. Headers: X-Chatbot-Timestamp (unix seconds) and X-Chatbot-Signature: v1=<hex HMAC-SHA256 of "timestamp.raw_body"> using the channel’s MCP webhook secret (shown on the channel page once a URL is saved). Reject timestamps older than 5 minutes and compare signatures in constant time.
  2. Look up the visitor from user.id, which is exactly the sub you put in the identity token (Step 6). For user.anonymous === true return an empty list.
  3. Mint a token scoped to that user for your MCP server — short-lived, limited to what the assistant may do. Never return a global or admin credential.
  4. Answer 200 with the servers to attach. Up to 20; an empty list is valid. Optionally add a preferences list with what the product already knows about the visitor (timezone, how to address them, plan limits) so the agent starts the conversation informed; see Preferences below. The whole call must finish within 10 seconds (one retry on failure); a failing webhook never blocks the conversation, it just starts without your tools (and without your preferences).

What the platform sends

event is conversation.started for a new conversation, conversation.test for the Send test request button and conversation.refresh when the agent calls refresh-mcp-servers or an admin clicks Re-run discovery. The request never carries preferences; they only travel in your answer. conversation.api_key is the conversation’s own key on the platform. Echo it back as the bearer token for the Widget Identity server to keep whoami available alongside your tools, or drop that entry once your own tools cover the user’s details.

What you answer

Each entry in mcp_servers needs a name (≤ 255 characters, unique; a later duplicate replaces an earlier one) and an http(s) url; headers are optional, and so is an expiry for the credentials (next section).

Expiring credentials (optional)

The tokens you hand out in headers are usually short-lived. Tell the platform when they run out and it refreshes them for you before the agent needs them, instead of letting the first tool call fail with a 401 and relying on the agent to call refresh-mcp-servers. What happens with it:
  • Refresh before the reply. Each time a visitor message or a fired reminder is about to be answered, the platform checks the servers your webhook discovered for that conversation. If one expires within the next 5 minutes, or has already expired, it calls your webhook again with conversation.refresh (the same body as conversation.started) and only then builds the agent’s tool list. Servers are matched by name and updated in place; a running agent loop picks the new credentials up on its next tool call. The whole process adds one webhook round trip to that reply, nothing to the others.
  • Your answer sets the next expiry. Return the new token with a new expires_at / ttl_seconds and the cycle continues. Leave both keys out and that server is never refreshed on its own again.
  • A failed refresh never blocks the reply. If your webhook is down or answers with an invalid body, the platform logs it, keeps the servers it discovered earlier (the agent can still try them, and refresh-mcp-servers remains available) and waits at least one minute before refreshing that conversation again. The MCP servers tab records the failed conversation.refresh like any other discovery outcome.
  • No expiry, no refresh. Servers without the fields behave exactly as before: they stay until the agent, an admin or your own conversation.refresh answer replaces them.
Mint tokens that outlive a conversation turn comfortably (an hour is typical) rather than ones that expire in a minute: the 5-minute window means a token shorter than that is refreshed on every message.

Preferences (optional)

Next to the servers, the same response may carry a preferences list: short, free-form sentences the platform records as the conversation’s preferences before the first reply. Preferences are the per-conversation notes the agent keeps about the person (see Conversation Preferences under Tools the agent always has); they are listed in the agent’s system prompt on every turn, so facts you already hold (timezone, preferred name, plan, limits, language) reach the model without a tool call. The key only exists on the response. The conversation.started request never contains it. How the list is applied:
  • Merge, never overwrite. Each entry whose text is not already recorded for the conversation (compared trimmed and case-insensitively) is added, in the order you returned it. Existing preferences, whether the bot recorded them through the Conversation Preferences tools, an admin edited them, or an earlier discovery pre-filled them, are never changed or removed. A conversation.refresh can therefore top the list up but cannot undo what the conversation has learnt since.
  • Ordinary preferences afterwards. Pre-filled entries behave like any other: the bot can revise or delete them with its tools and admins can edit them on the conversation’s Preferences tab.
  • Ignored when preferences are off. If the bot’s Preferences switch (Behavior settings) is off, the servers are still attached and the list is dropped; the discovery outcome records preferences_skipped: preferences_disabled.
  • Shape errors fail the whole response. A preferences value that is not an array of strings, or an entry over 1000 characters, is a contract violation like a bad mcp_servers entry: the platform logs a failure and the conversation starts without your servers too. Validate what you send.
Write each entry as a complete sentence the model can act on (“User’s timezone for dates and times: America/Chicago”), not a key-value fragment. Keep credentials and anything the visitor should not see out of it: preferences are shown in the admin dashboard and can be read back by the bot.

Skills (optional)

The response may also carry a skills list: processes the platform saves as skills of the person behind the conversation, so the agent can follow your product’s playbooks by name from the first reply. Like preferences, the key only exists on the response.
How they are applied:
  • Create only, never overwrite. A name the person does not have yet is created at version 1 and listed in every conversation they own, on every linked channel. A skill of that name they already have (taught in chat, edited since, or seeded earlier) is left exactly as it is, so send the same list with every response.
  • Deleting sticks. A seeded skill the person deleted is not created again while the deleted copy is kept (30 days).
  • Ordinary skills afterwards. The person can update or delete a seeded skill in chat; admins see it on the person’s page under People.
  • Ignored when skills are off. If the bot’s Skills switch (Behavior → Agent Context) is off, the servers are still attached and the list is dropped; the discovery outcome records skills_skipped: skills_disabled.
  • At the limit. A person can hold 50 skills; entries that would exceed it are skipped and the rest are saved.
  • Shape errors fail the whole response. A skills value that is not an array of {name, summary, content} objects, a name that is not a slug or a field over its limit is a contract violation: the conversation starts without your servers too.
Send test request lists the skills your webhook returned (It also sent N skill(s) to save for the person behind each new conversation) without storing them, and the conversation’s MCP servers tab reads saved N of M skill(s) for this person after a real discovery; N is lower than M when the person already had some.
Personal authorization is the point. The token you return is what the model uses for every tool call in that conversation, so scope it to the one user and to read-mostly operations. If a tool performs a consequential action (refund, cancel, delete), have your MCP server require an explicit confirmation argument or keep it out of the assistant’s scope.

Step 6: Identify visitors and embed the widget

Two product changes so visitors are recognised:

6a. Mint the identity token

Add a backend endpoint (e.g. GET /api/chat-widget-token) that returns a token for the signed-in user. It is an HS256 JWT signed with CHATBOT_WIDGET_SECRET from Step 2:
PHP and Python versions are on the Web Widget channel page.

6b. Add the snippet

On every page where the launcher should appear, before </body>:
For server-rendered pages you can instead render the token into the one-line snippet as data-user-token="…".
🧑 Human action required. Deploying the webhook (Step 5), the token endpoint and the snippet changes the product. Open a pull request with the changes, summarise them, and ask the person to review, deploy to the environment they want to test in, and tell you the public webhook URL once it is reachable over HTTPS.

Step 7: Point the channel at the product’s webhook

Back on the channel page, either relaunch from Power this chat with an AI agent choosing My webhook URL, or expand MCP servers for conversations in the channel form and set Webhook URL to the endpoint from Step 5. Save. The Webhook secret field now shows the secret that signs every request to your endpoint.
🧑 Human action required. Ask the person to copy the MCP webhook secret into the product’s secret store as CHATBOT_MCP_WEBHOOK_SECRET and redeploy or restart so the webhook verifies with it.
Click Send test request. The platform sends a signed conversation.test to your URL and shows the answer: you should see your server name(s) listed (for example 2 MCP server(s) with Acme and Widget Identity) and, when you return preferences, It also sent N preference(s) to pre-fill each new conversation with followed by the entries. A 401 means the secret in the product does not match; a 422-style validation error means the response shape is off — compare it with What you answer above.

Step 8: Verify end to end

🧑 Human action required unless you can drive a browser signed in to the product: on the product site, open the chat, start a new conversation and ask something only the product’s tools can answer, e.g. “What is my current plan and when does it renew?”
Then in the dashboard, open the bot’s Conversations, pick the newest one and check:
  • Widget user matches the signed-in account (sub, name, email, attributes).
  • MCP servers tab: MCP discovery webhook: OK, your server listed as Discovered, status passing with its tool count and, when you returned an expiry, Expires in … (amber once inside the refresh window, red once passed). failing means the platform could not complete initialize/tools/list against your URL with the headers you returned. When the webhook returned preferences the outcome line also reads pre-filled N of M preference(s); N is lower than M only when some texts were already recorded.
  • Preferences tab (shown while the bot’s Preferences switch is on): the entries from your webhook, editable like any the bot recorded itself.
  • The transcript shows the tool call and an answer grounded in it.
Re-run discovery on that tab replays the webhook (conversation.refresh) for an existing conversation; it replaces only the servers the webhook discovered earlier and leaves ones added through chat or the admin UI alone. Preferences in the new answer are merged the same way as on start: new texts are added, nothing already recorded is touched.

Step 9: Go-live checklist

Walk through this with the person before announcing the chat:
  • Allowed origins lists only the production origins.
  • Allow anonymous visitors is off (or deliberately on, with the webhook returning no privileged servers for anonymous: true).
  • Only the agent answers — the Integrations tab shows the AI agent as the only enabled integration.
  • The system prompt names the product’s tools and forbids inventing account data.
  • A paid, tool-reliable model is selected and the OpenRouter key has credit.
  • Secrets live in the secret store; neither appears in the repo, logs or chat history.
  • Tokens from the webhook are per-user, short-lived and read-mostly.
  • Someone knows where Regenerate lives for both secrets (channel page) and that rotating invalidates existing tokens immediately.

Reference

Tools the agent always has

Besides the servers your webhook returns, every agentic loop on the platform can use built-in tools attached to the conversation automatically: Time (date/time helpers), Conversation Context (archives and reminders, when enabled in the bot’s Behavior settings), Async Callbacks, Conversation Preferences (when enabled in Behavior settings; the same per-conversation list your webhook’s preferences seeds, which the bot reads in its system prompt and can add to, revise or delete) and Conversation MCP Management (lets the visitor add their own MCP servers by chatting). Servers configured bot-wide under the bot’s MCP Servers tab are added too. On a name clash the conversation-level server wins over the bot-level one.

Where each secret lives

Error codes you may see

Troubleshooting

Next steps

Web Widget channel reference

Every setting, the JavaScript API and the identity token contract

Agentic Loops

How the model reasons over tools

MCP Servers

The platform’s built-in servers and their tools

Bot Behaviors

Typing indicators, debouncing, memory and preferences