Introduction To Building An Amazon Alexa Skill Using Alexa Skills Kit In ASP.NET Core

Introduction

 
Amazon Alexa is a virtual assistant AI technology developed by Amazon. Alexa is capable of issuing built in capabilities called skills such as playing music, answering questions, and providing the weather forecast.
 
Alexa is capable of listening to a user’s questions or receiving requests from customers and providing a response accordingly. Users can also extend Alexa capabilities by building skills that can provide customers with many different kinds of abilities.
 
Alexa Skills kit supports building different types of skills for Alexa and publishing skills to the Alexa Skill Store. Alexa Skills can be developed using AWS lambda functions or web services as an end point. We can create Alexa Skills using the account linking feature of Alexa Skills kit so that customers who are Alexa users can be linked to our web services.
 

Different types of skill models

 
Every skill has an interaction model that determines the requests the skill can handle and the words users say to invoke those requests. You can define this yourself with a custom model. The Alexa Skills Kit also provides pre-built models in which the possible requests and utterances are pre-defined for you.
 
The Alexa Skills Kit supports building different types of skill interaction models such as:
 

Custom interaction model

 
A skill with a custom interaction model that can handle just about any type of request. We can define the requests the skill can handle (intents) and the words users say to invoke those requests (utterances).
 
For example, searching a web service for a particular information and integrating with a web service to place an order for anything.
 

Different types of services

 
Different types of skills require different types of services, for a custom skill we can code either an AWS Lambda function or a web service.
 
AWS Lambda is a service that lets you run code in the cloud without managing servers. Alexa sends your code user requests and your code can inspect the request, take any necessary actions (such as looking up information online) and then send back a response. You can write Lambda functions in Node.js or C#.
 
Alternatively, you can write a web service for example in ASP.NET or ASP.NET Core and host it with any cloud hosting provider. The web service must accept requests over HTTPS. In this case, Alexa sends requests to your web service and your service takes any necessary actions and sends back a response. You can write your web service in any language.
 

User interaction with skills

 
When a user interacts with a device having Alexa, it is received by the Alexa service in the cloud. Alexa recognizes this interaction, determines what the user wants, and then sends a request to the particular skill developed by a particular web service at an end point, that can fulfil the user's request. Every Alexa skill contains an interaction model defining the words and phrases users can say to interact with a particular skill. This model describes how Alexa communicates with end users.
 
An Alexa Skill is divided into two parts,
  • Skill Service which runs inside service container like AWS Lambda or HTTPS Service.
  • Skill Interface which is a voice user interface configuration which can be utterances, slot types and intent schema.

Components of a Custom Skill

 
Components of a Custom Skill consists of the following:
  • A set of intents that represent actions that users can do with your skill.
  • A set of sample utterances that specify words and phrases.
  • An invocation name that identifies the skill.
  • A cloud based service that accepts these intents and acts on them.
  • A configuration that combines all this, created in a developer portal.

Building an Alexa skill using C# ASP.NET on AWS

 
In order to build an Alexa custom skill using C# in ASP.NET Core, we need Visual Studio 2015 (or newer) with AWS toolkit for Visual Studio installed. Sign up for an AWS account as we can host our service inside AWS Lambda, and sign up for an Amazon Developer Account.
 
We can also use rest service that will return information which a user can interact with.
 

Conclusion

 
In this article I have explained about Alexa Skills, and the concepts required to develop Amazon Alexa Skills using AWS Lambda function or Web Service as an end point inside ASP.NET Core using C#.