Get external data in custom action

Hi there, long time lurker, first time poster.

I’m working with your framework and I implemented a system that works with external frameworks. This receives some data about the user in a Flask endpoint. To predict the intend I have an agent that loads a model I previously trained. So far, so good.

In your documentation you reported as follows:

 class FetchProfileAction(Action):
     def name(self):
         return "fetch_profile"
     def run(self, dispatcher, tracker, domain):
         url = ""
         data = requests.get(url).json
         return [SlotSet("account_type", data["account_type"])]

This custom action uses an URL to fetch the user’s profile, however having a static URL to get user information is almost never the case. In a “normal” case the URL is provided from the service in the HTTP request body. What I want to do is, to call an action and provide some piece of external information, not provided by the (Rasa) form. For example:

url = f"{username}/profile"

How can I pass this piece of information from the Flask endpoint to the custom action (in a clean way)?

By the way for those interested, I resolved by adding a Redis Docker container and using it at shared ram, this also allows the two systems to exist on different infrastructure. When a request arrives to the backend REST service, it saves the data needed with a TTL (Time To Live) of 2 minutes, then the message is forwarded to the Rasa model, which does his thing, if and when an action is called, the data regarding this message is stored in the DB. If it is not used, it is automatically deleted after 2 minutes. To retrieve the correct data, I saved them as key = <user_ID>_name_of_property This can be done because the framework passes the user ID to the Action Server.

I’m a little disappointed I’ve not found a “clean” way to do it using the Rasa framework, but i realized this may be out of scope.

Let me know if you need additional info or there is a solution indeed. Cheers!