The widget only works on HTTPS pages.
To pass client variables to the widget, add the clientMetadata object to the widget code. This object will contain the variables that you want to pass to the bot:
clientMetadata: {
contractId: "12345",
variable1: "value1",
variable2: "value2",
variable3: "value3"
}
In the bot, you can use these variables as follows:
- `{clientMetadata.contractId}`;
- `{clientMetadata.variable1}`;
- `{clientMetadata.variable2}`;
- `{clientMetadata.variable3}`.
### Usage example
Widget source code:
```javascript
<div id="chat-client" style="z-index: 1000000;"></div>
<script src="https://twin24.ai/app/chat-client/widget.js"></script>
<script>
appChatClient({
chatId: 'b0cfca0-ad00-4f00-b1f0-40ca000b0',
}, {
host: document.getElementById('chat-client'),
})
</script>
Modified widget code with variables:
<div id="chat-client" style="z-index: 1000000;"></div>
<script src="https://twin24.ai/app/chat-client/widget.js"></script>
<script>
appChatClient({
chatId: 'b7cfca7-ad40-4f06-b1f4-48ca462b6',
clientMetadata: {
contractId: "12345",
variable1: "value1",
variable2: "value2",
variable3: "value3"
},
}, {
host: document.getElementById('chat-client'),
})
</script>
Now variables in the bot can be used via {clientMetadata.CHANGE_NAME}. For example:
{clientMetadata.contractId} = 12345;{clientMetadata.variable1} = value1;{clientMetadata.variable2} = value2;{clientMetadata.variable3} = value3.