T
Typebot•8mo ago
theervilha

Persist variable value after closing session

Is it possible to persist the value of variable even after the user reaching the end of the flow (it means, closing session?) Example: I want to set the variable firstAccess=false in the first interaction If the user come back two days later, I want to use a condition to check if the firstAccess=false or not and provide a personalized greeting: "Hey, good to see you again :)" (I tried to set a result variable. Whatsapp channel.)
5 Replies
Hall
Hall•8mo ago
Someone will reply to you shortly. In the meantime, this might help:
theervilha
theervilhaOP•8mo ago
Looking at the code, on packages/bot-engine/src/startSession.ts there is a function getResult which will try to find an existingResult using the resultId, and then it would get its existing variables. But I noticed two things: - startWhatsAppSession doesn't pass the resultId to the startSession function - Whenever a new session is created, a new different resultId is created So, I think the existing variables won't be found because the resultId won't exist on database I would need to change the code to keep the resultID with the same value as before, right?
vini_zaan
vini_zaan•8mo ago
hi! maybe you can use an external database like nocodb
Baptiste
Baptiste•8mo ago
Indeed you'd have to use an external DB for now. We will soon be able to query existing results: https://github.com/baptisteArno/typebot.io/issues/499
theervilha
theervilhaOP•8mo ago
Hey! Thank you for the answers 🙂

Did you find this page helpful?