How to get a specific field from REST API Request

I have created my custom actions , DB connectivity etc. Everything is working fine when I use RASA-X or rasa shell.

Now I am in process to make a custom UI for which I am using Rasa REST APIs. I am able to get response from GET and POST


Response :

Now my question is , in my Custom Action I need to extract the “sender”:“SAURABH.SINGH” so that I can check in DB as who is enquiring to get proper response. Currently I have hardcoded the sender . Please let me know how can I get value from REST API request in my

Hey @sks6184, good question! Every action gets the tracker parameter. If you use the tracker.latest_message, it should contain all of the message parameters including the sender_id.

Many thanks Ella for this …let me try it out.

Hello @erohmensing,

I was getting some error , Is there any documentation available for all the functions available in tracker ? I checked Tracker but seems its not exhaustive.

Any where else I can find the documentation ?

Best Regards , Sunny

Agreed, it’s not the most well documented at the moment. We are currently working to update our documentation. In the meantime I’d recommend going straight to the source and looking in the tracker class of the SDK: rasa-sdk/ at master · RasaHQ/rasa-sdk · GitHub

@erohmensing Great !! Let me check that …

I think you cannot access any custom information send on the REST call except the sender_id. Everything else seems to be neglected in the tracker object. I am also looking for a way to access custom information (e.g. user name and access token) through the tracker so I can make a REST call in a custom actions to e.g. store data extracted from the chat into a user profile.

Is there any easy way to fix this or must it be a change in the REST channel class and tracker class?

See a similar issue here: Customing user information in rasa

I am checking the code in github and tried few things : Even the sender_id is ignored in rest. I tried

But I was able to get the user message in while using rest.

I will be trying how to get it and will upload if there is any success as getting sender_id is very important if we want to build rest based system.

I now I am successfully getting user id in my To make sure we get correct user id, JASON key should be properly named as “sender” . You can see in below code I am able to send user_id as key “sender”. If I use any other key like “sender_id” “user_id” it doesnt work.

My code:

Yes, you’re correct. Here you can see in the curl request that sender and message are the required fields. This is a little unclear. We’re planning on making the REST channel better documented as its own channel rather than as a foundation for creating custom channels, since it’s a good first step in channel testing and creation.

@erohmensing … many thanks . Having open source bot development platform itself is great effort.

It is. Thanks for the appreciation! We do continue to try to make it as easy to use as possible though, and feedback of any kind, like this, is helpful in that regard!

@erohmensing Thanks for your reference to the custom REST connector. I think I understand now how to send custom information from the front end to the custom actions with the metadata field and access it through the tracker.

Do you know how to do it also the other way? I want to send some custom information (e.g. a collection of hotel results I found that I got from an external API based on the slots) to the front end, so that it can use this data to display the results in another UI component in the screen apart from the chat only.

Sure, you should look into dispatcher.utter_custom_json(), which is used for sending custom json payloads. You can either embed that info in the custom payload directly and pass it along to the UI for parsing, or you can use that method to get the info to your output channel, parse it where and send separate requests to the UI from the output channel.

The code for the dispatcher methods is in rasa-sdk/ (I would link but I’m on mobile)