https://discord.gg/botpress logo
global variable
# 🤝help
c
Hello @everyone Can anyone help me how to use the global variable in the botptress? I am new to this and have made the complete bot flow for my company chat support - but facing some issues with global variable, not able to find any detail around the same. also documentation is not clear enough about the same. Can someone help me with the how to use the global variable? one info I found was using the end node and pass alll the variable to the end node to use to reserve it state, is it correct?
w
Hi @clever-air-9139 , what do you mean by global variable ? Variable acessible accross all workflows for one single user -> user variable Variable available for all users -> Bot variable https://botpress.com/docs/guides/studio/interface/variables#variables
c
Like I need some variable that I can pass to different flows - for example is a user enter from x flow and get the info and in the same way if that same user enter the same flow from different flow - the flow is not working reason: cause when the user enter from x flow it worked cause it fetches the data and stores the same in the variable (I am using workflow variable) but when the same user enter that flow from different path those variable goes to null even though I am passing the same variable to that flow as well and thus my flows break there. How should I fix that?
l
check the documentation that @wooden-beard-40210 shared it has the details variables and its scope. Additional you can also pass values from workflow variable to another workflow variable when call the workflow Option 1: in your usecase workflow variables are limited to a workflow and as you need to pass them to the new workflow you can either use user or session variable Option 2: when calling the workflow pass the value of the workflow variable and capture them in the called workflow and assign it to a variable in the workflow (check the images) https://cdn.discordapp.com/attachments/1370330034224631859/1370359085178028113/image.png?ex=681f35d9&is=681de459&hm=5b28024efc9fbf761f975efd7bc65445f16fadf45026e0c3d9a9941cf1581c97& https://cdn.discordapp.com/attachments/1370330034224631859/1370359085681082388/image.png?ex=681f35da&is=681de45a&hm=f1b71911e0427c9dd8dc53177d3a2575e730a4c96d788e5106acb7bb4764060b&
c
This is exactly What I am doing - but still facing the same issue
let me share an screen recording for a a better understanding what I am trying to solve here?
Here you can see in the video When i trigger the bot it goes from track or manage order -> where I select the order and it fetches and store the value in "*selectedOrderDetails* and then I pass the same variable to my another flow of PostDeliveryIssues in that flow when I enter the variable values goes to null and my code breaks and It entered into and error. https://cdn.discordapp.com/attachments/1370330034224631859/1370363846199345182/Screen_Recording_2025-05-09_at_5.01.14_PM.mov?ex=681f3a49&is=681de8c9&hm=90cc41318dff163255c171dcfe16c908c4699be9573023d1914a22c658e4997e&
l
it is evident that in your parent workflow the value was not set hence it was not passed to the next workflow
c
Why I can't store the output in a conversation variable
l
You should be able
w
there's an error in your execution card, look logs to see error details
c
Thank you @everyone
5 Views