flat-fuchsia
flat-fuchsia2y ago

Open URL in Chatbot

Hi, I'd like to send my user to a URL upon completion of a chat. Specifically, when the user is finished the chat, I want to send them to a Thank You page on my website. Is there a simple way to do this? Any help would be appreciated.
4 Replies
Tico | Voiceflow Assistant
To redirect users to a specific URL upon completion of a chat, you can use the JavaScript API provided by Voiceflow. Unfortunately, there isn't a built-in feature in the chat widget to redirect users to a URL, but you can achieve this by listening to the 'done' event and then redirecting the user using JavaScript's window.location.href. Here's an example of how you can do this:
window.voiceflow.chat.load({
verify: { projectID: 'YourProjectID' },
url: 'https://general-runtime.voiceflow.com/',
versionID: 'production'
}).then(() => {
window.voiceflow.chat.on('done', () => {
window.location.href = 'https://yourwebsite.com/thank-you';
});
});
window.voiceflow.chat.load({
verify: { projectID: 'YourProjectID' },
url: 'https://general-runtime.voiceflow.com/',
versionID: 'production'
}).then(() => {
window.voiceflow.chat.on('done', () => {
window.location.href = 'https://yourwebsite.com/thank-you';
});
});
In this example, replace 'YourProjectID' with your actual project ID and 'https://yourwebsite.com/thank-you' with the URL of your Thank You page. Please note that this will only work if the chat ends with a 'End Interaction' step in your Voiceflow project. The 'done' event is triggered when the chat reaches an 'End Interaction' step. For more information on how to use the JavaScript API, you can refer to the Voiceflow documentation.
flat-fuchsia
flat-fuchsiaOP2y ago
That doesn't quite work for me. I need to be able to send them to a different URL according to different variable values. So it can't be just on "done".
NiKo | Voiceflow
You can use a custom version of the react-chat and a Custom Action step to pass the URL you want. In your custom integration, check for the Custom Action payload in the Dialog API trace and redirect the user to that URL.
flat-fuchsia
flat-fuchsiaOP2y ago
Thank you. That miight be a little over my head, but I'll do some research and try it...

Did you find this page helpful?