Retrieve the JWT token inside a custom action

Hi all, I try to integrate Rasa Open Source with an existing website and want to allow users do have queries about their personal data after login. My existing service prepares a JWT token that is valid for Rasa. Currently I use Socket IO though the Chat Widget example for managing the communication and it is well configured for JWT authentication.

At this point I am wondering if I could do retrieve the JWT token inside a custom action, so I could use it for authenticating the user request at my existing service side. Any feedback would be really appreciated.

Yes, you can pass the token from your web UI chat widget to Rasa as metadata. I have a PR here that adds the metadata feature to the Socket channel.

Thanks, Stephens. Indeed, it would be a good and straightforward approach. However, I found a different solution by forking the Socket channel and writing a custom connector for managing the way of preparing the sender_id. It might not be the best approach due to its performance side effects but it worked. It means that I store the username in the sender_id, so I can access it from the tracker and prepare a new JWT token anytime I need inside my custom actions.