https://discord.gg/botpress logo
#🤝help
User variables
# 🤝help
f

flat-nail-33989

07/13/2023, 1:25 PM
Hi! How can we use user variables to store some information from api calling for a user and then use that same info again in other session, rather than calling the app again and again? I see user variables in chat settings, but unable to use them within the bot
a

acceptable-kangaroo-64719

07/13/2023, 3:15 PM
Hey @flat-nail-33989 we just updated our documentation on variables here https://botpress.com/docs/cloud/studio/variables/ Session variables might also be helpful for you too
f

flat-nail-33989

07/13/2023, 4:45 PM
Thank you so much for your response @acceptable-kangaroo-64719! Will check this out
h

helpful-kilobyte-18816

07/19/2023, 4:37 AM
@acceptable-kangaroo-64719 The documentation explains how to create a User Variable but nothing about how to populate it. For example how do I save a users name so that it can be used throught the conversation today, and tomorrow when they return. Can you explain pls.
a

acoustic-hair-60678

07/19/2023, 4:41 AM
hi londibob 👋 take a look at this vid. should have what you're looking for:

https://www.youtube.com/watch?v=ep6ZtVrxxv4

h

helpful-kilobyte-18816

07/19/2023, 4:53 AM
Thanks for sharing the video. As I understand the process is this : Step 1 : In Settings, create User Variable stype "string". eg. personsname Step 2 : Add users name to variable via capture card eg. John Step 3 : Output name @user.personsname The part that is not explained in neither the knowldegebase document or the video is Step 2, how to save a person name in the User Variable. In the capture card it wont let me add the User Variable to save the persons name. Not sure if Im doing something completely wrong or its a bug.
a

acoustic-hair-60678

07/19/2023, 5:37 AM
hey @acceptable-kangaroo-64719, any insight on how to get this done?
a

acceptable-kangaroo-64719

07/19/2023, 10:11 AM
For step 2, use a code card. It can be as simple as
Copy code
js
user.uservar = event.preview
To capture the exact thing that the user said.
h

helpful-kilobyte-18816

07/19/2023, 6:28 PM
@acceptable-kangaroo-64719 Many thanks that worked, you're a star! For a "no-code" app there's still many things that we need code for, and that perhaps a simple thing like this could easily be added as its own type of card called "add workflow variable to user variable". 🙂
a

acceptable-kangaroo-64719

07/20/2023, 10:19 AM
That would make a great addition to #1111026806254993459 !