Sending custom variables from the page
I'm using the Voiceflow web widget and need to pass a custom variable (postcode) into the assistant. This variable is collected from the page (via a form input), so it is not available at the time of widget load.
I want to:
I also tried sending the variable later using chat.interact({ type: 'intent', payload: { postcode } }), but that only works if the assistant is currently waiting for a last event — otherwise the value is ignored.
Additionally, when interact() does work, calling chat.open() afterward seems to trigger a second launch, resulting in duplicated flows or broken logic.
I’d like to know: what’s the best practice for sending a variable after load and after assistant start, without causing a second launch or missing the variable entirely? Is there a way to keep the session live or defer variable usage until interact() is called, without relying on timeouts?
Thanks!
I want to:
- Load the widget normally when the page loads
- Collect the postcode after the user submits a form
- Send that variable to the assistant after launch, without interfering with the session or causing a second unintended launch
I also tried sending the variable later using chat.interact({ type: 'intent', payload: { postcode } }), but that only works if the assistant is currently waiting for a last event — otherwise the value is ignored.
Additionally, when interact() does work, calling chat.open() afterward seems to trigger a second launch, resulting in duplicated flows or broken logic.
I’d like to know: what’s the best practice for sending a variable after load and after assistant start, without causing a second launch or missing the variable entirely? Is there a way to keep the session live or defer variable usage until interact() is called, without relying on timeouts?
Thanks!
