Documentation Index
Fetch the complete documentation index at: https://docs.humanizing.com/llms.txt
Use this file to discover all available pages before exploring further.
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
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 }}.Pass context in the embed code
Go to Deploy → Chat Widget, copy the embed code, and add a
context object to humanizing.init.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:
| Placeholder | Example | Description |
|---|---|---|
{{ page_url }} | https://example.com/products/widget | Current page URL without query string or hash |
{{ page_origin }} | https://example.com | Site origin, including protocol and domain |
{{ page_path }} | /products/widget | Current path on the site |
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
| Rule | Details |
|---|---|
| Placeholder format | Use {{ key }} in the system prompt |
| Key format | Start with a letter, then use letters, numbers, or underscores |
| Values | Strings, numbers, and booleans are supported |
| Maximum keys | Up to 50 context keys are accepted |
| Maximum value length | Values are limited to 500 characters |
| Missing values | If a key is not provided, the placeholder stays visible as {{ key }} |
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.