Introduction
In this tutorial, we will be focusing on how to create a Hello World Skill in Alexa Developer Console. This is the most basic skill, and it would give us an idea about Skill-building using Alexa’s developer console. If you’re completely new to Alexa, you might want to take a look at this. For more information about creating an account and accessing the developer console, you can click here.
Creating the Hello World Skill
After accessing the developer console, click on Create Skill. Subsequently, you will be able to see the following page
Step 1. Give a proper name to your skill. In this case, we name it hello world.
Step 2. Select the preferred language for developing your skill. Here, we select English (US).
Step 3. Select the model for the skill. Since we want a custom model, we choose Custom.
Step 4. Select the method to host the skill’s backend. Since we’re building using Python, we choose Alexa-hosted(Python).
Step 5. Click on Create Skill.
After doing these steps, you will have to choose a template for your skill. Therefore, choose Start from Scratch as the template and click on Continue with template option.
Once the skill creation is complete, we’ll be able to see different parts of our Alexa skill. First, let’s look at the intent section.
So, we can see that there are 5 in-built intents. These are some of the mandatory intents which we use in almost all skills. Also, we can see the HelloWorldIntent. This is the intent related to our Hello World skill. Now, let’s look into the HelloWorldIntent
Here, we can see that the HelloWorldIntent already has some utterances built into it. Also, we can add our own set of utterances to the intent.
Next, let’s take a look at the JSON Editor tab. It consists of the JSON representation of everything related to our skill, including the different intents as well as the sample utterances. In this case, we are using the default template. But as we add additional functionalities to our skill, the changes will be reflected in the JSON editor as well.
Code for the Hello World skill
Now let us look at the code template. We will be focusing on a certain class within the code to understand a few of the basic methods used within the code.
In order to access the code template, click on the Code section at the top. The lambda_function.py is the main code file.
For better understanding, we will only be looking at the HelloWorldIntentHandler class within the code. As we can see, there are two methods(functions) – can_handle and handle.
The can_handle method is responsible for checking whether the handler is suitable for the incoming request. Following this, the handle method determines the action needed once the request is received.
The response text “Hello world!” is sent using the response_builder when the HelloWorldIntentHandler is invoked. We use “.speak()” function for this. Also, in order to add “reprompt” function, we can use the “.ask()” function.
Now, let us build the skill. To do so, first, click on the Skill Invocation Name option within Invocations. Subsequently, click on the Build Model option.
After the build is successful, let’s test out the model.
First, click on the Test option to go to the testing interface. Next, enable skill testing to Development mode.
Finally, let’s start testing the skill. You can either speak by clicking on the microphone icon, or you can type the sentences.
First, we need to open the skill with the invocation name. So type start hello world (a launch phrase along with the invocation name). Next, type Hello. The following would be the end result
Conclusion
So, we have successfully created our first Alexa skill – Hello World. Hope that this tutorial was informative and worth your time.
Happy Learning!