Getting values of customData in custom action in python

How could I get the value of customData in our action files. I have tried so many methods but nothing works, I want to get userId value from running rasa service


please share the code how to do this, I have read many blogs but no one has shown how to do this

1 Like

I’m assuming this is with respect to socketio. I don’t know if this is the correct approach but here’s what I’ve done.

In your virtual environment, find the following file: rasa\core\channels\

In this file, go all the way to the end where you should find the handle_message() function. Within this function is the following line:

        message = UserMessage(
            data["message"], output_channel, sender_id,

Replace this line with:

        message = UserMessage(
            data["message"], output_channel, sender_id,
        , metadata = data['customData'])

Now in your file, store the tracker state as:

val = tracker.current_state()

If you print, this out, you should be able to see the metadata in the val variable. Now you can do whatever you want with it.

Thanks a lot Gaurav , yes it was w.r.t socketio. I’ll try & post you back if this is good enough.

1 Like

yes man it worked! btw, I didn’t had metadata parameter in my UserMessage function since my version of socketio was 4.0.0 & engineio was 3.8.1, but I passed customData in senderid parameter (not a good approach) and used it accordingly without any repercussion. Thanks a lot for the help man!

1 Like

why am I not able to find the files rasa\core\channels\ in my virtual environment path! I am using rasa 2.2.0

also, what are the other ways of reading customData values in custom actions?

I have changed as you mentioned, but not working for me, using
rasa 2.5.1
rasa-sdk 2.5.0
python-engineio 4.1.0
python-socketio 5.2.1