Anand Mukundan
Posted on September 1, 2018
This is the second post on the series about developing Alexa Skills using .NET.
Coding A Skill
Developing a skill is made up of two major parts. You setup what is know as the intent, utterances configuration. This is done in the amazon skill website console. The new iterations of this console is vastly improved and is easier to use from a newbie perspective. (It used for be a text box into which you typed in a huge JSON).You need to have a registered Amazon developer account to develop a skill and it is free.
The other part is the building of the backend that would actually process the request from Amazon. So Amazon parses the actual voice input and then maps into the intents and structures we had configured and then calls our backend service with that data.
All data from and to the Amazon Alexa Skill system is via JSON and our backend is just a REST endpoint that is called by Amazon. So if you are a .NET developer at this point you are thinking Web API, right? Well you are correct.
So we need to start with a Web API project. It does not matter what framework and Core vs. Non-Core, the Alexa service just needs a REST Endpoint that supports https (Important, if you are planning to host your endpoint). There are some other rules that are documented in the Amazon site for custom hosted endpoints, but if you starting off with a skill, the this is the only major rule.
Handling Alexa Requests
I am going to assume you read thru the developer documentations and setup the intent mappings and utterances for your Alexa skill. This is quite well documented in the Amazon site.
Though the interface between the Alexa service and your backend is purely REST/JSON based, it is helpful if you use a library that helps parse those requests and also create response requests. This will greatly simplify the amount of plumbing code you will have to write for everything to work.
The most common library I found is the AlexaSkillsKit.NET kit. This supports most of the commonly used Skill kit requests and would be quite easy to start with.
It is not very well documented, but you should be able to get started with the documentation available and then you will have to jump into the code or use GitHub forums to get around using more complex features.
You can get this from GitHub or as a NuGet package
Once you have a basic WebAPI project with this library integrated correctly, you should be able to host a backend that can handle requests coming in from the Alexa service.
If you are just checking it out, I would recommend you use Azure App service hosting to get a sample working. It allows you to easily have a HTTPS endpoint available which will work with the Alexa service.
The future articles in this series will be focused of specific scenarios and how you can handle those when you are building your backend.
Posted on September 1, 2018
Join Our Newsletter. No Spam, Only the good stuff.
Sign up to receive the latest update from our blog.