Channel Variables

Channel Variables

Channel Variables are injected into the Widget via JavaScript.

Inject variables into the Widget

Injecting variables from the frontend is possible with this function:

solvemate('contextVariables', {'variable_name': variable_value});

Here is a full example:

(function(s,o,l,v,e,m,a,t){t='solvemateConfig';s[e]=s[e]||function(x,y)
{(s[t]=s[t]||{})[x]=y;};a=o.createElement(l);a.async=1;a.src=v;o.body.appendChild(a);
})(window,document,'script','https://widget.solvemate.com/v2/init.js','solvemate');

solvemate('projectID', project_id);

solvemate('contextVariables', {
    'website_location': webLocation,
    'current_url': documentUrl,
    'browser_language': browserLanguage,
    'app_version': appVersion,
});
The names for the variables used in the script (here website_location , current_url , browser_language and app_version) need to match the variable names that you configure in the Web App.

Setup in Solvemate Web App and prerequisites

There are no prerequisites to use Channel variables.

To make Channel variables available in the Chatbot:

  • Variable name needs to be declared in Workspace -> Variables -> Channel Variable,
  • Variable value needs to be injected in Solvemate Widget from the client page,
  • Variable is used accordingly in texts, forms or function code.

Notes for developers

  • variable values can be updated during a conversation,
  • nested variables are not supported,
  • variables should be passed in as a string (integers and booleans currently not supported),
  • these variables are neither signed nor encrypted.