Merci de votre visite. Cette page est disponible en anglais uniquement.

Steps to Create a Video Skill

You create a video skill in the Amazon developer console. Once you've created the skill, you provide skill information, configuration and skill code hosted as an AWS Lambda function (an Amazon Web Services offering) that handles requests from the Video Skill API and communicates with a device or video streaming service. To enable this communication, the cloud or service should support the OAuth 2.0 authorization code grant type. You will need information about the authentication endpoint, client ID and secret to complete the video skill registration.

This topic provides the steps for creating a skill in the developer portal, creating the AWS Lambda function, configuring and testing your skill, and submitting it for certification.

Register as an Amazon Developer and Create a Skill

To configure a new video skill, you need an account on the Alexa Skills Kit (ASK) developer console. If you don't already have an account, go to the developer console and create one. Registering is free. Once you've registered:

  1. Open the ASK developer console and login.
  2. Click the Create Skill button.
  3. Enter the Skill name . Note that your skill's name must not indicate that its functionality is limited. For example, you should not use "basic", "reduced" or "simple" in the name of your skill.
  4. Select the Default language.
  5. Under the Choose a model to add to your skill page, select Video, which is a pre-built model.
  6. Click Create Skill.
  7. Copy Your Skill ID to the clipboard. The ID will be in a format similar to the following: amzn1.ask.skill.1a2b55555-c325-1234-d56e-1f234d5e6a78

For more information on how to use the developer console, see Manage Skills in the Developer Console.

Next, you will create a Lambda function so that you can configure the Video Skill Service endpoint.

Create a Lambda Function

You will need an AWS account and some basic knowledge of AWS.

The code for your video skill is hosted as a Lambda function on AWS. AWS Lambda is a service that lets you run code in the cloud without managing servers. The Video Skill API sends your skill requests. Your code parses the request, takes any necessary actions, and responds.

You need an AWS Identity and Access Management (IAM) Role with the AWSLambdaBasicExecutionRole policy attached. If you don't have this, complete the steps for To create an IAM role before completing the steps to create a Lambda function. If you already have a role with this policy, skip to To create a Lambda function.

To create an IAM role

Navigate to the Identity and Access Management (IAM) console.

  • Choose Roles, Create role.
  • Choose AWS service, then Lambda. Choose Next: Permissions.
  • Type "basic" in the filter box, then select AWSLambdaBasicExecutionRole. Choose Next: Tags.
  • Choose Next: Review.
  • Type a role name to identify this role, then choose Create role.

To create a Lambda function

Navigate to the AWS Lambda console.

  1. In the upper-right corner of the console, make sure you've selected:

    • N.Virginia for English (US) skills.
    • EU (Ireland) for English (UK) or German skills.

    Choosing the correct region helps prevent latency issues.

  2. Choose Create function.
  3. Choose Author from scratch.
  4. For Basic information:
    1. Type a name for your function.
    2. For Runtime, choose Python 2.7. The following example uses Python 2.7.
    3. For Existing role, chose the role that you created in the previous procedure.
    4. Choose Create function.
  5. On the Configuration page, under Designer, choose Alexa Smart Home.
  6. Under Configure triggers, in the Application ID box, paste your skill ID.
  7. Choose Add, Save.
  8. Navigate back to the AWS Lambda console list of functions.
  9. Choose the function that you just created.
  10. Scroll down to the Function code section.
  11. Copy and paste the following Python code into the code editor. This code provides a starting point for implementing a video skill. The code determines the request type by determining the namespace and name values in the message header. The namespace specifies whether the request is a Discovery or ChannelControl request, and either the handleDiscovery or handleChannelControl function is called. For a ChannelControl request, the name property specifies the kind of request. In this example code, the only request type detected is a ChangeChannel. The response is not fully implemented. You should handle every type of request a user would make to your skill, and provide the correct response headers and payload. For information about all of the request and response messages, see the interface reference topics such as Alexa.Discovery or Alexa.PlaybackController.

    def lambda_handler(event,context):
        namespace = event['directive']['header']['namespace']
        if namespace == 'Alexa.Discovery':
            return handleDiscovery(context,event)
        elif namespace == 'Alexa.ChannelController':
            return handleChannelControl(context,event)
    
    def handleDiscovery(context, event):
        payload = {}
        header = {
            "messageId": event['directive']['header']['messageId'],
            "name": "Discover.Response",
            "namespace": "Alexa.Discovery",
            "payloadVersion": "3"
        }
        if event['directive']['header']['name'] == 'Discover':
            payload = {
                "endpoints": [
                    {
                        "capabilities": [
                            {
                                "interface": "Alexa.RemoteVideoPlayer",
                                "type": "AlexaInterface",
                                "version": "1.0"
                            },
                            {
                                "interface": "Alexa.ChannelController",
                                "type": "AlexaInterface",
                                "version": "1.0"
                            },
                            {
                                "interface": "Alexa.PlaybackController",
                                "version": "1.0",
                                "type": "AlexaInterface"
                            }
                        ],
                        "endpointId": "videoDevice-001",
                        "description": "Device description that's shown to the customer",
                        "displayCategories": [],
                        "friendlyName": "Upstairs Amazon Player",
                        "manufacturerName": "Amazon"
                    }
                ]
            }
        response = {
            'header': header,
            'payload': payload
        }
        return {'event': response}
    
    def handleChannelControl(context, event):
        payload = {}
        header = {}
        messageId = event['directive']['header']['messageId']
        if event['directive']['header']['name'] == 'ChangeChannel':
            header = {
                "namespace":"Alexa.ChannelController",
                "name":"ChannelChanged",
                "payloadVersion":"3",
                "messageId": messageId
            }
        response = {
            'header': header,
            'payload': payload
        }
        return { 'event': response }
    

    After you paste the code, choose Save.

  12. Above the code editor, for Handler, leave the default name lambda_function.lambda_handler. A function handler is the main entry point for a Lambda function, and you specify it with the format fileName.entryPointFunctionName. For this example, the file name is lambda_function and the lambda_handler function is the entry point in this code.
  13. At the top of the page, copy the ARN for your Lambda function. You will use this value to finish configuring the video skill in the Alexa Skills Kit developer console. The ARN should be similar to the following: arn:aws:lambda:us-east-1:123456789012:function:myVideoFunction.

Test the Lambda Function in the AWS Console

To perform a quick test of a Discovery request in the AWS Lambda console:

  1. Navigate to the functions page in the AWS Lambda console.
  2. Choose the video skill function that you created in the previous procedure.
  3. Choose Test.
  4. For Event name, type a name for this test event. Then replace the entire contents of the code editor text box with the following code:

    {
      "directive": {
        "header": {
          "messageId": "12efe1cb-7a9c-4baf-9776-074d9166b5b8",
          "name": "Discover",
          "namespace": "Alexa.Discovery",
          "payloadVersion": "3"
        },
        "payload": {
          "scope": {
            "type": "BearerToken",
            "token": "some-access-token"
          }
        }
      }
    }
    
  5. Choose Create to create the test.
  6. Choose Test again to execute the test. If successful, the Execution result should be similar to the following:

    {
      "event": {
        "header": {
          "payloadVersion": "3",
          "namespace": "Alexa.Discovery",
          "name": "Discover.Response",
          "messageId": "12efe1cb-7a9c-4baf-9776-074d9166b5b8"
        },
        "payload": {
          "endpoints": [
            {
              "endpointId": "videoDevice-001",
              "capabilities": [
                {
                  "interface": "Alexa.RemoteVideoPlayer",
                  "version": "1.0",
                  "type": "AlexaInterface"
                },
                {
                  "interface": "Alexa.ChannelController",
                  "version": "1.0",
                  "type": "AlexaInterface"
                },
                {
                  "interface": "Alexa.PlaybackController",
                  "version": "1.0",
                  "type": "AlexaInterface"
                }
              ],
              "manufacturerName": "Amazon",
              "friendlyName": "Upstairs Amazon Player",
              "displayCategories": [],
              "description": "Device description that's shown to the customer"
            }
          ]
        }
      }
    }
    

Finish Registering Your Skill in the Developer Console

  1. Navigate back to the Alexa Skills Kit developer console, then open your video skill.
  2. Under Video Skill Service endpoint, for Default endpoint box, paste the ARN from the Lambda function you created, then choose Save.

Provide Account Linking Information

Select the Account Linking page. This section requires account information from your OAuth 2.0 provider, which enables customers to associate their device cloud account with your smart home skill. You can use Login with Amazon or another OAuth provider for this section. You provide:

  • Authorization URI for your OAuth provider
  • Client ID for your OAuth provider
  • A Scope, if required by your OAuth provider
  • Access token URI for your OAuth provider
  • Client Secret associated with your Client ID

For more details and instructions about the required fields, see Configure Authorization Code Grant. For an overview of account linking in video skills, see:

Test Your Skill

When your implementation is complete, and you've tested your Lambda function, you can functionally test your smart home skill.

  1. Make sure you have a smart home trigger added and enabled. To check this, go to the Lambda console, select your skill, and make sure you have an Alexa Smart Home trigger.
  2. Sign in to the Alexa app (available on Android, IOS or the web at https://alexa.amazon.com) with the same credentials as your developer account.
  3. Find your skill in the Alexa app. To do this, go to Skills, and tap Your Skills in the upper right corner of the All Skills page. Scroll to DEV SKILLS and find your skill.
  4. Click the ENABLE button to enable the skill, and you will be directed to account-link the skill to a device cloud account. If you are unable to complete account linking, make sure you are using valid credentials for the device cloud. Otherwise, it is likely there is an issue with account-linking information you provided in the developer console. For help with this, see Alexa: Debugging account linking in the developer forums. If you want to remove account linking later, you should disable your skill in the Skills tab.
  5. Return to the developer console, open your skill and on the Test page, move the slider to Yes. Use the Alexa Simulator to give Alexa commands using the utterances based on capabilities your skill supports. Make sure and test the skill with valid utterances and invalid ones, and in a variety of conditions, such as with a target device powered off. For a list of utterances and recommended test cases, see the Testing Guide. The test cases provided contain tests very similar to the tests used during skill certification testing. Running these tests and addressing issues before submitting for certification is an important step to get your skill published and available to customers as fast as possible. When issues are found during self-testing, usually they are much easier to fix, and you are more likely to pass certification the first time.
  6. When you are satisfied with your smart home skill's performance, you can, provide it for beta testing or submit it for certification.

Provide Launch Information

Next move to the Distribution page. The information you provide here displays with your skill in the Alexa app and is required unless noted as optional.

  • Select Distribution, and on the English (US) Store Preview page, specify:

    • Public Name.
    • One Sentence Description
    • Detailed Description
    • Example Phrases
    • Small Skill Icon
    • Large Skill Icon
    • Keywords
    • Privacy Policy URL
    • Terms of Use URL.
  • Click Save and Continue

On the Privacy and Compliance page, answer the questions provided. For Testing Instructions, provide test account credentials.

  • Click Save and Continue
  • On the Availability page, check whether your skill is public, or for use by Alexa for Business Organizations.
  • Select the countries and regions you would like to distribute your skill
  • Click Save and Continue

Optionally do a Beta Test

At this point, the Beta Test button will be enabled, and you can complete information to start a beta test. For more information, see Skills Beta Testing.

Submit Your Skill for Certification

If you have completed all of the fiends successfully, you should see a large green check mark and Your skill is ready for submission.

  • At the bottom of the page, click Submit for review.

Congratulations! You've successfully created and submitted a video skill for certification. You should hear from the certification team in a few days with the status of your skill; whether it's passed certification or whether there are issues to fix. When your skill passes certification and is available for customers, its status will change to Live in the developer console.

Submit Changes to a Live Skill

Once your skill Status is Live, any changes to the skill must be certified. For example, your skill must be recertified when you change the skill metadata or the AWS Lambda function. The certification review varies depending on the changes, and updating the Lambda function may cause additional review.

A new Development version is automatically created in the developer console and displays directly following your Live skill. This version has the same information as the original live version. You can use it to continue to work on your skill to improve it and add features.

When you submit your updated skill, use the Testing Instructions field to provide a change log detailing the changes you made.

Update your Lambda function

Do the following to update your AWS Lambda function:

  1. Create a new lambda function with a new ARN, and copy the code from your live Lambda function into the new Lambda function.
  2. Make your updates in the new Lambda function. Avoid updating the live Lambda function that supports your live skill, and avoid Lambda aliases or versioning because they do not work reliably once your skill is updated.
  3. In the development version of your skill, update the Lambda ARN configuration to point to the new Lambda ARN.

After your skill is recertified and the status is live, your skill points to the new Lambda ARN. You can then deprecate the previous Lambda function or use the function for future development or updates.