Getting Started with building your first Alexa Skill
By: Sarvesh Virkud
Tags: Lambda, Alexa Development, Alexa Skills, Alexa Developer, Alexa

You can create your own Alexa skill. Yes, that’s right. You just need some basic understanding of Python/NodeJs and an Alexa Developer account.

So, Let’s get started.

To build your first skill, you must login to the Alexa developer console. If you don’t have an account, registering for an account is a pretty straightforward process.

Now, after you login into the Alexa Developer Console, you will get a window like the one shown in the image below. To start building your first skill, follow these steps.

Click on Create Skill.

2. Enter skill name, select the default language which will be used by your skill.

3. From the choose a model to add to your skill, select Custom. You can choose any one later whichever suits your use case better.

4. You can either Provision your own backend for the skill or choose either Node.js or Python as your backend. In this case, I will go with Alexa-hosted (Python) backend. After this configuration, Click on Create Skill in the top-right corner of the window.

5. You can choose from many available templates which will give you a headstart into the type of skill you are building. You can choose from Fact Skill, High-Low Game Skill etc. In our case, I am going to go with Start from Scratch.

Click on Continue with template.

6. After a couple of minutes, your skill will be available for editing and testing. The currently deployed skill is a basic Hello World Skill. The image shown below is the main dashboard which will be used for configuration of Intents, Slots etc.

7. Click on Invocation tab in the left menu. In the text-box for Skill Invocation Name, enter the invocation name that you want to use. In this case, I will go with “sam bot”.

Invocation name is the phrase that the users of the skill will use to invoke the skill. So, when the user asks their Alexa device to “Ask Sam bot” or “Open Sam bot”, the LaunchIntent of the Skill gets triggered.

8. Under the Intents tab in the left-menu, Click on HelloWorldIntent. An Intent can be thought as a task that the user intends to do. So, for example add 2 numbers, Order a Pizza can be an Intent etc.

An intent has sample utterances which are the possible phrases that the user might say to get this task started or to perform that task. It could be as simple as saying Hello, which is shown in the image given below. E.g. of utterances for ordering a pizza could be something like “Hi, Can you please order a pizza for me”, “Order Pizza”, “Order Pizza with extra cheese” and so on.

9. You can also bulk edit utterances for an Intent by clicking on the bulk edit option. In the image shown below, we have the sample utterances that the user might say to invoke the HelloWorldIntent.

10. Adding more utterances is as easy as entering them into the textbox under the Sample Utterances and pressing Enter. In the image below you can see, that I have added the utterance “hi sam” and “hello sam”.

11. After this is done, Click on Save Model in the top pane of the Skill Dashboard.

12. After Save is Successful, Click on Build Model, this will train a custom model with the new utterances that we have entered for the HelloWorldIntent

13. Now, lets take a look at the Code tab for the Skill, Click on Code tab next to Build. For every Alexa Skill that we create has 2 major components, the first is the Model that we build which has the Intents, Slots, Invocation name etc, and second is a backend AWS Lambda which performs specific operation when a user invokes a specific Intent.

This window that you see below in an IDE created exclusively created for Alexa backend development. This is the lambda code that will run when the skill is invoked. At the start, we chose Python as out language for the backend lambda, so what you see on the screen is the Python boilerplate code for the Alexa Hello World Skill.

14. I am going to perform a few edits to this code, that is to change the reply messages or prompts that the Alexa skill will return to the user when it is invoked. In the diagram shown below, I changed the Welcome message for the LaunchRequestHandler. This is the skill code that executes when the skill is invoked using the Invocation name.

15. In the image shown below, I also changed the output message for the HelloWorldIntent to “Hello World! I am Sam, Nice to meet you!”.

16. After these changes are done, now click on Save followed by Deploy to deploy this updated code to the lambda function.

17. Now, to test the skill, Click on Test tab next to the Code tab. It will ask you to grant permissions so that this website can access your microphone. Click on Allow if a prompt appears for the same.

In the image shown below, we can see that the Test is disabled for this skill and a dropdown set to Off.

18. To test our skill, Click on the dropdown and select Development.

19. Now to test our skill, we can provide input to this Skill Simulator in 2 ways, that is either by making use of the textbox or the microphone icon next to it. If you want to give input via the mic, hold down the mic button and speak the phrase “Open Sam bot”.

You can use the other way, that is enter the phrase in the textbox like in the image shown below.

Enter “Open Sam bot” in the text box. The skill will return the welcome message that we configured.

20. The skill prompted that you can either say “Hello Sam” or “Hi Sam” or Help. Enter “Hi Sam” in the textbox. It returns the Hello World message that we configured in the backend Lambda code for the HelloWorldIntentHandler.

21. You can re-invoke the skill and this time use “hello sam” instead of “hi sam”. It will return the same response. “Hello/Hi Sam” were the utterances that we added in our Intent. You may also try invoking the intent just by saying Hello or Hi.

That’s it for this article. Will talk more about Intents and Slots in the next article. Thanks for reading! :)