Skip to main content

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

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:
PlaceholderExampleDescription
{{ page_url }}https://example.com/products/widgetCurrent page URL without query string or hash
{{ page_origin }}https://example.comSite origin, including protocol and domain
{{ page_path }}/products/widgetCurrent path on the site
For single-page applications, the widget refreshes this page context when the browser URL changes.

Prompt Example

Add this in Playground → Instructions (System prompt):
The visitor is currently on {{ page_path }}.
If their question is page-specific, use that page as the first clue for what they need.
Then embed the widget with the standard snippet:
<script src="https://chat.humanizing.com/embed.js"></script>
<script>humanizing.init("YOUR_PUBLIC_KEY");</script>

Custom Context

You can also pass your own context values as the second argument to humanizing.init.
<script src="https://chat.humanizing.com/embed.js"></script>
<script>
  humanizing.init("YOUR_PUBLIC_KEY", {
    context: {
      location: "North Branch",
      department: "Service",
      premiumCustomer: true
    }
  });
</script>
Then reference those values in the system prompt:
You are answering for the {{ location }} location.
If a visitor asks about appointments, route them to the {{ department }} team.
At request time, the agent receives:
You are answering for the North Branch location.
If a visitor asks about appointments, route them to the Service team.
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

RuleDetails
Placeholder formatUse {{ key }} in the system prompt
Key formatStart with a letter, then use letters, numbers, or underscores
ValuesStrings, numbers, and booleans are supported
Maximum keysUp to 50 context keys are accepted
Maximum value lengthValues are limited to 500 characters
Missing valuesIf a key is not provided, the placeholder stays visible as {{ key }}
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:
<script>
  humanizing.init("YOUR_PUBLIC_KEY", {
    context: {
      location: "North Branch",
      phone: "+49 241 000000"
    }
  });
</script>
You are answering for our {{ location }} branch.
When visitors ask how to reach us by phone, give them {{ phone }}.

Page-Aware Support

Let the agent know which page the visitor is viewing:
The visitor is chatting from {{ page_url }}.
Use the current page as context, but answer only from the knowledge base.

Different Departments

Reuse one agent across different department pages:
<script>
  humanizing.init("YOUR_PUBLIC_KEY", {
    context: {
      department: "Sales"
    }
  });
</script>
You are currently supporting the {{ department }} department.
If the question belongs to another department, explain who can help.

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.