FredrikOseberg / react-chatbot-kit

MIT License
299 stars 139 forks source link

How to restart converation? #60

Open VeenaMalali13 opened 3 years ago

VeenaMalali13 commented 3 years ago

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.

FredrikOseberg commented 3 years ago

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: []
}))
seschwartz8 commented 3 months ago

@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
iammmk commented 2 weeks ago

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

seschwartz8 commented 2 weeks ago

@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

abduu11aahh commented 2 days ago

is there any update on this @FredrikOseberg ?