How to run a custom action for every user input and then process through Rasa?

Hi,
I have a use case where I want to pass every user input asynchronously to a rest API and then process the user input as Rasa normally does.

Through searching I have got an idea to implement it through custom actions. Using asynchronous call and UserUtteranceReverted() in the custom action.

Now, how can I call this custom action for every user input? I want to know if there is any better way to it.

To do this as a custom action, you would have to modify every rule/story to insert your custom action. You could also insert middleware between the user and the Rasa channel and do the call in your middleware before sending the utterance on to the Rasa channel. You could also create a custom version of the REST or socket channel.