There are two parts to an Alexa skill.
The first part is the Voice User Interface (VUI). This is where we define how we will handle a user's voice input, and which code should be executed when specific commands are uttered.
The second part is the actual code logic for our skill. All you need to integrate with Alexa is an API to get data from, your imagination and some basic coding skills as far as this Despicable Me character Alexa skill is considered.
Detailed Documentation for setting up necessary things : https://developer.amazon.com/alexa-skills-kit/tutorials/fact-skill-1
To configure a Custom Skill for Alexa, we begin at developer.amazon.com and login with our AWS account details. From here, we’ll select the “Alexa” tab, then “Get Started” from the “Alexa Skills Kit” section. Clicking “Add a New Skill” takes us to the page where we’ll set up our Custom Skill, starting with the word that Alexa will need to recognize in order to know that a request is intended for us.
At this step, our new Skill is also assigned an application ID, which looks something like this:
amzn1.echo-sdk-ams.app.bd304b90-031d-xxxx-xxxx-1e4fd4772bab
We’ll need this later when implementing the Custom Skill (Second Part), in order to know that requests we receive are from the expected source. The next in the setup wizard is where we will configure the speech interface for our Custom Skill. This breaks down into the following three distinct sections:
- Configuring the Intent Schema
- Configuring Custom Slot Types
- Configuring Sample Utterances
This can also be done using the GUI
In the Alexa architecture, Intents can be thought of as distinct functions that a Skill can perform. The Alexa platform uses an “Intent Schema”, expressed in JSON, to communicate which function the code for a Custom Skill should execute to fulfil a given request. Intents can also take arguments which are known here as Slots.
For our Despicable Me Skill :
GetDescription:
provide the user with the description of the character
Additionally we’ll have Alexa listen out for a few standard Intents that Custom Skills should implement:
AMAZON.HelpIntent
: provide the user with some help text
AMAZON.StopIntent
: let the user stop an operation
AMAZON.CancelIntent
: let the user cancel an operation
Our intent, “GetDescription”, requires a set of valid values for its parameter, so that the backend code knows which character the user wants from Despicable Me. In our interaction model, we specified a Custom Slot Type whose name is “Characters” and the slot values “LIST_OF_CHARACTERS” that should contain all of the possible values for Characters, so that Alexa can listen for these and pass the appropriate value to our Custom Skill backend for a given request.
“Sample Utterances” are where we define the phrases that Alexa needs to hear in order to invoke each of our Custom Skill’s Intents. This is done using a simple text list of the format:
- Describe about {Characters}
- Tell me about {Characters}
- Enlighten me about {Characters}
Note also that we don’t need to provide sample utterances for the stop, cancel, and help intents.
Typing the above into the “Sample Utterances” box completes the interaction model which now looks something like this:
We can now click “Next” to configure the endpoint that our Custom Skill’s code will reside at.
Second Part : Custom Skill Endpoint ConfigurationOnce Alexa has used our Intent Schema and Sample Utterances to decode which Intent (and optionally which Slot(s) or argument(s)) the user is trying to invoke, it will pass this information as a JSON document to code that we need to write to implement our Custom Skill logic.
This code needs to reside either on AWS as a Lambda function, or anywhere that the Alexa platform can reach it via a HTTPS post with a JSON body.
For our example, we’ll use AWS Lambda, so we’ll need to create a Lambda function as described in the next section, then enter the ARN for that function into the “Endpoint” field in the configuration form:
Alexa will then send all requests to this endpoint, and expect an appropriate JSON response back from it. To make that happen, we’ll need to write some code.
Coding the Custom Skillhttps://github.com/Akash3096/Despicable-Me-Alexa
Upload the AlexaDesMe.zip from the Link given and you will be finished with the coding segment.
TestingThe Custom Skill can be tested using the Service Simulator within the Amazon Developer portal and without the need to use an Echo hardware device. We can type in sample sentences that the user might speak, view the JSON message that is sent to the Lambda function and its response JSON as well as listen to how the response would sound when played back on an Echo.
Comments