How to Pass Parameters from Website to Scenario
ConnectiveOne widget allows passing parameters from your website to the bot scenario. This is useful for passing UTM tags, user ID, product data, and other context.
How Does Parameter Passing Work?
- You pass parameters through
params_from_siteduring widget initialization - Parameters are automatically added to each message
- Parameters are available in the scenario through
{{param_name}}
Passing Parameters During Initialization
Pass parameters through params_from_site during widget initialization:
kw('init', {
bot_id: 1,
language_code: "uk",
params_from_site: {
utm_source: "widget",
utm_campaign: "summer_sale",
company_name: "TV123",
user_id: "12345"
}
});
In the scenario, parameters are available through placeholders:
{{utm_source}}→ "widget"{{utm_campaign}}→ "summer_sale"{{company_name}}→ "TV123"{{user_id}}→ "12345"
Changing Parameters During Operation
You can change parameters during widget operation:
kw_event('kwsetparamsfromsite', {
params_from_site: {
company_name: 'TV123123',
page_url: window.location.href
}
});
Important: If you pass an empty object params_from_site: {}, all parameters will be cleared.
Passing Dynamic Parameters
You can pass parameters based on the current page or user actions:
// Pass current page URL
kw('init', {
bot_id: 1,
params_from_site: {
page_url: window.location.href,
page_title: document.title,
referrer: document.referrer
}
});
// Pass parameters on button click
document.getElementById('product-btn').addEventListener('click', function() {
kw_event('kwsetparamsfromsite', {
params_from_site: {
product_id: '12345',
product_name: 'iPhone 15',
action: 'product_inquiry'
}
});
kw_event('openchat', 1); // Open chat
});
Automatic Metadata Addition
By default (recognize_user_meta is enabled), the following are added to params_from_site:
user_agent— browser informationip_address— user IP address when the lookup succeeds (if the request fails, other fields are still sent)source_platform— launch environment: Web (browser), Mobile App iOS, or Mobile App Android (typical in-app WebView). If you already setsource_platforminparams_from_site, the automatic value does not override yours.
To disable metadata collection, set recognize_user_meta: false.
Example (typical case — no extra flags needed):
kw('init', {
bot_id: 1,
params_from_site: {
utm_source: "widget"
}
});
When sending /start, user_agent, ip_address, and source_platform are added (with recognize_user_meta on). They are available in the operator panel; source_platform is also stored in Statistics for web widget dialogues.
Usage in Scenario
After passing parameters, they are available in the scenario through placeholders:
Message Block Example:
Hello! You came from {{utm_source}}.
Your company: {{company_name}}
Condition Example:
{
"if": {
"{{utm_source}}": {
"widget": "process_widget_user",
"facebook": "process_facebook_user",
"default": "process_default_user"
}
}
}
Limitations
- Parameters are passed in each message through the
constantsfield as a JSON string - If parameters are not passed,
params_from_sitewill be an empty object - Maximum parameter size is limited by system settings