Skip to main content

Overview

By default the agent only sees what the visitor types. With page context, you can tell the agent where the visitor is and what they’re looking at — a pricing page, a product detail, an account settings screen — so it can give smarter, more relevant answers without the visitor having to explain.

Quick start


API

sendContextUpdate(data, includePageDetails?)

Sends a context payload to the agent over the active WebSocket connection. Call it whenever the visitor navigates or when relevant page data changes.
Context is delivered on the live chat connection. A brand-new visitor has no connection until they send their first message, so the latest context you set is what the agent sees once the conversation starts. To attach context to a proactive trigger before any chat begins, use the trigger’s pageContext option.

Auto page details

When includePageDetails is true, the SDK automatically collects: These are merged with your custom data. If you pass a key that overlaps (e.g. title), your value takes precedence.

What the agent sees

The page context is injected into the agent’s prompt as additional context:
The agent can use this to tailor its responses. For example, if a visitor asks “What’s included?” while on the Pro Plan pricing page, the agent already knows which plan they’re looking at.

Updating context

You can call sendContextUpdate multiple times. Each call replaces the previous context on the server — it does not merge. Send the full context you want the agent to have each time.
For single-page apps, call sendContextUpdate on route changes to keep the agent informed as the visitor navigates.

Examples

E-commerce product page

SaaS pricing page

Account dashboard

SPA route change listener


Next steps

Register tools

Give your agent the ability to take actions on your website.

Form tools

Turn any HTML form into an agent-callable tool with zero JavaScript.