I developed my chatbot using c# and bot framework sdk v4. I connected it to my webpage using react js by passing directline token. 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.
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.