Setting up a chat Surface
Use a chat Surface to put your Product’s Capabilities in an embeddable chat widget. When you finish this guide, the widget runs on your website and answers visitors with your Flow or Agent.
Before you begin
- Create a Product.
- In the workbench, add at least one Capability to the Product before you set up the Surface. A Capability is a Flow, Agent, or connected external Agent that answers messages from the Surface. For more information, see Adding capabilities to a Product. In the classic dashboard, if you create a Product with a chat Surface and no Capability, Runtype creates an Agent for the Surface.
The dashboard has two layouts, the workbench and the classic dashboard. Each layout has its own way to set up a chat Surface. To go back to the classic dashboard from the workbench, open the Runtype menu and select Switch to the classic dashboard.
Set up a chat Surface in the workbench
To set up a chat Surface in the workbench, follow these steps:
- Open a Product. Under Surfaces, select Add a surface, then select Chat Widget. The new Surface opens as a draft in the Surface editor.
- In Overview, enter a Name and a Welcome message.
- In Answering capability, choose the Flow or Agent that answers messages.
- Open Access & keys and click New token. Enter a Name, select a Mode of Test or Live, enter the Allowed origins of your website, and click Create token. Runtype shows a live token value only once, so store it before you close the dialog.
- Open Appearance and style the widget. The preview shows the widget on desktop and mobile.
- Open Embed. In Snippet, select Script tag or React, then select your token in the token list. For a live token, paste the value that you stored in step 4 into Saved live token. Click Copy.
- Click Save, then click Test to chat with the saved configuration. Test is available after the Surface has an enabled Flow or Agent.
- Open Overview and click Activate in Status.
A new chat Surface starts as a draft, and the widget returns Chat surface is not active until you activate it. Activate is available after the Surface has an active client token linked to it. To stop new conversations later, turn off Surface active to pause the Surface. Conversations that are already open continue until they end.
Route messages between Capabilities
By default, one Capability answers every message. To send each message to the Capability that fits it best, follow these steps:
- Open Capabilities and set Message handling to Route each message to a capability.
- In Routing, choose a Router model and, optionally, enter a Routing prompt.
- Use Add a capability to add more of the Product’s Capabilities to the Surface.
- Under Routable capabilities, select the Capabilities that the router can choose. The entry point is always routable. To change it, click Make entry point on another Capability.
- Expand each Capability and write an Exposed name and Exposed description. The router uses them to choose a Capability, so describe what each one handles.
- Optionally, choose a Fallback capability for messages that match no Capability.
For more information, see Surface orchestration modes.
Other Surface editor settings
The following table lists other settings in the Surface editor:
To review conversations from this Surface, open Sessions in the activity panel. Select a conversation to see its transcript and trace. Cost & latency and Evals are in the lower panel.
Set up a chat Surface in the classic dashboard
In the classic dashboard, you set up a chat Surface with a setup wizard and then refine it in the Surface panel.
Use the setup wizard
When you create a chat Surface, Runtype opens the Get Your Chat Live setup wizard:
- Configure Agent: set the system prompt, choose a model, and add tools. This step is required.
- Style Widget: choose a theme preset or customize the widget’s appearance. You can skip this step.
- Ship: select a client token and copy the embed code. You can skip this step. If no token exists, the wizard creates a live token that accepts every origin and activates the Surface. Restrict the token’s origins in the Auth tab before you publish the widget.
When the wizard finishes, select View Full Config to open the Surface panel, or select Add Capability to add another Capability.
Add a chat Surface to an existing Product
- Open Products in the sidebar, then select the Product.
- In the Product surfaces section, click Add Surface.
- Select Chat Widget. The dashboard opens the Surface panel.
Configure the Surface panel
The following table describes the tabs in the Surface panel:
Get the embed code from Ship
The Ship tab shows your choices as sentences with dropdowns that you can change.
- In the first sentence, choose your app goal and the tool that builds it.
- To get a prompt for a coding agent, leave the tool set to my coding agent or select a named tool. Click Copy prompt and paste the prompt into your coding agent.
- To copy code yourself, select code it myself, then choose an Integration format of Script tag or React. Paste a script-tag snippet before the closing
</body>tag of your page. - In the It should use sentence, click the style, such as Clean style, to open the Chat Style Editor. You can adjust colors, typography, layout, and launcher position, or generate a theme from a website URL or a description.
- In the same sentence, select a client token after with, or select Create token. If you keep a placeholder, replace
YOUR_CLIENT_TOKENwith a real token before you publish the page. - In Overview, set the status to Active.
Verify the widget
Open a page that has the embed code, open the widget, and send a message. The widget shows the reply from your Flow or Agent. In the workbench, the conversation also appears in Sessions.
Design browser tools for your assistant
Use WebMCP page tools when an assistant needs browser-only state or UI. Keep
backend work in server-side tools. Register page tools on document.modelContext,
enable webmcp in Persona and on the chat Surface, and restrict the token’s
origins and the Surface’s origin-scoped tool allowlist before publishing.
Design a user journey before writing tools. Include the starting state,
ambiguous requests, and the point where the user must confirm an action.
For example, get_cart reads a cart and open_checkout opens a review screen.
Neither places an order. Keep a purchase behind authenticated, user-confirmed
checkout; a model-authored confirmed: true is not proof of consent.
Declare readOnlyHint: true only for tools that change neither application
state nor the UI. Use consequentialHint: true for significant real-world
actions, and untrustedContentHint: true for user-authored or third-party
results, even when your own database stores the text. These hints are advisory,
not authorization. Missing hints do not justify bypassing confirmation.
Validate arguments and resource access at execution time, honor cancellation, protect unsaved work, and wait for visible updates before returning success. Remove owned tool registrations when their page or component unmounts.
Keep Persona’s approval defaults. Browser confirmation and requireConfirmFor
do not replace server authorization. Use webmcp.autoApprove only with a
host-owned safe-read policy, not arbitrary page-authored hints.
Start with the typed Persona tool example. It includes deterministic safety tests and opt-in model evaluations. Run both: schema-only model tests do not prove approval enforcement or injection safety. Google’s WebMCP authoring skill provides additional journey-design workflows. Its authoring budgets do not change Runtype’s limits, security policy, or supported compatibility paths.
Troubleshooting
The following table lists common problems and how to fix them:
For other errors, such as Session message limit reached, see Troubleshoot rejected requests.
To set up a chat Surface without the dashboard, use the Runtype MCP server. Call create_surface, then create_client_token with the Surface’s product_surface_id, then generate_persona_embed_code. To create an Agent, a client token, and a snippet from a terminal instead, run runtype persona init.
Next steps
- Embedding the chat widget (script tag): add the widget to an HTML page
- Embedding the chat widget (React): add the widget to a React application
- Widget theming and customization: customize the widget’s appearance
- Client tokens and domain restrictions: set token origins, limits, and release targets
- Client conversation history: keep a visitor’s history across sessions and devices