Can we send other than sender_id to rasa..... is it possible to send like email and employee id in my JQuery AJAX with REST Channel

Dear Team,

I want to send/capture the email and employee id along with the sender_id to the tracker using JSON.stringify() in my AJAX Rest API.

Here is my constants.js code snippet:

const action_name = "action_hello_world";
const rasa_server_url = "http://localhost:5005/webhooks/rest/webhook";
const sender_id = '12345678';
const sender_email = '';
const sender_name = 'Kondru Ravi Kumar';

Here is my Rest API Call with AJAX:

function customActionTrigger() {
        url: "http://localhost:5055/webhook/",
        type: "POST",
        contentType: "application/json",
        data: JSON.stringify({
            next_action: action_name,
            tracker: {

And in my

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"
            text="Hello <b>" + (emp_name) + "</b> Thanks for choosing to chat with me.")
            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.

Can someone please help to fix this. Thanks

Best Regards, Ravi

The message you send to the server should be in the following form:

{sender_id, message}

You could store the user information in a database and look for the email and name in a custom action.

You could also use a trick :joy: Put the three info in a string and pass it all to sender_id. Then you dissect the Id in a custom action.

  sender_id: "1||John Doe",
  message: "Hello!"
sender_id = tracker.current_state()['sender_id']
emp_id, emp_email, emp_name = sender_id.split('|')

Hi @ChrisRahme Thanks…

But i am having MongoDB configured for storing sender_id treating it as a users what they are really doing with the bot.

So in this case rasa stores the entire sender_id along with the full string which we are passing in it. So this is where i am facing the issue.

Any idea on how to fix this?

Best Regards, Ravi

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”?

Hi @ChrisRahme okay let me rephrase 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.

Hope this clarifies. Thanks

Best Regards, Ravi

Ah okay, I understand.

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?

1 Like

Okay, now i understood and got an idea.

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

Best Regards, Ravi

1 Like