我在 Node.js 中使用 botbuilder 创建了一个简单的聊天机器人。由于给定的环境,我通过自定义 iframe 包含了聊天机器人。前端是带有 DirectLine 的 WebChat。如何在父窗口中检测到对话框的结束?
我找不到关于如何在 WebChat/DirectLine 中捕捉对话结束的正确方法。
我在 iframe 中使用以下代码呈现我的聊天:
const store = window.WebChat.createStore({}, ({ dispatch }) => next => action => {
if (action.type === 'DIRECT_LINE/CONNECT_FULFILLED') {
dispatch({
type: 'WEB_CHAT/SEND_EVENT',
payload: {
name: 'webchat/join',
value: { language: window.navigator.language }
}
});
}
return next(action);
});
window.WebChat.renderWebChat({
directLine: window.WebChat.createDirectLine({ token: "thisismytoken" }),
store,
userID: '1',
username: username,
styleOptions: {
botAvatarImage: "https://mylink.azurewebsites.net/avatar_user_1.png",
userAvatarImage: "https://mylink.azurewebsites.net/avatar_user_1.png"
}
}, document.getElementById('webchat'));
在 Node.JS 中,我使用以下代码结束对话:
return await step.endDialog();
运行 endDialog 后,我想提交 iFrame 的父级。谁能给我一些指导?