Access to the sender name from rasa

Hi, I use RASA for a project with my own graphical interface. So, to join the chatbot I send a message with the following method :

I need to get the sender value (here “Rasa”) to use it in my custum actions scripts. How can I do it ?

Thanks for helping

I was also facing issues in a similar vein. I resolved it using HTTP API.

I created a slot to store the sender’s name and fired the above-mentioned API to set the slot as the first thing while starting the bot.

  var http_set_event = "http://localhost:5005/conversations/tonysingh/tracker/events"
  var event_xhttp = xhrCreator(http_set_event);
  var event_json = {"event": "slot", "name": "sender_name", "value": "tonysingh"};
  try{
    event_xhttp.send(JSON.stringify(event_json));
  }catch (error) {
    console.log("Sender's name could not be set in slots.")
  }

Hello @yahiaouik,

You can get the sender by using this line of code:

sender = tracker.sender_id
1 Like

I am using BotUI js for my UI. What are you using for creating UI ?

Are the sender_id and the conversation_id same thing?

I’m not sure about the conversation_id since i never touch it. But the sender_id stores the ‘sender’ value in the HTTP request which OP mentioned above. Also the bot seems to keep track of a conversation using the sender_id, which means if you using multiple browser, but with the same sender_id, the bot will handle their messages as one conversation. Different sender_id = different conversation. Does that answer your question ?

So the conversation_id used in HTTP API is same as sender_id.

Yes, after checking again, it appears that they are identical.

If I pass another parameter friend in the message like this

{
"sender": "tony",
"message": "Hello",
"friend": "fuih"
}

Can I access the friend parameter from tracker just like we can access sender_id ?

1 Like

I don’t think you can, but i’m not 100% sure. The tracker object seems to have a list of predefined attributes, sender_id is 1 of them so you can access that through tracker. It does not seems like it can create new attribute depends on what you pass in the request. But since this is not really a hard thing to test, i suggest you try it and see how it goes, it shouldn’t take more than 5 minutes :smiley:

The thing you need is a custom channel. Within your own channel you can define which data you send from your frontend to Rasa.