1
Directline Webchatを使用してWebアプリケーションをリロードする方法は?Directline Webchatを使用してWebアプリケーションをリロードする方法は?
または、Directline WebchatがBotからの応答を受け取った後にJavascript関数を呼び出す方法はありますか?
Directline Webchatを使用してWebアプリケーションをリロードする方法は?Directline Webchatを使用してWebアプリケーションをリロードする方法は?
または、Directline WebchatがBotからの応答を受け取った後にJavascript関数を呼び出す方法はありますか?
あなたは、このためにウェブチャットコントロールのバックチャネルを使用することができます。
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;
}
この例では、ボットが変更されたページののbackgroundColorをウェブチャットして持っているchangeBackgroundイベントを送信する方法を示しています。
から: https://github.com/Microsoft/BotFramework-WebChat/blob/master/samples/backchannel/index.html
代わりchangeBackgroundイベントの、あなたはJavaScriptでreloadPageイベントを送信し、()location.reloadを呼び出すことができます。