Building your Skill for the Alexa Conversations Challenge

Leo Camacho
7 min readAug 3, 2020

The Alexa Skill Challenge is a Hackathon organized by Amazon Alexa Team, that invites Builders, Makers and Developers around the world to create Skills that Discover the Future of Natural Alexa Interactions, with a Pool Prizes of $101,000 USD, the chance to be Interviewed by Alexa Tech Evangelist, $50 Amazon.com e-gift card, among many other rewards and prizes!

In a voice-centered world! What more natural than a conversation?

The number of ways customers can engage and the variety of dialog paths they can take results in a combinatorial explosion of states and code.For example, an Education skill with three topics requires thousands of dialogs paths. Here’s the magic of Alexa Conversations, it helps your customers experience natural interactions with much less development effort, freeing you to focus on the experience instead of on flowcharts.

The categories prized for this Challenge are: Food and Drink Skill, Travel and Transportation Skill, Productivity Skill, Education and Reference Skill, Game Skill, Wildcard Skill, Alexa Conversations Audio Skill, Alexa Conversations Visual Skill. You can also read more about the competition rules: https://alexaconversations.devpost.com/rules

“Alexa, start The Language Teacher Codelab” 🤖 🏁

Their are a variety of terms that we need to understand so we can create Custom Skills, let’s start! Login into https://developer.amazon.com/alexa/ and click on Create a custom Skill and select Alexa-Hosted (Node.js) to host your skill’s backend resources and Select the Alexa Conversations template and click continue with template. This will serve as a blank slate for our skill.

Read the Docs of the Alexa Skill Kit: https://developer.amazon.com/en-US/docs/alexa/custom-skills/and also review the repos in Github with samples and templates: https://github.com/alexa/alexa-cookbook/tree/master/feature-demos/alexa-conversations

Once you select the Alexa-Hosted (Node.js), now go to your project: https://developer.amazon.com/alexa/console/ask/build/custom/ The first step for this challenge is verify that your Interfaces use of Alexa Conversation:

Enable Alexa Conversations

Alexa Conversations allows to new or existing skills to create flexible, multi-turn dialogs that feel natural, especially for open-ended goal-oriented experiences like making recommendations, reservations, buying tickets, ordering transportation or food.

Step 1: Enabling Alexa Conversation displays in you console the Dialogs, Utterance Ses and Response!

Once you have set Alexa Conversations either as your default dialog manager or custom model on your project is going to create the following structure:

In the Menu > Go to Build:

Intents: 7 default Intents are configured in your Interaction Model: Cancel, Help, Stop, Navigate, Fall Back, Set Fav Color and Get Fav Color, in this sample as a start, but the idea is to match the specific journies of the user in your App, so we custom it by adding many other Intents dialogs related to our customer journey.

The Slot types, allow you to customize your text classification to be match categories of data in your Intents, to have a better understanding of the users needs during a conversation with the skill.

Now, in the Alexa Conversation configuration you have the option to 1) enable the AC manage the dialog or 2) connect your own model and ivoke AC API calls, for every user input you need to define your Dialog Act: Inform Args, Ivoke API, Deny or Affirm.

API Definition: create a Utterance set for your API call! And now you can create your response: Create a new promt, in our example is going to be I want to learn spanish {LanguagesProgram}.

Responses: Responses are how Alexa responds to users in the form of audio and visual elements. They are used when annotating Alexa Response turns in a Dialog. The default project includes 8 responses dialogs: welcome, bye, RecordColorSuccess, GetFavoriteColorSuccess, reqmore, RequestFavoriteColor, out_of_domain, provide_help.

The next step is that you are going to add your custom dialogs in the Multimodal responses. Here you are going to define a audio response and a visual response. For this we are going to use APLA: Read the Docs:Alexa.Presentation.APL: https://developer.amazon.com/en-US/docs/alexa/alexa-presentation-language/understand-apl.html

For example, in the welcome audio response your APL structure for:” Here is the Languages Assistant, do you want to start your program ?” is:

{
“type”: “APLA”,
“version”: “0.8”,
“mainTemplate”: {
“parameters”: [
“payload”
],
“item”: {
“type”: “Selector”,
“strategy”: “randomItem”,
“description”: “Change ‘type’ above to try different Selector Component Types like Sequencer”,
“items”: [
{
“type”: “Speech”,
“contentType”: “text”,
“content”: “Welcome to the Languages Assistant, do you want to start your program ?”
}
]
}
}
}

Now go to> Code

Now go to > Code

Create a Lambda function:

const LanguagesProgramApiHandler = {
canHandle(handlerInput) {
return util.isApiRequest(handlerInput, ‘RecordColor’);
},
handle(handlerInput) {
console.log(“Api Request [RecordColor]: “, JSON.stringify(handlerInput.requestEnvelope.request, null, 2));
// First get our request entity and grab the color passed in the API call
const args = util.getApiArguments(handlerInput);
const color = args.color;
// Store the favorite color in the session
const sessionAttributes = handlerInput.attributesManager.getSessionAttributes();
sessionAttributes.favoriteColor = color;

let response = {
apiResponse: {
color : color
}
};
console.log(“Api Response [RecordColor]: “, JSON.stringify(response, null, 2));
return response;

are sample conversations consisting of turns between the User and Alexa. They are used as training data to build your model. Learn more. Dialogs are examples of conversations that you expect to occur between Alexa and the user throughout the course of your skill.

https://developer.amazon.com/en-US/docs/alexa/conversations/write-dialogs.html

User: What are my class assesments for today?
Alexa: Today you have Pronunciation and a Trivia ?

User: Let’s start!
Alexa: Repeat after me: Here you can find green grapes.

In the header bar, click save!

Example for Node.js > Alexa In the Menu > Go to Build:

Innvocation Name: This is the name of your Skill, take your time to define this expression that is going to be the way the user should ask Alexa to get started with your App. Also, the recommendation is that the name should be specific to the functionality of the skill, and the invocation name must meet a list of requirements. For example: “Alexa start the Language Assistant ” For this example we are going to name our skill The Language Assistant!

Intent: This are the utterances (trainning phrases) that users would say to invoke your skill intents, for example: “Alexa ask The Language Teacher for my assesments of the day” , “Alexa tell The Language Teacher that today I want to practice Portugues” or “Alexa open/start The Language Teacher

Slot Type: This is the concept refered to the text classification of the conversation that allow the model recognize the intention of the user in the conversation, in the defined utterance, the slot type would the {assesments} asigned by the Language Teacher Skill. Some examples of our Assesments are: Lectures, Pronunciation, Conversational, Trivia, other, and it’s synonnyms.

In the Menu > Go to Code:

Configure the AWS Lambda service and create function in various languages such as: Node.js, Python, Ruby, Java, C# and Power Shell. For this ecample we are going to use the Documentation of the Node.js sample:

The function runtime passes a context object to the handler, in addition to the invocation event. The context object contains additional information about the invocation, the function, and the execution environment.

Once you are done editing the interaction model, be sure to save and build the model.

In the Menu > Go to Distribution:

Provide all the details about your skill; Public Name, Description, What’s new?, Example Phrases, Icon, Category, Terms of Use, Privacy Policy and others.

In the Menu > Go to Test:

Configuring and Testing Your Skill:

Use the invocation name along with one of the sample utterances we just configured as a guide. For example, “ask The Language Teacher for my assesments of the day” should result in your skill responding with “Your assesments are a Lecture and a Triva”. Now, you should also be able to go to the Alexa App (on your phone or at https://alexa.amazon.com) and see your skill listed under Your Skills. From here, you can enable the skill on your account for testing from an Alexa enabled device.

At this point, feel free to start experimenting with Alexa Conversations features and your intents as well as the corresponding request handlers in your skill’s code. Once you’re finished iterating, you can optionally choose to move on to the process of getting your skill certified and published so it can be used by Alexa users worldwide.

//Disclaimer: Opinions are my own, not of the hackathon, the company or their programs. Each Developers is fully responsible for their services, and is not affiliated with Amazon nor do they offer services on behalf of Amazon. Customers are fully responsible for their use of services, if any. This code is a sample, should not be used for any potential production workloads.//

--

--

Leo Camacho

AI Developer & Certified Educator 🤖 Passionate about NLP & Voice Assistants 🏆 Hackathon Winner/Finalist NASA, MIT, IMF, TechCrunch DisruptSF & SW Korea💡