How to persist data between triggers & main flow
# 🤝help
s
Our use case: We want to send data from a bot that is embeded in web page, and then use that data later in our main flow. Possible solutions First approach is to do something like this :
Copy code
window.botpressWebChat.sendPayload({
            type: 'text',
            text: 'Some random text',
            payload: {
                   'myData': 'awesome'
            }
   });
The problem here, is that the user sees a message, sent by the bot. We'd like to avoid that. 2nd approach : we tried to do the same using triggers :
window.botpressWebChat.sendEvent({ type:'trigger', myData:"awesome"});
The issue Once the trigger is executed, we collect the payload & store it in a session variable. But it seems that the bot doesn't recognize that session variable inside our main flow. Question Is there a way to store/create some data with a trigger, then persist it and use it later in the main flow ?
m
Hey there, not sure exactly what you mean by the user sees a message sent by the bot. But in any case, have you checked the following resources? https://botpress.com/docs/cloud/studio/variables/

https://www.youtube.com/watch?v=2THIkCcehHM&t=1s

s
When I use this :
Copy code
window.botpressWebChat.sendPayload({
            type: 'text',
            text: 'Some random text',
            payload: {
                   'myData': 'awesome'
            }
   });
My website visitor receives the message "Some random text" when he interacts with the bot. Which is normal, but I was wondering if it's possible to not send a message, but still manage to transmit a payload to my bot.
m
Sounds like a session variable should be able to handle this. Did you take a look at the documentation/video and check if you were using one in the correct format?
61 Views