Alexa Skill with Azure Function
Won’t it be good if someone reminds your schedule? Won’t it be nice if someone answers all your questions? YESSS!!! It is possible by a skill. There come the voice assistants. Would you like to create your skill? Are you interested.? This blog offers you the fundamentals to jump into the implementation.
The goal is to create your application in any of the personal assistant apps and distribute it for other’s use. Here, I would like to write about the Alexa app. This blog on Alexa Skill will help you to gain Knowledge on custom skills with azure function as a backend resource to build a voice assistant. Here, we will see how to build the simpler Restaurant chat bot. Below is the final result of our development. In this blog, we will be getting the same in the postman. Follow me on the next blog to crack it with Aleeexaaaa.
Alexa is a virtual assistant by Amazon. Music, Radio, News, Information, Calls, Alarm, Timer, Reminder, Messaging, shopping, smart home are all the core functionality available on it.
When you say, Alexa Play music, the music skill got instantiated by using ASR (Automated Speech recognition) and NLP (Natural language Processing). NLP Processes the main words in the sentence to identify user intention.
The utterance is a sentence that the user wants to know. Each phrase that the user prompts is an utterance
What’s today’s special dinner?
A popular dish in the restaurant?
What are all the food items available to order?
The intent is a name given to a collection of utterances. Following are the user’s intentions to do with our application.
To know the details of the menus,
To pay a bill for the ordered items,
To check the delivery option to their residency.
It can be anything. Categorize the user utterance with intents to serve them better. Intent has n number of utterances. When the user uttered, What’s today special? NLP recognizes and assigns the top intent based on the utterance with it.
Slots are variables/keywords which has more value in the sentence. Those words are the key to the answer
What is the breakfast menu available?
What is the dinner item available?
Here breakfast, dinner is all slots.
Book a flight from India to Canada.
Here India and Canada are slots.
Without any delay, let us get started with Azure Function.!!!
Azure Function :
Open Visual studio -> File -> New Project-> Azure function -> Name your function app — “AlexRestaurant”
Select Http Trigger template with Access Right to Anonymous
Add the Route endpoint to access our function localhost: port/API/ Alexa/restaurant
I like to go with the modular programming approach for ease of modification. The function app only handles the incoming and outgoing response. All the logic should be present in another layer. Create a new Class library project in the same solution. Add Alexa .NET NuGet package to both the project. Then code the following steps in the AlexRestaurant Function skill.
Read request content as skill request with JSON convertor.
Handle the User request.
Write the response to the Alexa using the ResponseBuilder.
ResponseBuilder in Alexa.net NuGet provides multiple options to communicate with the Alexa App/Echo bot.
Create a new MenuItemDescription class in the AlexaRestaurantDomain class library Project to handle the description for the available menu items in the restaurant.
Create a new HandleUserInput class in the AlexaRestaurantDomain class library Project to process the request and provide the response string.
Things to be noted on the above code
- Retrieval of slot value from the alexa input.
- Various requests in the Alexa JSON input. we will deep drive it in the upcoming blogs
Time to test it in postman
Run the application in visual studio. Hit the endpoint with the post request. Use the below-added JSON in the body of the post request.
Publish a function app
Right click → Azure Restaurant skill function Project(not the entire solution)-> Publish -> Pick azure function consumption plan-> create new publish target.
Provide the necessary information and Zip deploy your application by publishing it into your portal.
Access the site: https://<yourappname>.azurewebsites.net.
Download the GitHub code for a quick run
GitHub is home to over 50 million developers working together to host and review code, manage projects, and build…
Looking to create Alexa skill? want to view the same result in the alexa app? Click here https://keerthana-murale.medium.com/alexa-custom-skill-ecb1344925f8