€¦  · web viewthe user’s request is recorded, and the audio data is sent to the alexa...

10
Amazon Alexa Demo I. How Alexa Skills Work 1. A User speaks to an Amazon Echo device and makes a request to access a Skill. 2. The user’s request is recorded, and the audio data is sent to the Alexa Service in AWS where it is used to generate the appropriate request to send to the linked application logic which is implemented in another AWS service called Lambda. 3. The Lambda Service receives the request from the Alexa Service and processes the linked application logic accordingly. 4. Upon completion of processing the user’s request, the linked application logic in the Lambda Service will generate a

Upload: others

Post on 02-Sep-2019

1 views

Category:

Documents


0 download

TRANSCRIPT

Page 1: €¦  · Web viewThe user’s request is recorded, and the audio data is sent to the Alexa Service in AWS where it is used to generate the appropriate request to send to the linked

Amazon Alexa DemoI. How Alexa Skills Work

1. A User speaks to an Amazon Echo device and makes a request to

access a Skill.

2. The user’s request is recorded, and the audio data is sent to the Alexa Service in AWS where it is used to generate the appropriate request to send to the linked application logic which is implemented in another AWS service called Lambda.

3. The Lambda Service receives the request from the Alexa Service and processes the linked application logic accordingly.

4. Upon completion of processing the user’s request, the linked application logic in the Lambda Service will generate a response, which will include any necessary data, and send that response back to the Alexa Service

5. Finally, when the Alexa Service receives the response to the user’s request from the Lambda Service, that response will be converted into

Page 2: €¦  · Web viewThe user’s request is recorded, and the audio data is sent to the Alexa Service in AWS where it is used to generate the appropriate request to send to the linked

an audio response which will then be sent back to the user’s Amazon Echo device, where it will be played back for the user.

II. Parts of An Alexa Skill

Alexa Skills are made up of a number of different parts across a number of different web services. Each part has its own distinct function within the Skill’s ecosystem that allows the Skill to function appropriately.

At its most basic level, an Alexa Skill consists of 2 parts:

Interaction Model Application Logic

II.I The Interaction ModelThe Interaction Model is the Skill’s Natural Language User Interface. In short, the Interaction Model defines how users invoke and interact with the Skill. The Skill’s Interaction Model is hosted on Amazon’s Alexa Service, which is one of the many services offered as part of AWS. The interface for creating/editing the Interaction Model can be accessed by logging into Amazon’s Developer Portal.The first step in creating a Skill is to give the Skill a name. The name is the real world name of the Skill and will appear on the Alexa Skills Marketplace.

Figure 1 - Amazon Developer Portal 'Create a New Skill' Interface

Once the Skill has been given a name, the next step is to choose a template model to start with. Amazon provides templates for 3 different types of skills: Flash Briefing, Smart Home, and Video Skills.

Page 3: €¦  · Web viewThe user’s request is recorded, and the audio data is sent to the Alexa Service in AWS where it is used to generate the appropriate request to send to the linked

More commonly however, the “Custom” option will be selected which will generate a blank template to start with.

Figure 2 - Alexa Skills 'Choose a Model' Interface

Once a template model has been selected, the Interaction Model of the Skill can be developed. The first step of developing the Interaction Model of a Skill is to give the Skill an Invocation Name. The Invocation Name of a Skill is the name the user will give Alexa in order to open, or invoke, the Skill. Amazon’s interface also provides some requirements that the Skill’s Invocation Name must meet in order to be valid.

Figure 3 - Alexa Skills 'Invocation' Interface

Page 4: €¦  · Web viewThe user’s request is recorded, and the audio data is sent to the Alexa Service in AWS where it is used to generate the appropriate request to send to the linked

After the Skill has been given an Invocation Name, the main parts of the Interaction Model can be defined. The Interaction Model is made up of 3 main parts:

Intents Slots Sample Utterances

Intents are defined by an Intent Schema and represent the actions that a Skill can perform. In the ‘Custom’ template model, Amazon provides 3 basic Intents:

Cancel Intent Help Intent Stop Intent

These 3 Intents are provided by default so that functionality for providing users with extra help is easy to include in a Skill. Custom Intents can also be defined in addition to the default Intents.

Figure 4 - Intent Interface + Default Intents

After creating a custom Intent, the next step is to add any needed slots to that Intent. Slots represent arguments that can be passed into an Intent. An Intent is not required to have any Slots at all, but for those Intents that do have/need Slots, those Slots must have a Slot Type Definition. Once a Slot Type Definition has been created, it can then be mapped to a Slot within a specific Intent.A Slot Type Definition is essentially a data type for the Slot. A Slot Type definition is made up of a Name, and a list of possible values for that Slot.

Page 5: €¦  · Web viewThe user’s request is recorded, and the audio data is sent to the Alexa Service in AWS where it is used to generate the appropriate request to send to the linked

Figure 5 - Slot Type Definition

Once a Slot Type Definition has been created, Slots of that type can then be added to an Intent.

Figure 6 - Adding Slots to an Intent

Fortunately, Amazon provides a number of built-in Slot Types, such as dates, numbers, colors, and names of people, places, and things. It is not necessary to create a Slot Type Definition for any of these built-in Slot Types, as the appropriate definition will automatically be added when a Slot of one of the built-in types is added to an Intent. That said, a list of expected values can be added to the definition for any of the built-in Slot Types.

Page 6: €¦  · Web viewThe user’s request is recorded, and the audio data is sent to the Alexa Service in AWS where it is used to generate the appropriate request to send to the linked

Finally, once Intents have been created, and any needed Slots have been added to the Intents, the last step in creating the Interaction Model of a Skill is creating Sample Utterances.Sample Utterances are phrases or statements a user may say to an Amazon Echo Device in order to invoke a specific intent within a Skill. Sample Utterances should also indicate where Slot values will appear in the phrase or statement. Sample Utterances are essentially the User Interface of the individual Intents. The key to creating good Sample Utterances is to think about how a person would go about completing a task in the real world, and the questions they may ask along the way to help them complete it. Understanding how people interact with each other, and their devices will go along a way towards creating a powerful skill.

Figure 7 - Sample Utterances

II.II The Application LogicOnce Sample Utterances for all Intents have been created, the next step is to open the Amazon Lambda Service and create the 2nd part of the Skill: the Application Logic.The Amazon Lambda Service can be accessed from the AWS Console and is essentially a service for functions on demand. When Lambda receives a request from the appropriate Alexa Skill, it will automatically create a runtime environment and runs the necessary Application Logic, also known as a Lambda Function, which in turn will send a response back to the appropriate Skill on the Alexa Service. Once that

Page 7: €¦  · Web viewThe user’s request is recorded, and the audio data is sent to the Alexa Service in AWS where it is used to generate the appropriate request to send to the linked

response has been sent. Lambda will automatically close down the runtime environment it had created.The first step in creating a Lambda Function is to set up the trigger that will tell the Lambda Service to activate the Lambda Function. In short, the Alexa Skills Kit has to be added as a trigger, then the ID of the Skill (Found in the Interface of the Alexa Service) must be entered. Once saved, the Lambda Service will then know to execute the function when the identified Skill sends a request. After the trigger has been created, the application logic can be written.

Figure 8 - Lambda Function Trigger

Page 8: €¦  · Web viewThe user’s request is recorded, and the audio data is sent to the Alexa Service in AWS where it is used to generate the appropriate request to send to the linked

Figure 9 - Lambda Function Code

Once The Interaction Model, Lambda Function Trigger, and Lambda Function code have all been created, the final part of the Skill is linking the Lambda Function to the Interaction Model. By creating the Lambda Function Trigger, the Lambda Function now knows that it should execute the appropriate application code when it receives a request from the identified Skill. However, the Alexa Service still needs to know where to send its requests to.

II.III Identifying the Service EndpointThe last step in creating a Skill is to identify the Service Endpoint for the Skill. The Service Endpoint is where the Alexa Service will send requests to for processing. In other words, the Service Endpoint is how the Interaction Model is linked to the Application Logic.

Page 9: €¦  · Web viewThe user’s request is recorded, and the audio data is sent to the Alexa Service in AWS where it is used to generate the appropriate request to send to the linked

Figure 10 - Service Endpoint Interface

The Lambda Service interface will provide an Amazon Resource Number or ARN, for the Lambda Function for the skill. Simply enter that ARN into the Alexa Service interface as seen above, and the link between the 2 services will be complete. The Alexa Service now knows where to send requests for the Skill, and the Lambda Service knows to execute the appropriate function when requests for the Skill are received.It is worth noting that as an alternative to the Amazon Lambda Service, it is also possible to use an external HTTPS service endpoint to host the Application Logic for the Skill. However, doing so would require the creation of an entire Web Service, capable of verifying Amazon’s SSL Certificate, and handling Skill requests, as well as for any supporting resources and maintenance to be provided.