Jovo Plugin execution order on same middleware

plugins

#1

Hey,
we are more and more using Hooks and Plugins and there a few question upon this:

  • Execution Order: Hook and Plugin on same middleware
    Which Plugin/ Hook will be executed first? Is there a way to change this behavior?

  • after.response middleware: when is response sent back to alexa device?
    Our intention is to make the response ready and sent it back to the user. During this process we start a asynchronous function call (and do not wait for its response). This way it does not matter how long the asynchronous call takes and there is no delay to the user. This is working when using the express webhook - but not when using a lambda. I can see at the cloud watch logs that the response is getting logged (and expected that the response is sent to the alexa device) but this is not happening. The response to the device is getting out when all asynchronous call are processed.
    Do you have some advice?
    Greeting André


#2

Hey @Andre

Here’s the command to get more details about the middlewares that are triggered and the order

jovo run -- --performance-report

or this for more data

jovo run -- --performance-report detailed

You can influence the order of your custom by adding before. or after. to your middleware name.

Here’s an example. Adding three middlewares

app.middleware('before.request').use(() => {
    console.log('middleware before.request');
});
app.middleware('after.request').use(() => {
    console.log('middleware after.request');
});
app.middleware('before.before.request').use(() => {
    console.log('middleware before.before.request');
});