Given below is my payload to rasa server:
{
“sender”: “shaurya”,
“projectname”: “RASA”,
“message”: “list users in Claim_Center”
}
I am able to fetch sender and message from this payload, but not projectname. How to fetch these keys from custom payload?
stephens
(Greg Stephens)
October 16, 2023, 8:46pm
2
You can pass the data on a metadata key. You can then retrieve the metadata in action_session_start on the session_started_metadata slot. An example is shown here .
shaur.sum10
(Shaurya Suman)
October 19, 2023, 11:54am
3
Thanks @stephens . It is working as expected.
josejulio
(Josejulio Martínez)
October 19, 2023, 12:42pm
4
Also, something I didn’t found on the documentation (maybe i didn’t search properly) is that the metadata can obtained in each event.
class MyAction(Action):
# ....
async def run(
self, dispatcher: CollectingDispatcher, tracker: Tracker, domain: Dict
) -> List[Dict[Text, Any]]:
tracker.events[-1].get("metadata").get("your-custom-data")
You only need to make sure that the event is an user event. We get the last one by running something like:
def is_user_event(event: Dict[Text, Any]):
return event.get("event") == "user"
latest_user_event = next(filter(is_user_event, reversed(tracker.events)), None)