Where to Find Code for the Reset Conversation Button

Hello, I have been working with Botpress and I am having trouble getting the bot to reset the conversation when ever the page gets loaded. I already have working code that displays a welcome message, but since the conversation is never being reset it never displays again, since technically the user is not visiting the bot for the first time. What I want to happen is that when the page gets refreshed the function/code that makes the “Reset Conversation” code work gets called, so I was trying to find its code but I have not had any luck with that.

I have read the similar article here How Reset the Conversation of bot?, but it did not help me. Does anyone have any advice/solutions?

Hello @ryan-benson, you can edit the file config/channel-web.json and set those parameters. When the page is refreshed, it will be a new conversation. Does that work ?

"startNewConvoOnTimeout": true,
"recentConversationLifetime": "1s",

Otherwise, if you really just want to see “Reset the conversation”, you can use window.botpressWebChat.sendEvent({ type: ‘session_reset’ }) and it will send the event (just add it in a timeout after the chat is loaded)

Yes that works perfectly! Thank you.

Let me rephrase, setting startNewConvoOnTimeout to true works fine. However, nothing happens when I try to send the session_reset event, even when it is inside a time out. Included is the code I am using to send the ‘session_reset’.

You can listen for the session_reset event from inside an incoming middleware hook and reset the session programmatically using this method.

For example:

await bp.dialog.deleteSession(bp.dialog.createId(event))
event.setFlag(bp.IO.WellKnownFlags.SKIP_DIALOG_ENGINE, true)