Bot asking user's info only once.
# 🤝help
s
Is there a way to make my bot for example, capture a user's name and not ask it ever again when it is the same user? Because if I tell my bot my name and then come back a few hours later, it asks again
I'm having this problem with webchat bots
s
Tyy
q
Some older tutorials here that solve the same or similar problems might be difficult to find.
s
but should my conversation start with the expression cards?
Like if the user ends the conversation and it starts back again, how is the bot gonna know that the user already exists if he/she hasn't inputted any name in this new conv
s
man
how tf do you come up with all of this
i'm having a call with a client tomorrow
and this is all that i'ts missing
s
and how does it recognize that the user is new?
q
It first checks if the user variable called 'username' is empty. If so, it asks for the name and stores the name in that variable. And the next time the same user visits with the same device, it checks the user variable again, and now that 'username' exists, it greets that user. After verifying that, you can continue with your normal chatbot workflow. https://cdn.discordapp.com/attachments/1220364417238040697/1220372347698155531/image.png?ex=660eb351&is=65fc3e51&hm=7be91164a38b195d39b3e2fa7578883c00d0761e142a39f5a91eaf459cb2997d&
s
and if the user idk, comes back a few days later it still works, right?
q
Yes. User Variables User Variables are variables that follow a user between conversations. For example, if a user speaks with your bot on Monday and Wednesday, any user variables set on Monday will still be accessible on Wednesday. User variables are great for storing data that doesn't change very often, such as: Storing users' personal details or id numbers 1. Collecting tags or notes from past conversations 2. Storing extra flags like VIP customer 3. Saving language preferences Creating a User Variable 1. Open up the Variables tab and navigate to the + icon in the Variables section. 2. Change the scope to User, select the Data Type, give it a name, and click Add to create the Variable. Using User Variables Once the User Variable is established, employ {{user.variablename}} or @user.variablename to render it in a send message card. https://botpress.com/docs/cloud/studio/variables/#user-variables
This great idea first came to me from 🦸‍♂️ @wide-oyster-38514 and @jolly-policeman-82775 🫡 So I have been building my own versions of these, or sometimes a small part to their bigger project.
s
well thanks a lot
it was really helpful
q
Let us know if you can make it work for your use case and client 🛠️
s
last question: Is the execute code card neccessary?
j
Huh
Who tf ping me
s
@quick-musician-29561
j
Oh..
Wass good devmik
Itd easy to come up with stuff like this lol.
I used quary kb as a recommendation system lmao
Nobody has done this before
s
how???
j
Lol
How what?
s
how does it work
j
With prompting
Hell ton of prompting
So much prompt i hate to say the word prompt
q
Good that you pointed this out! 🦾 🔍 Also, note that user variables work after you publish the bot, not in the Emulator (which always starts as a new user).
c
@quick-musician-29561 is just AWESOME. Thanks for sharing your 🧠 with the community 🙂
q
Did you notice this earlier message: "Also, note that user variables work after you publish the bot, not in the Emulator (which always starts as a new user)."
s
yes this is not in the emulator
i published the bot then i tried it on a different tab
q
Can you try with different browser?
for me it works like that
Maybe it recognizes a different tab as the same user, but a different browser as a different user.
s
i tried nothing changed
when i try on the browser i always used to test it, it says welcome back (my name) but on a different browser it just prints welcome back and the name is just blank
q
Okay, good to know! 🫡
I have to double-check those again
We have built this for many chatbots and projects, and it used to work. This demo I just built quickly, so maybe there is some mistake that we can now fix, thanks to you! 🛠️ 💎
s
No problem and if you find a solution please share it here, because I have to submit this chatbot very soon but I need to fix this issue first
q
I built the bot again and tested if, for me it works 🛠️
when I come back
I tried another browser (which is considered as a different user)
s
I didn’t try the file you sent yet but i think i found the issue i was facing It was that the user.name variable stores data of type object which stores names in arrays When i used a string data type it worked
But thank you so much for your help i really appreciate it
q
I'm happy to hear that it works now! 🛠️ And yes, for others who try this: Raw Input card result should be stored in a user variable, Type: String in this case. If you want to use the Person Name card instead, then its Type: Object.
g
thanks
i think it should work now
Oh it didn't work
8 Views