Build custom Alexa skills with Azure Logic Apps or Microsoft Flow

OK Google, how many new users did we get in our product yesterday?

Alexa, swap back production and staging slots.

Hey Cortana, send my SharePoint documents for approval.


Sounds like a not-so-distant future? It may be closer than you think.

Personal assistants like Cortana, Google Home, and Amazon Alexa are becoming integration hubs for consumers. They provide instant access to news, weather, shopping, traffic, and more. However there may be certain integrations that are more custom than what is out-of-the-box or readily available, or that leverage services that are not supported (or custom) themselves. Azure Logic Apps provides an easy way to build your own custom skills that can be used to extend these personal assistants into any number of our over 100 cloud and on-premises connectors. The best part? You could build the whole skill without any code.

All right, now to the nitty-gritty. For this blog I’m going to focus on how you can register a custom skill with Amazon Alexa, but the same pattern could be followed for Google Assistant and I assume Cortana.

Pattern for custom skills

To integrate with Alexa we will use the webhook pattern:

  1. Alexa determines a command has an intent that is relevant to our skill/application
  2. Alexa sends the command with relevant data to an HTTP endpoint we register
  3. Our app does custom processing on the data
  4. Our app returns a response back to Alexa
  5. Alexa responds back to the user

Logic Apps fits very naturally into steps 2-4. By using the Logic Apps HTTP Request Trigger a secure HTTP endpoint is automatically generated for us. We use connectors and control flow (potentially a switch statement to route intents) to process the response, and send back a response using the HTTP Response action.

Building the Logic App

After creating a new Logic App, add an HTTP Request trigger and define the request payload you expect to receive. In this case we expect an Alexa request so you can use this schema.

You can then begin to add actions to get the data you need for the response. For example, if I asked “How many customers did we get today?” I may add a Dynamics 365 List Records action with a filter for customers added today and return the @length().

Once the data has been composed, add a response action to return the response to Alexa. You can use a number of different properties, but a basic speech response looks like this:

{
    "response": {
        "outputSpeech": {
            "text": "//your response here//",
            "type": "PlainText"
        }
    },
    "version": "1.0"
}

That’s it! Now simply go to the Alexa Skills Kit and register a new skill using the Request URL generated when you save. You can test the app in the Alexa console to make sure everything is working end-to-end before publishing.

example application

About the Author

I'm a Program Manager for Azure Logic Apps. Opinions shared on my blog are my own. Follow me on Twitter @jeffhollan.



Build custom Alexa skills with Azure Logic Apps or Microsoft Flow