Sign In
Sign In
  1. Home
  2. INTEGRATE
  3. Configure Your Widget
  4. Passing variables through the widget script
INTEGRATE
28 articles
1. Give ViaSay access to your Page
Agent Channels8
Configure Your Widget4
Production Bot Test
Manage your widget visibility
Passing variables through the widget script
Securing user channel variables
AI Tools
Ctop Messenger
User Channels3

Passing variables through the widget script

Lets you send information from your website, such as the visitor's first name or customer ID, to the chatbot through the widget script.

Updated on October 1, 2026

Your chatbot can use your website's data directly to:

  • Personalize conversations: greet users by name when they're logged into their account.

  • Boost conversions: remind shoppers how many items they have in their cart, and which ones.

  • Power dynamic logic: send a unique customer ID so your bot can call an external API and fetch loyalty points, order status, or plan details.

In short, you take any piece of information from your site and feed it straight into your ViaSay chatbot, which then knows the visitor's context.

How it works

You use User Channel Variables. Once created, they behave like any other Custom Variable across the ViaSay platform: usable in flows, conditions, and messages.

Your webpage pushes values to the bot by setting HTML attributes on the <destygo-webchat> element.

Step 1: Create a User Channel Variable

In the ViaSay platform, go to Build → Variables → User channel.

User channel tab of the Variables page

Click Create variable, select User channel variable, then enter a Variable Name (e.g. user_firstname) and an optional Description.

User Channel Variable creation window

Once saved, your variable appears in the list, ready for use in any flow, condition, or message.

Step 2: Pass variables through the widget integration script

You'll modify the standard widget embed code to include your variables.

First, copy the widget embed code found under Integrate → Channels → ViaSay Widget.

User Channels list, with the ViaSay Widget
ViaSay Widget embed code

To pass data from your site to the chatbot, simply add extra setAttribute calls before the widget is appended to the page.

Each call takes a key (the name of your User Channel Variable) and a value (either a hard-coded string or a JavaScript variable from your page).

HTML
<script>
  var widget = document.createElement("destygo-webchat");
  widget.setAttribute('id', "destygo_widget");
  widget.setAttribute('class', "destygo_widget");

  widget.setAttribute('key', "value"); // value to add

  widget.setAttribute('token', "here_is_your_widget_token");
  document.body.appendChild(widget);
</script>

For example, to pass the visitor's name, their ID and their subscription plan, you would update the snippet like this:

HTML
<script>
  var widget = document.createElement("destygo-webchat");
  widget.setAttribute('id', "destygo_widget");
  widget.setAttribute('class', "destygo_widget");
  widget.setAttribute('token', "217e439c-7832-4d80-535c-10125655c5d5");
  widget.setAttribute('chatter_name', chatter_name);
  widget.setAttribute('client_id', client_id);
  widget.setAttribute('client_plan', client_plan);
  document.body.appendChild(widget);
</script>

⚠️ Attribute names are case-sensitive and must be all lowercase: chatter_name works, but Chatter_Name does not.

That's it: your bot now receives chatter_name, client_id and client_plan as variables you can use throughout the Flow Builder.

Step 3: Use the variable in the Flow Builder

Your webpage now pushes live values into the widget. In the Flow Builder, anywhere you would normally type text, insert {{variable_name}} and ViaSay replaces it with the value you passed.

For example, in an Answer step:

Answer step greeting the visitor with the chatter_name variable

To fetch additional data, for instance the user's latest invoice status, use the same variable in an API Call step. In the configuration panel on the right, put {{client_id}} in your JSON body or URL, then map the API response to a new bot variable:

API Call step using the client_id variable

Then add a Condition step right after the API call. For example, if {{payment_status}} equals "failed", route the conversation to a human agent; otherwise, continue with an automated confirmation message.

Was this article helpful?

On this page
  • Step 1: Create a User Channel Variable
  • Step 2: Pass variables through the widget integration script
  • Step 3: Use the variable in the Flow Builder

Made from France 💙

Categories

  • ANALYTICS
  • BUILD
  • LOUIS AI
  • INTEGRATE

🔗 Useful Links

  • Sign In
  • Website
  • Terms & Conditions

© 2026

MindsayPowered by Mindsay

Search the help center…

Search help center articles