Zeeshands
(Zeeshan)
November 16, 2019, 10:01am
1
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
[“user_uttered”,{“message”:“hello”,“customData”:{“userId”:“123”}}]
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\socketio.py
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, input_channel=self.name()
)
Replace this line with:
message = UserMessage(
data["message"], output_channel, sender_id, input_channel=self.name()
, metadata = data['customData'])
Now in your actions.py 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.
Zeeshands
(Zeeshan)
November 20, 2019, 5:10am
3
Thanks a lot Gaurav , yes it was w.r.t socketio. I’ll try & post you back if this is good enough.
1 Like
Zeeshands
(Zeeshan)
November 21, 2019, 5:38am
4
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\socketio.py 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