Jaa


Connect a bot to Alexa

APPLIES TO: SDK v4

You can configure your bot to communicate with people through an Alexa custom skill. This article describes how to create an Alexa skill using the Alexa Developer Console, connect your bot to your Alexa skill in Azure, and test your bot in Alexa.

Prerequisites

  • An Azure subscription. If you don't already have one, create a free account before you begin.
  • A bot published to Azure that you want to connect to Alexa.
  • An Amazon account.

Important

Your bot must use the Bot Framework SDK version 4.8 or later. If you have an existing bot you may need to update your SDK version and republish your bot.

Create an Alexa skill

  1. Sign in to the Alexa Developer Console and select Create Skill.

  2. On the next page:

    1. Enter a name for your new skill.
    2. Make sure that Choose a model to add to your skill is set to Custom.
    3. Make sure that Choose a method to host your skill's backend resources is set to Provision your own.
    4. Select Create Skill.

    Choose model and hosting

  3. On the next page:

    1. Make sure that Choose a template is set to Start from scratch
    2. Select Choose.

    Choose a template

  4. On your skill dashboard under Interaction Model, select JSON Editor.

  5. In the JSON editor:

    1. Replace the existing contents with the following JSON.

      {
          "interactionModel": {
              "languageModel": {
                  "invocationName": "<your-skill-invocation-name>",
                  "intents": [
                      {
                          "name": "GetUserIntent",
                          "slots": [
                              {
                                  "name": "phrase",
                                  "type": "phrase"
                              }
                          ],
                          "samples": [
                              "{phrase}"
                          ]
                      },
                      {
                          "name": "AMAZON.StopIntent",
                          "samples": []
                      }
                  ],
                  "types": [
                      {
                          "name": "phrase",
                          "values": [
                              {
                                  "name": {
                                      "value": "<example-phrase>"
                                  }
                              },
                              {
                                  "name": {
                                      "value": "<example-phrase>"
                                  }
                              },
                              {
                                  "name": {
                                      "value": "<example-phrase>"
                                  }
                              }
                          ]
                      }
                  ]
              }
          }
      }
      
    2. For invocationName, change <your-skill-invocation-name> to the name that users will use to invoke your skill on Alexa. For example, if your skill invocation name was "adapter helper", then a user could say "Alexa, launch adapter helper" to launch the skill.

    3. In the values array under types, replace the three instances of <example-phrase> with phrases that users can say to trigger your skill. For example, if a user says "Alexa, ask adapter helper to give me details of the alexa adapter", one example phrase could be "give me details of the alexa adapter".

  6. Select Save Model, then select Build Model. This updates your skill's configuration on Alexa.

Configure your bot in Azure

To complete this step, you'll need your Alexa Skill ID. Get the ID either from the URL in the Alexa portal or by going to the Alexa Developer Console and selecting Copy Skill ID. Your Alexa Skill ID should be a value like "amzn1.ask.skill.<some-guid>".

  1. Open the Azure portal.
  2. Open the Azure Bot resource blade for your bot.
  3. Open Channels and select Alexa.
  4. In Alexa Channel Configuration, enter the information you copied in the previous step.
    1. In Enter skill Id, enter the Alexa skill ID that you copied from the Alexa Developer Console.
    2. Select Apply.
    3. Copy the Azure-generated Alexa service endpoint URI.

Update your Alexa bot registration

  1. Sign in to the Alexa Developer Console.

  2. Find and open your skill's configuration page.

  3. Select Endpoint.

  4. For Service Endpoint Type, select HTTPS.

  5. For Default Region:

    1. Enter the Alexa service endpoint URI you copied from the Azure portal.
    2. In the drop-down, select My development endpoint is a sub-domain of a domain that has a wildcard certificate from a certificate authority.
  6. Select Save Endpoints.

Test and publish your skill

If you own an Alexa device, you can test your skill before you publish it.

See the Alexa Skills Kit developer documentation for custom voice model skills for information on how to test and publish your skill on their platform.

Additional information

For more information about Alexa skills, see the Amazon developer documentation:

User authentication in Alexa

User authentication in Alexa is done by setting up and using Account Linking on the Alexa skill. For more information, see Understand Account Linking for Alexa Skills. You can require account linking when the user enables the skill, or you can require it as part of a conversation flow.

If you add user authentication as part of the conversation:

  1. Attach a sign-in card on the outgoing activity. This will be converted to an Alexa LinkAccount card that prompts the user to sign in using the Alexa app.

  2. If the user successfully links their account into the app, a token is then available on subsequent requests in the channel data.

Next steps