Skip to main content

Overview

Widget context lets one Chatbot adapt to the page or location where it is embedded. The widget sends context values with each chat request, and your agent uses them only when you reference them in the system prompt with placeholders such as {{ page_path }} or {{ location }}. Use widget context when the same agent is embedded across multiple pages, branches, departments, or customer locations and needs to answer with the right local details.
Context values are data, not instructions. They do not change your agent unless your saved prompt contains a matching placeholder.

Where to Configure It

1

Add placeholders in the Playground

Open your agent in the dashboard, go to Playground, and edit Instructions (System prompt). Add placeholders with double curly braces, for example {{ location }}.
2

Pass context in the embed code

Go to Deploy → Chat Widget, copy the embed code, and add a context object to humanizing.init.
3

Test on the embedded page

Visit the page where the widget is installed, start a conversation, and confirm the agent responds with the page or custom value.

Built-In Page Context

The embed script automatically sends these values from the current page. For example, if a visitor opens https://example.com/products/widget?utm_source=newsletter#details, the widget sends: For single-page applications, the widget refreshes this page context when the browser URL changes.

Prompt Example

Add this in Playground → Instructions (System prompt):
Then embed the widget with the standard snippet:

Custom Context

You can also pass your own context values as the second argument to humanizing.init.
Then reference those values in the system prompt:
At request time, the agent receives:
Use custom context for values that are known by your website, such as branch, market, product line, campaign, customer segment, or language variant.

Rules and Limits

Do not put instructions, secrets, access tokens, or private customer data in widget context. The embed code runs in the visitor’s browser and should only contain data that is safe to expose on that page.

Common Patterns

Multi-Location Agent

Use the same agent for multiple branches:

Page-Aware Support

Let the agent know which page the visitor is viewing:

Different Departments

Reuse one agent across different department pages:

Troubleshooting

Check that the key in your prompt exactly matches the key in your context object. For example, {{ location }} only resolves when the embed sends context: { location: "North Branch" }.
Make sure the value is a string, number, or boolean. Objects, arrays, null values, and keys that start with an underscore are ignored.
In most single-page applications, the widget refreshes page context after route changes. If your framework changes content without changing the browser URL, pass a custom context value when initializing or updating the widget.

Next Steps

Edit Prompts

Add placeholders to your agent instructions.

Embed the Widget

Add context to your widget snippet.