https://discord.gg/botpress logo
Storing variables
# 🤝help
m
Hi. I am looking to generate a six digit number (one time password) that I can send to an SMS service for user authentication. I have set the workflow variable called "OTP" up and made it a string. For some reason, the variable not stored. No error I can see either. workflow.OTP = (Math.floor(100000 + Math.random() * 900000)).toString(); What might I be doing wrong here please with storing the value? Greg
l
can you share your code?
m
Hi Lijo. Thankyou for responding. This is the only line for this action. When I display the text to console, the formula delivers the right information. I think it's the way it's trying to save it to the variable. Under Workflow there is a single variable called OTP with String content. Greg
l
did you try user variable?
for an action a zod schema should do as well
m
Hi Lijo. I understand that a User variable is one that is "more" permanent, and I dont want any of the variables to live beyond the session (last term correct?). Other variables in the like collecting the name etc work fine, I just cant seem to do it from within an Action script. Greg
l
@mysterious-fall-54669 - Workflow variables are local to the workflow, while user variable are available across workflows for that user. they both behave the same, their scope of access is different. user variables do not live beyond the session of that user
if not try zod schema
m
Thankyou for educating me on that one - every bit of info helps. 🙂 I will look into Zod schema and also try the User variable declaration. Thankyou Lijo
3 Views