react-chatbot-kit icon indicating copy to clipboard operation
react-chatbot-kit copied to clipboard

How to restart converation?

Open VeenaMalali13 opened this issue 3 years ago • 5 comments

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.

VeenaMalali13 avatar May 27 '21 10:05 VeenaMalali13

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 avatar Jun 16 '21 08:06 FredrikOseberg

@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.

Screenshot 2024-03-25 at 5 18 11 PM

seschwartz8 avatar Mar 25 '24 22:03 seschwartz8

Hi @seschwartz8 Did u find any way to access props in header?

iammmk avatar Jun 21 '24 13:06 iammmk

@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

seschwartz8 avatar Jun 21 '24 15:06 seschwartz8

is there any update on this @FredrikOseberg ?

abduu11aahh avatar Jul 08 '24 06:07 abduu11aahh