[英]Chatbot restarts conversation on minimizing
我使用 c# 和 bot 框架 sdk v4 开发了我的聊天机器人。 我通过传递直线令牌使用 react js 将它连接到我的网页。 但是现在当我最小化聊天然后最大化聊天时,聊天会停止流程并重新启动。 但是旧的消息仍然存在。 最小化时我不需要重新启动流程。 我的 reactjs 实现代码如下。
const store = createStore({}, () => next => action => {
if (action.type === 'DIRECT_LINE/INCOMING_ACTIVITY') {
if (action.payload.activity.from.role === 'bot') {
this.setState(() => ({ newMessage: true }));
}
}
return next(action);
});
this.state = {
minimized: true,
newMessage: false,
side: 'right',
store,
styleSet: createStyleSet({
backgroundColor: 'Transparent'
}),
token: null
};
}
async handleFetchToken() {
if (!this.state.token) {
const res = <ReactWebChat directLine={ this.directLine } />
console.log(res)
// const { token } = await res.json();
// this.setState(() => ({ token }));
}
}
handleMaximizeButtonClick() {
this.setState(() => ({
minimized: false,
newMessage: false,
}));
}
handleMinimizeButtonClick() {
this.setState(() => ({
minimized: true,
newMessage: false
}));
}
内部渲染
render() {
const {
state: { minimized, newMessage, side, store, styleSet, token }
} = this;
<WebChat
className="react-web-chat"
// onFetchToken={this.handleFetchToken}
store={store}
styleSet={styleSet}
token={"my_token_here"}
/>
请帮助我解决问题。 提前致谢。
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.