How to inject custom middleware into all actions?

I know how to create custom action and dispatch action inside it. But the limitation is that it only applies to an individual action. Can I define a middleware that apply to a group of actions, or even to all utter template actions and defaut actions?

My use case:

In the custom middleware, I will call api to fetch user’s issue number. Then, append ‘@{issue number},’ to the message before dispatching the utter action.

I want to apply this logic not only to one or two action but for all actions.

You can write a separate function that you call from all your custom actions. Does that work?

@akelad hey. That is one of the method. But is there any other sophisticated method for this ?

I have actually gone through some of the sanic project files. Sanic has implemented a middleware decorator. can you shed some light on how to use it ?