https://discord.gg/botpress logo
#🌎general
Title
# 🌎general
b

better-eye-20248

07/02/2023, 11:26 AM
Is anyone building a telegram chatbot? I just built a chatbot on telegram, where at the beginning of the conversation some information are asked and stored in variables. The chatbot remember those variables for a couple of hours, but afterwards it tends to forget them. Does anyone have a solution for this?
e

early-train-33247

07/04/2023, 1:54 AM
Hey @better-eye-20248, what is they information you are prompting? If its data that doesn't change like user names, you can save them in User Variables, so they remain the same forever or until you change them
To add a user variable, go to the chatbot settings, and add a variable here
You can then write values to it using
ùser.variableName = ...
and read it with
user.variableName
To assign the value the user just typed in, create a Execute Code card after the Capture, with the code:
user.variableName = event.preview
It's recommended to do some checking though, to see if the value is valid!
And this works the same way for any messenger!
b

better-eye-20248

07/04/2023, 8:22 AM
Great value in this message, thanks a lot Guil! I’ll try to do it right away, hopefully it will fix it!
This one looks like working, thanks.
e

early-train-33247

07/05/2023, 12:23 AM
Good to know @better-eye-20248! 🚀