class ActionHelloWorld(Action):
def name(self):
return "action_hello_world"
def run(self, dispatcher, tracker, domain):
emp_id = tracker.current_state()['sender_id']
emp_email = tracker.current_state()['sender_email']
emp_name = tracker.current_state()['sender_name']
button_resp = [
{
"title": "Looking for documents in delta",
"payload": "/lookingfordocumentsindelta"
},
{
"title": "“How to” questions related to Delta",
"payload": "/faq"
},
{
"title": "Have Feedbacks",
"payload": "/feedbacks"
}
]
dispatcher.utter_message(
text="Hello <b>" + (emp_name) + "</b> Thanks for choosing to chat with me.")
dispatcher.utter_message(
text="Please choose what you are looking for from the list below.", buttons=button_resp,)
return []
I was trying to read the above parameters like below in my actions, but i can read only sender_id and not the other two parameters like email and name. I can read only one of them. If i execute above code it is saying KeyError : from my actions server logs.
Sorry, I don’t understand. You’re having an issue looking in the database for information because of the sender_id format?
What do you mean by “treating it as a users what they are really doing with the bot” and “rasa stores the entire sender_id along with the full string which we are passing in it”?
We are using the sender_id to identify the unique users with an employee id.
So here my sender_id will be the employee id.
And we have also configured MongoDb for tracker store.
Hence, when a user clicks on the bot, by default we sending the sender_id and obviously which is our employee id. And it is stored in tracker store. Fine with this.
But, i want to wish the user with his name as we have initPayload() configured for bot to respond firs and instead of his id. So in this situation we wanna send emp name and his email as well along with the sender_id.
You probably have a database, unrelated to Rasa, with a list of employees, no? You can query the database to look for the name of the employee (from JavaScript you can do so with Ajax or Axios).
Or, if’s too much of a hassle querying a database from JavaScript (which it is), since you’re getting the employee ID and using it as sender ID, I guess you’re doing that by getting it from the interface. Isn’t there a way to do the same for the name? If not, isn’t it possible to add a hidden HTML element containing the required data?
Then, after getting that info, you can pass it as an entity in your payload.
Again, can’t you just query the employee database from your Rasa custom action?
what i will do, any how we are getting sender_id which is our emp id. so, with this, i will write a piece of code just to connect with our LDAP along with a select query by using the sender_id in our custom actions and get the user details. I believe it works. Thanks