I am trying to create a chatbot that when chatted up gives the user a list of options on what the user wants eg A.check account balance B.Send money, then when the user enters A, the online chatbot should reply that particular user with another set of options eg if the user replies with B(Send money), the second set of options should be which bank do you want to transfer money to A.standard bank B.Union bank etc, how do I make it so that when the user enters A, the onlin chatbot will the know the particular question that A belongs to, the first question or the second or the third
In building the chatbot, I tried giving every single option a unique letter so that I can check for what to reply when given that specific letter, but then the sequence of actions will be disordered
Related
I have an idea of doing a back office for my website. The problem is that, when I introduce a user who has, for example, two roles, I want the user to choose the role to work with, but I can't figure out how to do that. I've tried so different things such as putting the two roles separate with commas in MySQL and separating them in PHP but it didn't work.
let say you have a user table, and a user can have multiple role.
you can create a master table for role ( let say roles )
you can have a field on user table say user_roles -> it can have values like 1,2,4
note:- there should not be gaps between the numbers / comma
on the front-end you can take a mutiselect / tags UI element to input role for the user.
to fetch the role of a user at server side - you can use explode() + in_array() to check the role if exists
comma separated example
EDIT:-
It requires validation when adding roles ( ie: which user's role is allowed to select when already selected specific types )
For authorization, the user's roles should be added to the session :- this will help when allowing the user to do tasks he is allowed to do.
you can take a third table to maintain user's roles ( as suggested by #ADyson ), this will help if you want to join tables based on user + roles but you will need to join roles table for getting user data when starting session for the user.
1. What I have done till now
I added reset password functionality in my project in which user gets the link in their respective email. I used user's hashed password as its secret key to make the link ONE TIME USE. So if the user change his password once than the hash changes and also the secret key making the token verification invalid which in turns makes the the link ONE TIME USE. As I used user's hashed password as its secret key I also have to pass user's _id with the token in the link so that at the time of verifying the token first I fetch the user's password hash with the help of the user's _id that I passed with the token in the link.
2. What I want to do
Now it's time to add email verification functionality to my project and I am not getting any idea of how to make the verification link as one time link. And what if the users request multiple times for the email verification and I generate that many link and send it to the user's respective email.
3. I thought of doing this
I thought of creating a database for email verification and insert the user_Id and token to that database each time the user requests for the verification and once the user click any of the requested links I make the user verified and delete all the token associated to the user's user_Id so that when the user clicks any of the link or the same link again the email is already verified and token is deleted so I can response "Invalid Link or Request" to the user.
If the no. 3 is a legit mechanism I will implement same to no. 1
If the above mechanism is legit and good to go I would like to implement the same for my password reset functionality so that I no need to use user's password hash as the secret key and also not pass the user's _id in the link
Please also give suggestions if these both functionality can be done in a different way
How do you pick a random user from a server that a bot is in?
For example, GiveawayBot randomly picks a user in a giveaway. How can I implement that but without having to click on a reaction for the giveaway?
Also an example, #r in a command in Minecraft.
Array.from(message.member.guild.members)
This will get you an array of all members in a guild (with their id). I would recommend doing something else as it would take a lot of space to store larger servers in cache but it's up to you.
After doing so you can make a random number generator from 0 to the greatest amount and you will get an object of the user back when indexed, with the id as the identifier.
I create something like chat, I know how to send messages to all users in room with(sails.sockets.broadcast(...e.m)) but can't understand how to send message to one user(I think chat between 2 users), when second user send message to the first user, first get the sent by second, but when I create 3 users, and when the third user send message to first - the second user too get that message, how can I avoid this. Who knows how to do it?
Basically what I need is to return the gender of each friend who is in the feed
The following does not work:
gender is covered by public_profile permission – so you need to get that from every individual user first, before you can access it.
Without those friends becoming users of your app and granting it permission to access their basic profile information, you won’t be able to get this field.
Plus, the gender field will only return a value, if the user has chosen one of the “traditional” settings, male or female. If they entered their own custom value (which Facebook made possible a while ago), then the gender field will just return an empty string.