conscious-sapphire•2y ago
Start a new chat from JS
Hello, I would like to restart a chat via JS/React whenever I want. So far, I have to do it manually. Is there any way to do it via JS?
Thanks!
2 Replies
To restart a chat from JavaScript/React in the Voiceflow Web Chat, you can use the
window.voiceflow.chat.reset()
function provided by the Voiceflow Web Chat API. This function will reset the conversation state and start a new chat session.
Here's an example of how you can call this function in a React component:
In this example, when the "Reset Chat" button is clicked, the handleResetChat
function is called, which in turn calls window.voiceflow.chat.reset()
to reset the chat session.
You can also call the reset
function directly from JavaScript without React, like this:
This will reset the chat session and start a new conversation.
Please note that the window.voiceflow.chat
object is only available after the Voiceflow Web Chat has been loaded and initialized. Make sure to call the reset
function after the chat has been loaded successfully.
https://developer.voiceflow.com/docs/chat-widget#resetconscious-sapphireOP•2y ago
Seems that reset is no longer available
Solved by setting "Forget" in the widget memory option