Botframework 如何使用Directline Webchat重新加载Web应用程序?
如何使用Directline Webchat重新加载Web应用程序Botframework 如何使用Directline Webchat重新加载Web应用程序?,botframework,direct-line-botframework,Botframework,Direct Line Botframework,如何使用Directline Webchat重新加载Web应用程序 或者,在Directline Webchat接收到来自Bot的响应后,是否有任何方法调用Javascript函数?您可以使用Webchat控件的反向通道执行以下操作: const user = { id: 'userid', name: 'username' }; const bot = { id: 'botid', name:
或者,在Directline Webchat接收到来自Bot的响应后,是否有任何方法调用Javascript函数?您可以使用Webchat控件的反向通道执行以下操作:
const user = {
id: 'userid',
name: 'username'
};
const bot = {
id: 'botid',
name: 'botname'
};
const botConnection = new BotChat.DirectLine({
secret: 'SECRET'
});
BotChat.App({
bot: bot,
botConnection: botConnection,
user: user
}, document.getElementById('BotChatGoesHere'));
botConnection.activity$
.filter(function (activity) {
return activity.type === 'event' && activity.name === 'changeBackground';
})
.subscribe(function (activity) {
console.log('"changeBackground" received with value: ' + activity.value);
changeBackgroundColor(activity.value);
});
function changeBackgroundColor(newColor) {
document.body.style.backgroundColor = newColor;
}
此示例显示了机器人如何向WebChat发送changeBackground事件并更改页面的背景颜色
发件人:
您可以发送一个reloadPage事件并调用javascript中的location.reload(),而不是changeBackground事件