Hello @Juste and all can you please help me?
i want a button in action.py file for custom use?below i show you a example?can you please help me for that .i search all topic and blog but i cannot found anything.Can you please solve this problem?
Ex:-
user- give me mobile no of rohan
bot:- There is 2 rohan in database
rohan shah
rohan pandya
->i want buttons for employee names, if i click on that employee name button it should give me details of that employee on click event of that button.
Thanks for the help.
You can do this in custom actions. I believe you need to fetch that data from your DB. When the user asks give me mobile no. xx, first you need to capture the name of that person in a slot.
Then in your custom actions make your API call to the DB or however you want to fetch the user details.
Use
# Fetch the data and store in the format used by buttons.
buttons = [{"title": "Rohan Shah", "payload": "/intent_name"}, {"title": "Rohan Pandya", "payload": "/intent_name"}]
dispatcher.utter_button_message("There are 2 people with the name Rohan:", buttons)
Once the user selects a button again trigger custom actions and fetch his details.
Thanks you so much @srikar but how we can trigger on button click event?and in the buttons title "Rohan Shah " is static name here i want a name who i got in person slot. so i can do this?
First, capture Rohan in a slot and query your DB, then create buttons with all the search result matches, then on-clink, send that name as a message or set the slot in /inform{“person”: “The on-click name”}.
Again use this name to fetch this particular user’s details.
Yes, you have to create the buttons using the data you fetched from your DB.
actually i want to make hr chatbot for my last sem project and i use SQLite database.so i also feeling stuff in insert employee detail in database if you know then also help me for that.Thanks in advance @srikar_1996.
I haven’t used SQLite with RASA. All my data is in mongoDB, so I use APIs to fetch data from my DB. But I believe it is the same approach for any database. Query user search -> display buttons -> again query with specific user details.
yes yes @srikar_1996 it’s similar to mongo db and now i got it how to create button. but now problem in insert data with validation. i mean like if hr want to insert data then first bots want name like rohan, then bot ask give a number then hr enter number, then bot ask give email id , then hr gives a email id. now i want all this data into database.i successfully insert employee name into database .i train all name into nlu.md file and then store using slot value.so its only for name.but now if i want to fatch all detail and insert into database.so how i can do this? everytime i train name ,mail,mobileno in slot and fatch that slot and insert?or any other method for that that store multiple slot? i see form action but i cannot find good example.and also form action may not provide validation.so how can i do this?Thanks.
The best way to do this is formActions. Since you’re taking many details, you can ask them in order and finally insert all of the user details at once. You can do a lot with form actions. It also handles cases where the user enters all the slots in one utterance, for eg.: his name is xxx and email is yy then the form automatically captures email and name slots. There is a required_slots() method in forms.
FormAction does provide validation. Check this documentation, a very good description on how to use forms: forms
You need to provide the validations in the validate() method.