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 openshttps://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):Custom Context
You can also pass your own context values as the second argument tohumanizing.init.
Rules and Limits
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
The placeholder appears in the answer
The placeholder appears in the answer
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" }.My custom value is ignored
My custom value is ignored
Make sure the value is a string, number, or boolean. Objects, arrays, null values, and keys that start with an underscore are ignored.
The page path is outdated
The page path is outdated
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.