Share feedback, ideas and get community help

Updated 2 months ago

Persist variable value after closing session

At a glance

The community member is asking if it's possible to persist the value of a variable even after the user reaches the end of the flow and closes the session. They want to set a variable firstAccess=false in the first interaction, and then check if firstAccess is false when the user returns later to provide a personalized greeting.

In the comments, another community member suggests that the issue might be related to the resultId not being passed correctly to the startSession function, and that a new resultId is created for each new session. They suggest that the community member would need to change the code to keep the resultID the same as before.

Another community member recommends using an external database like NocoDB to store the variable values. A third community member confirms that using an external database would be necessary for now, and mentions that the ability to query existing results is planned for the future.

There is no explicitly marked answer in the comments.

Useful resources
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.)
t
v
B
4 comments
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?
hi!
maybe you can use an external database like nocodb
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
Hey!
Thank you for the answers πŸ™‚
Add a reply
Sign up and join the conversation on Discord