Share feedback, ideas and get community help

Updated 2 days ago

How can I restart chatbot?

Hello, is there any script that can I use to reset all the information bot send and restart all over?

After all the interation with chatbot ends, will show a button to start again the conversation, and I want to reset all the messages and create a new chat when this button is clicked.

Thanks in advance πŸ™‚
2
B
c
d
28 comments
You could add a script block with the following content:

Plain Text
document.location.reload()


Make sure to check the Execute on client option
Hi, i tried this but this just closes the bot (popup), how can we refresh the conversation and start again? without closing the window?
You'd have to enable Remember user so that it automatically opens up again https://docs.typebot.io/settings/remember-user#remember-user
Quick question on this, is there a script to clear the chat state as well as reload the chat so we can have a restart chat button?
I also need a quick restart button when needed.
what is that you need and that @Baptiste replies has not solved for you?

With this

document.location.reload()

you can close the bot

if you enable remember user (https://docs.typebot.io/settings/remember-user#remember-user) it automatically opens up again

What is that you need more?

You can also add a button with restart label and the connected flow has a redirection function to your public typebot link
In general , I would like to remember the chat state, but I when the user restarts the chat I would the chat state to be cleared. Is there a script I can use to clear the chat state?
mmhhh you want two opposite options.
If you activate the remember option you can not deactivate it when you restart the chat.
All informations are stored in the browser cache so you'd need to remove them from storage.
you can try to use a script look like this:

localStorage.clear();
sessionStorage.clear();
document.location.reload();

it would do a clear first to restart the chat.

I've quicly tested here --> https://typebot.co/test-for-drippingfist and i think that it work but i'm not an expert how @Baptiste or others guru so please take care and test it first to apply.

Thnak you
Thanks for this! It clears the variables but doesn't clear the chat state. The name field remains. I would like the restart button to reset the whole flow. Thanks again for your effort
i do not ubnderstand what you mean with chat state.
When you restart the bot the name field do not remain 8if you click the correct option with the script shared.
What is the chat state?
It only clears the variables.
ok i've understood.
Why do you need to restart a chat with all cleared?
What is the use case?
what have to happen to info inserted previously to this "restart action"
Giving a look to your screenshot look like to be a customer care bot on that you receive the users's questions and you'd like to give the way to can ask something else after a previous request.
in that case i suggest to see the @Baptiste ondoc link (https://docs.typebot.io/guides/how-to-create-loops#how-to-create-loops) about how to manage loops.
Better work around can be easily a redirect to bot link in a new page (you can see a new button on test bot) but these are only some suggests and ideas without to know what you exactly need.

Here also public typebot link (just to see what's inside) https://app.typebot.io/typebots/cm40zj8fc0001gpn943z1zae1/edit
I know how to create loops. When a user requests a callback, we want to end the flow because we count the number of "completed" chats as a performance metric. Because we are deployed on websites I need to remember the chat state so that if they load another page, the chat history reappears. BUT, after they request a callback I would like them to have the option to restart the chat from the beginning. Currently this only works if they open the site in a new window. Is there no script to clear the chat state from the browser cache?
i think that your case is fairly complicated and is not possibile to solve between typebot that, how every web service, can not automatically clear the browser cache.
Clearing cache is a manual action that user can do but, for that i know, is not possibile to automatically do.
i hope that someone (or @Baptiste ) can help you because i've finished my ideas 😦
I appreciate your efforts.
That's odd. If you clear the storage, the user should not be remembered anymore
Can you maybe record a video that shows how you clear the storage etc?
This is script that runs when the user presses the restart chat button. I have the flow set to remember user by session.
Attachment
image.png
I'll have to try this
I will keep you posted
So the issue is that it clears the storage correctly but after the script is executed the bot store the state again in the storage
We can't really clear the storage directly from the bot flow it seems
So I suggest you do it outside of it, from your website
You can subscribe to the onAnswer callback and if it is "Restart" you clear the storage and reload the page
Sorry Baptiste. I don't understand this part, "subscribe to the onAnswer"
Add a reply
Sign up and join the conversation on Discord