Introduction
Here is another article on custom Alexa skills. In this article, I am going to demonstrate how to create a custom Alexa skill on a hosted node.js server. For that, I will be creating a custom Alexa skill named Eating House. With the help of this skill, users can ask Alexa to book restaurants in advance.
The users can tell the timing, day, number of people to book for reservations, and the name of the person under whom the booking has to be done. The backend code required for the Alexa skill to work will be stored in a lambda function inside the Amazon developer console. To know the basics of what components are needed to create an Alexa skill you can visit my previous article.
Creating Alexa Skill
To create a new skill, first, we need to log in to the Alexa developer console, we need to mention the unique skill name, and select the default language according to our location.

After that, we can choose a model to add to our skills. To create a custom skill, we can select a custom model.

We can also choose a method or a template to host the skill’s backend code inside a lambda function.

We can choose Alexa Alexa-hosted node.js or Python template. We can also mention our own endpoint or server to store backend resources for the required Alexa skills.
The next step is to choose a template to add to our skill, which we customize later according to our needs,s and click on the Create Skill button.
Now that the skill has been created, we need to make adjustments to the skill’s front end. Now I will be creating intents, slots, and custom slot types to create the skill’s frontend.
First, we need to mention the invocation name. Users say a skill's invocation name to begin an interaction with a particular custom skill.

Now we have to create intents.

Here I have added a new intent named CreateReservation Intent along with a sample utterance. Inside the utterance “I want to make {ReservationDate} at {ReservationTime} for {NumberOfPeople}”, ReservationDate, ReservationTime, and NumberOfPeople are slots defined for the skill. Slots are defined within curly brackets.
Slots and slot types of each slot are defined as follows.

Here NumberOfPeople, ReservationDate, ReservationTime, and NumberOfPeople are slots created for CreateReservation intent.
Custom slot types can also be created by clicking on the Add Slot Type button under the slot types menu. To create a custom slot type, type the name of the custom slot also fill in the required slot values along with ID and synonyms.
We can also create dialogs such as Alexa speech prompts and user utterances for each and every slot being created. When the slot required to fulfill the intent is not mentioned in the sample utterance of a user then dialogs are created to ask users to mention the slot values to fulfill the intent.
Here Alexa speech prompt is whatever Alexa will say to prompt the user to fill a particular slot and user utterances are whatever the user might say in response to Alexa prompts.
To create a dialog under each slot
- Enable the option “Is this slot required to fulfill the intent”.
- Type Alexa speech prompts and user utterances accordingly.

The above dialogs were created for the NumberOfPeople slot.
The JSON code for the frontend part is as follows.
{
"interactionModel": {
"languageModel": {
"invocationName": "eating house",
"intents": [
{
"name": "AMAZON.CancelIntent",
"samples": []
},
{
"name": "AMAZON.HelpIntent",
"samples": []
},
{
"name": "AMAZON.StopIntent",
"samples": []
},
{
"name": "AMAZON.NavigateHomeIntent",
"samples": []
},
{
"name": "CreateReservation",
"slots": [
{
"name": "NumberOfPeople",
"type": "AMAZON.NUMBER",
"samples": [
"there will be {NumberOfPeople} people"
]
},
{
"name": "ReservationDate",
"type": "AMAZON.DATE",
"samples": [
"make reservation on {ReservationDate}"
]
},
{
"name": "ReservationTime",
"type": "AMAZON.TIME",
"samples": [
"i want to book at {ReservationTime}"
]
},
{
"name": "PersonName",
"type": "AMAZON.FirstName",
"samples": [
"{PersonName}"
]
}
],
"samples": [
"please make reservation for {NumberOfPeople} people on {ReservationDate} at {ReservationTime} for name {PersonName}",
"i want to make reservation on {ReservationDate} at {ReservationTime} for {NumberOfPeople} people",
"i want to make a reservation for {NumberOfPeople} people",
"i want to make a reservation"
]
}
],
"types": []
},
"dialog": {
"intents": [
{
"name": "CreateReservation",
"confirmationRequired": false,
"prompts": {},
"slots": [
{
"name": "NumberOfPeople",
"type": "AMAZON.NUMBER",
"confirmationRequired": false,
"elicitationRequired": true,
"prompts": {
"elicitation": "Elicit.Slot.735905142355.536259982955"
}
},
{
"name": "ReservationDate",
"type": "AMAZON.DATE",
"confirmationRequired": false,
"elicitationRequired": true,
"prompts": {
"elicitation": "Elicit.Slot.735905142355.431728293953"
}
},
{
"name": "ReservationTime",
"type": "AMAZON.TIME",
"confirmationRequired": false,
"elicitationRequired": true,
"prompts": {
"elicitation": "Elicit.Slot.735905142355.1527575461050"
}
},
{
"name": "PersonName",
"type": "AMAZON.FirstName",
"confirmationRequired": false,
"elicitationRequired": true,
"prompts": {
"elicitation": "Elicit.Slot.735905142355.1189785990153"
}
}
]
}
],
"delegationStrategy": "ALWAYS"
},
"prompts": [
{
"id": "Elicit.Slot.735905142355.536259982955",
"variations": [
{
"type": "PlainText",
"value": "How many people will be there?"
}
]
},
{
"id": "Elicit.Slot.735905142355.431728293953",
"variations": [
{
"type": "PlainText",
"value": "what is the reservation date?"
}
]
},
{
"id": "Elicit.Slot.735905142355.1527575461050",
"variations": [
{
"type": "PlainText",
"value": "at what time?"
}
]
},
{
"id": "Elicit.Slot.735905142355.1189785990153",
"variations": [
{
"type": "PlainText",
"value": "under whose name do you want to make the reservation?"
}
]
}
]
}
}

Join the conversation! Your thoughts help the community grow.