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
If you set recognize_user_meta: true, the following are automatically added to params_from_site:
user_agent— browser informationip_address— user IP address
Example:
kw('init', {
bot_id: 1,
recognize_user_meta: true,
params_from_site: {
utm_source: "widget"
}
});
When sending /start, user_agent and ip_address will be automatically added to params_from_site, which will be available in the operator panel.
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