VIP users?
# 🤝help
f
Hi everybody, i'm having some issues with a bot. The system is built to ask the user for a keyword that's gonna act like a password to enter the bot. However, when the user writes the keyword, i want the bot to greet the user with his name. How do i make the bot check in the tables for that keyword and answer the proper name of the user? I'm using it for VIP users or frequent clients. Thank you so much for the help! 🙏
q
I can help you build this 🛠️ Does all the users have the same keyword they can use to login, or does every user have a different password? If they all have different passwords they use, after checking if it's correct, you can filter the KB table with that data and get the user's name. If they all have the same keyword, then after checking they provided the keyword, you can check the name from 'user variables' where you have stored their name when using the chatbot the first time.
f
well that's great, man. i could really use some help in this. Each user has a different keyword and actually they create the keyword, so they don't have to deal with some random number or anything like that cause that's really forgettable hahaha. so i decided to give them the opportunity to create it with a word they'd remember. anyways, what i don't really understand is how i am gonna filter the kb to find the name? Don't really know how to achieve that. Thanks a lot
Development ideas, ask a keyword and if they provide it wrong 3 times, end the conversation, etc.
Most important thing is the Find Records card, make sure you - connect it to a correct KB table - filter the records correctly - store the result to a correct variable
f
Devmik is a real hero!🦸‍♂️💎
q
I never trust my projects or ideas until Decay has commented, debugged or approved them. So now we're good to go! 🔥 🚀
f
Hello everyone! WOW, that was not only fast but extremely generous of you. Thank you so much for your time, really. it means a lot. i'll try it out right away and let you guys know! Cheers 🤘
One quick question: if i enter my password and enter the bot's info, how can i make the bot fill the information (name, email, phone) for me automatically now that it kinda knows me. I mean, i want the bot to recognize me when i enter the bot on another day to make a reservation. Something like: Welcome back, Mr. XXXXX, i already have your main information. i'm just gonna need the new date of the reservation, the time and the number of people. I'm getting closer and closer every time but i'm having trouble getting the sync correctly. THANKS!
q
Then you can use 'user variables' instead of 'workflow variables'
https://botpress.com/docs/cloud/studio/variables/#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."
first link might be more related to this.
f
i don't know how to assign the variable to the raw input card. it only accepts workflow variables. am i doing something wrong?
look a bit hard for me to understand. could you help me through this pls?
f
yes, but when i do that it doesn't show in the variable list :/
f
no, i mean in the options of the card itself. i can see them in the list on the right side of the cloud but not in the input card. it seems like it's not available
q
If you mean Raw Input, for me it shows like in the pictures above
f
ok, i got it. i just works on a new card. if i were to replace it, does not work.
q
and there I can select all workflow and user variables
Ok, good to know!
f
that's right, thanks a lot. working on it to see the results. i'll let you know.
Hi there! tested and everything works perfectly. thank you @quick-musician-29561 for sharing that talent!
q
@fresh-motherboard-89246 Great! 🔥 🛠️ 💎
@delightful-yacht-58732 maybe this gives you some ideas too ⤴️
d
Yeah thanks 🤩
@quick-musician-29561 For example, the database is a google sheet and I update this file in real time using Make. I want to create private sessions for Mr X, who is valid for 30 days, but at the end of the 30 days his name is deleted from the database and he can no longer connect.
@quick-musician-29561 Did you understand what I meant 😜
f
@quick-musician-29561 hey bro, i have another question for you or your friends. i'm in another part of the flow (now that the one you made is working great) and i'm syncing a Google Sheet that has the availability of the hotel written in a cell. Whenever that cell gets updated, the table in the bot knows it. but my question is, how can i make the bot know when the availability is full in order to reject the reservation and offer the chance to re-schedule the date or something like that? i used a tutorial video from CodingDecay which is a great developer by the way and that's working fine as gold. now i just need to make that little adjustment so the bot keeps updated with that info. The video is:

https://www.youtube.com/watch?v=92RxMwY_8Og&t=145s&ab_channel=CodingDecay

if you need to get some context. Thanks a lot man!
f
Thank you for the kind words 😊 I take it that you have dates in your Sheet. Are these the available dates or the booked dates?
f
they're actually the booked dates, which means the amount of rooms that are not available.
q
I hope so 😅 You can compare when the user was created (from the KB table) and what the time is now, and check if the difference is less than 30 days (they still have access) or more than 30 days (they don't have access anymore). I'll add that functionality to this same 'VIP users' bot if others find it useful too.
Add a new Execute Code card
Copy code
js
const currentDate = new Date()

const userCreatedAt = workflow.recordsFromTable[0].createdAt
console.log('USER CREATED AT: ' + userCreatedAt)
const userCreatedAtMs = new Date(userCreatedAt).getTime()

const differenceMs = currentDate - userCreatedAtMs
const differenceDays = differenceMs / (1000 * 60 * 60 * 24)

if (differenceDays < 30) {
  workflow.sessionValid = true
} else {
  workflow.sessionValid = false
}
then a new Expression card to check if the user was created more than 30 days ago (no access anymore) https://cdn.discordapp.com/attachments/1233611875003142205/1234366536806961202/image.png?ex=663078eb&is=662f276b&hm=f69cdc08282a134041457e5f36763577771b4204147d1f44d82ae9c99b17756c&
if you want to test the functionality faster than waiting a one month, you can change 30 days to 5 minutes by replacing this part of the code
Copy code
js
const differenceDays = differenceMs / (1000 * 60 * 60 * 24)

if (differenceDays < 30) {
  workflow.sessionValid = true
} else {
  workflow.sessionValid = false
}
with this
Copy code
js
const differenceMinutes = differenceMs / (1000 * 60);

if (differenceMinutes < 5) {
  workflow.sessionValid = true;
} else {
  workflow.sessionValid = false;
}
@fresh-motherboard-89246 🫡 I hope we didn't ruin anything with this little side task 🙏
"tutorial video from CodingDecay which is a great developer by the way and that's working fine as gold" I have also learned A LOT from Decay's tutorials and YouTube videos 🔥 🔥 🔥 🔥 🔥
d
@quick-musician-29561 Thank you very much 🤩🤯
f
hahaha not at all, man. actually, you guys improved the whole idea with this. awesome work! Cheers @delightful-yacht-58732 and @quick-musician-29561
a
even more interesting
f
Hey @delightful-yacht-58732! Sorry to bother you, man. Can you give me some hints on this one, please? I'm trying to make this work but not with the condition of 30 days. instead, i'm using a variable that determines a date that the user declares as the last day of his visit. how can i match up those variables if one is a number and the other is a date? i'm kinda stuck in that concept. Thanks very much.