Using DirectLine and Backchannel might help you here. You'll find the info in the readme on this repo if you scroll to the last section. It allows Webchat and the host can send/receive whatever you want from each other.
<body onload="postLoadMessage()">
<div id="BotChatGoesHere" class="wc-narrow"></div>
<script src="botchat.js"></script>
<script>
var params = BotChat.queryParams(location.search);
var user = { id: '***' };
var bot = { id: '***' };
window['botchatDebug'] = params['debug'] && params['debug'] === "true";
var botConnection = new BotChat.DirectLine({
secret: '****',
token: params['t'],
domain: params['domain'],
webSocket: params['webSocket'] && params['webSocket'] === "true" // defaults to true
});
BotChat.App({
botConnection: botConnection,
user: user,
bot: bot
}, document.getElementById("BotChatGoesHere"));
//var x= whatever value you want to send;
const postLoadMessage = () => {
botConnection
.postActivity({type: "event", value: x , from: {id: "me" }, name: "PageLoaded"})
.subscribe(id => console.log("success"));
}
</script>
</body>
The code given above is how i used it to send value x when the page with the bot is loaded.
I hope this helps :)