How-to
Article MarkdownReport an error

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?

  1. You pass parameters through params_from_site during widget initialization
  2. Parameters are automatically added to each message
  3. 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 information
  • ip_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 set source_platform in params_from_site, the automatic value does not override yours.
  • source_hostname — hostname of the page where the widget is open (for example, shop.example.com). Detected automatically from the embedding URL; if you already set source_hostname in params_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, source_platform, and source_hostname are added (with recognize_user_meta on). They are available in the operator panel; source_platform and source_hostname are also stored in Statistics for web widget dialogues — useful when one bot is embedded on multiple sites.


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 constants field as a JSON string
  • If parameters are not passed, params_from_site will be an empty object
  • Maximum parameter size is limited by system settings

Using your own AI agent?Install the open skill so your AI agent can work with current official ConnectiveOne documentation.Get the skillNeed support?Couldn’t find the answer or need help from the ConnectiveOne team? Create a request in Client Portal.Create a request