I need to capture the current page URL where users interact with my VoiceFlow chatbot and include it in the conversation transcripts. This would help me track which pages generate the most questions from users.
The issue is that previous_event seems undefined and I’m not sure how this would actually appear in the transcript logs. Any suggestions on the correct way to pass page URL data to VoiceFlow transcripts?
The launch event payload approach should work, but you need to set up variable capture in VoiceFlow first. Create a ‘page_url’ variable in your project settings, then modify your launch config to use the request payload properly. Don’t access previous_event directly - reference the variable through VoiceFlow’s variable system after it’s captured during initialization. You’ll find this data in the transcript logs under session variables, not in the event payload itself. Make sure your VoiceFlow project captures and stores this launch data - check your variable settings and confirm the launch event maps the payload to your page_url variable.
Had this exact problem last month - it’s a timing issue. The VoiceFlow widget wasn’t fully loaded when I tried accessing the payload data. Here’s what fixed it: use window.voiceflow.chat.proactive.clear() then send a custom event after a short delay. I wrapped the URL sending in a 500ms setTimeout after chat loads, then used a custom intent to grab it. The trick is setting up an intent handler in VoiceFlow that specifically looks for URL data and saves it as a session variable. Shows up clean in your transcript exports under session data instead of getting buried in the event payload.
Try window.voiceflow.chat.interact() instead of the launch event. Send the URL as a custom action after chat loads. Something like window.voiceflow.chat.interact({ type: 'intent', payload: { query: 'set_page_url', entities: [{ name: 'url', value: window.location.href }] } }) works better for transcript tracking.
Hit this exact issue 6 months ago building analytics for our support chatbot. VoiceFlow doesn’t automatically log launch payload data to transcripts - that’s your problem.
Here’s what actually works: use window.voiceflow.chat.send() right after initialization. Set up a system variable in your VoiceFlow project first, then send the URL as a text message that gets processed by a hidden intent:
window.voiceflow.chat.load({
// your config here
}).then(() => {
window.voiceflow.chat.send({
type: 'text',
payload: `PAGE_URL: ${window.location.href}`
});
});
Create an intent in VoiceFlow that captures messages starting with “PAGE_URL:” and extracts the URL into a variable. Now it shows up in your conversation logs as actual conversation data instead of being buried in session metadata.
Basically, transcript logs only capture actual conversation flow, not initialization payloads. You’ve got to make the URL part of the conversation itself.