简体   繁体   English

聊天机器人在最小化时重新开始对话

[英]Chatbot restarts conversation on minimizing

I developed my chatbot using c# and bot framework sdk v4.我使用 c# 和 bot 框架 sdk v4 开发了我的聊天机器人。 I connected it to my webpage using react js by passing directline token.我通过传递直线令牌使用 react js 将它连接到我的网页。 But now when i Minimize the chat and then maximize it the chat stops the flow and gets restarted.但是现在当我最小化聊天然后最大化聊天时,聊天会停止流程并重新启动。 But the old messages are still there.但是旧的消息仍然存在。 I doesn't need to restart the flow when minimized.最小化时我不需要重新启动流程。 My reactjs implementation code is given below.我的 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
      }));
   }

inside render内部渲染

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"}
                  />

Please help me in resolving the issue.请帮助我解决问题。 Thanks in advance.提前致谢。

Check out this solution I posted explaining how to make a basic local token server.查看我发布的这个解决方案,解释了如何制作一个基本的本地令牌服务器。 Enabling CORS here only applies if you are running purely local.在此处启用 CORS 仅适用于纯本地运行的情况。 If you are tunneling via ngrok to Azure Bot Service, then you will need to make changes either on your bot's DirectLine Channel or on the App Service.如果通过 ngrok 隧道连接到 Azure 机器人服务,则需要在机器人的 DirectLine 通道或应用服务上进行更改。 View this image post for visual reference.查看此图片帖子以供视觉参考。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM