Alexa, Teach Me How to Teach You
Learn how to build and deploy new Alexa skills using blueprints
Alexa is amazon’s voice-based virtual assistance like Siri for the iPhone, and Cortana for Microsoft Windows.
Alexa is a cloud-based service and it was firstly introduced in Amazon Echo. Alexa is an artificial intelligence oriented virtual assistance which is being used by the Amazon in tens of hundreds of devices, and in the other third-party devices as well.
Alexa is now part of music devices, robots, mobile phones, vacuum cleaners, etc.
Alexa capabilities are like software. Skills are voice-driven Alexa capabilities. In other words, the interface between users and Alexa is called Skills.
Creating Alexa skills
Alexa skills are built by 2 different components
- the voice controls or actions
- the functionality
In this article we will evaluate how to set up both, starting with the functionality.
The functionality is simply some code that will be executed when Alexa is tasked with our custom actions (or skill). This code for our purposes will run on AWS Lambda, a service matching perfectly with Alexa, it’s cost-efficient and super easy to set up.
Here are all the steps we need to take into account when building an amazing Alexa skill:
- Set Up AWS (Amazon Web Services) Lambda
- Create a free Alexa Developer Account
- Create a sample of Alexa Skill
- Test the newly created Alexa skill
So let’s start with the first step.
Set Up AWS (Amazon Web Services) Lambda
- Go to the Amazon Web Services management console (https://aws.amazon.com/) and create a new account if you don’t have one already. Click on the “Complete Sign Up” button.
After adding the appropriate data in all the required fields, login to the AWS management console. Keep in mind that AWS is a paid service, though they offer a trial period of 1 year with certain limitations, but it’s more than enough for what we want to do.
After the successful login, the AWS management console dashboard will be displayed to you.
Different web based services are available of AWS portal. From the find services list, search for the “Lambda” service. Select the “Lambda” service.
Lambda service only works in the US East (N. Virginia), EU (Ireland), US West (Oregon), and Asia Pacific (Tokyo). Make sure to choose one of the given regions before creating the Lambda service.
After choosing the “Lambda” service you will be redirected to the Functions screen. Choose the “Create function” option.
- Click on the “Use a blueprint” option and search for the “Alexa-skills-kit-color-expert-python”.
NOTE: We will use a blueprint for sample, a blueprint is an already develop sample you can easily add in your AWS lambda account. If you want to build your own skills, you can either program the lambda yourself, or use the blueprint and update it to your needs.
There are blueprints for Python, NodeJS and other programming languages, in our case we will use one based of Python, though we will ignore the code for this tutorial and focus more on the Alexa side of things.
- If the results are not displayed under the “Use a blueprint” section, then select the third option “Browse serverless app repository” and search for the “Alexa-skills-kit-color-expert-python”.
- Now enter the “TopicNameParameter” and click on the “Deploy” button.
- Now click on the “Logical ID” text.
- The function code will be displayed to you. Copy the “ARN” code displayed to you on the “top right corner”.
Create a free Alexa Developer Account
Now we have to create an Alexa Developer Account. Go to the Amazon developer portal (https://developer.amazon.com/dashboard) and create an account if you do not have an account already.
While creating the new account, add the appropriate data in all required fields.
Sign in to the Amazon developer portal if you have signed up already.
Create a sample of Alexa Skill
Here is where we build the actual Alexa interface, that is how we are going to talk to Alexa to solve our problems and communicate with our Lambda function.
Follow all these steps carefully:
- Now choose the “Alexa” option from the dashboard and select “Alexa Skills Kit”. You will be redirected to the “Alexa developer console”.
- Click on the “Create Skill” button.
- Enter the skill name, choose the language, and click on the “Create Skill” option.
The skill name can be anything you want, keep it meaningful to what you are trying to achieve. But don’t confuse the name with the phrase you will use to invoke Alexa to perform the task. The name is only for your reference.
- Enter the skill invocation name. This is what you will have to say to Alexa when communicating with your skill.
- On the Alexa skill dashboard, you will the list of your created skills. Click on “MyBookSkill”.
- Take a look at the sample intents to understand that how you can create your own intents.
With the invocation name you told Alexa to “talk” to your program, now intents, will tell your program exactly what procedure to execute. They can be anything your program can perform, like “find a book”, or “read live code stream”.
- For creating your own intent, click on the “Add Intent ” button.
- Enter the name of intent and then enter the utterances.
- Now choose the slots type from the left menu and click on “Add slot type”.
Slots allow you to create lists of possible values, IDs and synonyms, Often times they are generated by code, but for now we will set them manually.
- Enter the name of the slot type. I have entered here “BOOK_TYPE”, and after that enter the values.
- Enter all the values and then click on the “Build model”.
- Now click on the endpoint section from the left menu and enter the Lamba ARN value.
- After entering the ARN value, click on the “Save endpoints” option.
Alexa skill is now successfully created.
Test the newly created Alexa skill
After the implementation of the Alexa skill, we have to test it. The testing verifies the either we are achieving our desired results or not?
We can test the Alexa skill in many ways.
We can deploy the Alexa skill on Amazon devices i.e. Amazon Echo Dot, Amazon Echo, or on any other device which supports the deployment of Alexa.
We can test the Alexa skill by using the simulator. Just say the skill invocation name that you have written while creating the Alexa skill.
This is the fun part, so enjoy it!
Alexa, and voice assistants in general are here to stay, and the success of your product or services may be limited by the integration that these systems will present in the future.
So grab yourself some time and take a look into the endless possibilities these assistants give to users and developers alike.
If you have built Alexa skills, please let me know in the comments I’d love to play around with them on the one I have home.
Thanks for reading!
Join more than a thousand developers!
Subscribe now to our free, weekly e-mail with the best new articles, courses, and special bonuses.
We won't send you spam. Unsubscribe at any time.