Sending custom variables from the page
I want to:
1. Load the widget normally when the page loads
2. Collect the postcode after the user submits a form
3. Send that variable to the assistant after launch, without interfering with the session or causing a second unintended launch
I’ve tried sending the variable during chat.load() as prescribed, but since the postcode comes from a user input field, it isn’t available at page load — so that approach doesn’t work.
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!
