react-chatbot-kit
react-chatbot-kit copied to clipboard
How to restart converation?
How to restart conversation on some conditions? Like I am getting 'restart' flag from backend. Whenever I am getting this flag, I need to restart conversation.
All of your messages live inside the messages array. Simply use the setState function passed to the actionprovider or widgets to clear out the messages array and start the conversation again:
// When you get the restart flag in action provider:
this.setState(prev => ({
...prev
messages: []
}))
@FredrikOseberg I'd like to be able to access the chatbot's setState from a customComponent header for resetting the chat from there. I noticed that in the docs you can spread props to your customComponents, but when I log those props, there is nothing being passed to my header.
If you think this would be a simple change, I'd be interested in contributing a fix to the codebase if you have any suggestions on how you'd want it achieved.
Hi @seschwartz8 Did u find any way to access props in header?
@iammmk unfortunately I did not. I ended up scrapping the usage of this library and building it myself so I'd have more control over states
is there any update on this @FredrikOseberg ?