T
Typebot•2mo ago
Anthony

Where are Typebot variables stored?

I want to edit the value of multiple variables at once in a Script block, but for that I'd need to know if/how to set a Typebot variable's value within a Script block, as I couldn't find where they are stored. I haven't seen them being stored in localStorage, in window.Typebot or anywhere else. P.S. I wouldn't need to know that information if a specific feature were implemented: An "Auto Jump back" feature, which would dynamically jump back to the previous blocks group when the group it jumped to has finished its execution, as previously requested in another post.
7 Replies
Hall
Hall•2mo ago
Someone will reply to you shortly. In the meantime, this might help: -# This post was marked as solved by Anthony. View answer.
Anthony
AnthonyOP•2mo ago
In my flow, before every text bubble, I am manually setting a variable to a custom value, which is the name of the character speaking and their current emotion as one string. From this variable, I then update the value of 2 other variables: one that grabs the character name (first word of the previous variable), and another that returns the custom avatar URL corresponding to that emotion for that character. Currently, I have to duplicate these 3 blocks every time, and I'd like to have a function-like group that would take care of updating the 2 variables from the first one I manually set.
No description
Baptiste
Baptiste•2mo ago
Anthony
AnthonyOP•2mo ago
Ooh, it seems like I had missed that. Nice! So I could combine all of this into one Script block 👌
Anthony
AnthonyOP•2mo ago
Though there is no way to have a function-like blocks group, that we could go back to as we need, right? Consider the following goal: Every time a name-like string is asked to be inputted by the user, a Name validation function/groups of blocks should be executed, which should continue the flow normally if the name has passed the regex validation, otherwise display a specific text bubble/message. Imaginary flow to illustrate it:
No description
Anthony
AnthonyOP•2mo ago
Of course, the flow on my screenshot won't work properly with the current Jump blocks, but it illustrates my goal, which is to execute a set of blocks on-demand, and go back to where it was called after it finished executing, allowing for a DRY (Don't Repeat Yourself) flow, aka not duplicating the Name Validation group every time I need it but simply "calling it", much like a function in programming. So the desired behavior with the above (incomplete) flow should be: 1. Bot asks for the user's first name (assume it is then stored in a variable) 2. The first name goes through a Name validation check script: - if the name passes the validation, the execution continues, meaning it jumps back to the end of firstName Input and in our case goes over to the next group of blocks dogName Input - if the name doesn't pass the validation, it could display a Text bubble and Jump to the original name input (which should be dynamically specified, given the expected behavior) 3. Bot asks for the user's dog's name (assume it is stored in a variable) 4. Same as 2. but for the dog's name It is currently not possible to do that with the current state of Typebot, right? Just to be sure Maybe I could store a function in the client-side window object, that I could call on demand whenever I need it 🤔
Baptiste
Baptiste•2mo ago
You could instead of using the Jump block, use the Typebot link block set to "Current typebot", it should work. This is what I did in the Skin Typology template I am implementing a new Pod feature that will do exactly this, take specific inputs and can be reused by any of your bots

Did you find this page helpful?