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?