Introduction
In this article of custom Alexa skills, I am going to demonstrate how to create a custom Alexa skill on Alexa Hosted node.js server. For that, I will be creating a custom Alexa skill named City Facts. With the help of this skill, I will show how to implement dialog delegation in an Alexa skill. With the help of this skill, Users can ask Alexa to fetch information about different cities.
Each time Alexa asks if the user wants to know a fact about different cities. The users can give response by saying for example “give me a fact about London”. Alexa will fetch facts about the City London and prompt a message giving information about that particular city. The backend code required for the Alexa skill to work will be stored in a lambda function inside the Amazon developer console.
Creating an Alexa Skill
To create a new skill, first we need to login into 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 skill. To create a custom skill, we can select 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 hosted node.js or python template. We can also mention our own endpoint or server to store backend resources for the required Alexa skills.
Next step is to choose a template to add to our skill, which we customize later according to our need and click on create skill button. Now as skill has been created, we need to make adjustments to skill’s frontend. Now I will be creating intents, slots and custom slot types to create 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 factIntent along with some sample utterances such as give me a fact, tell me a fact.
A custom slot type named CityName is defined for this Alexa skill.

Different slot values are defined such as Paris, Toronto, Sydney, etc.
After creating a model for a particular skill, we can save and build the model by clicking on save model and build model button on the top.
Json code for above frontend is as follows:
- {
- "interactionModel": {
- "languageModel": {
- "invocationName": "city detail",
- "intents": [
- {
- "name": "AMAZON.NavigateHomeIntent",
- "samples": []
- },
- {
- "name": "AMAZON.CancelIntent",
- "samples": []
- },
- {
- "name": "AMAZON.HelpIntent",
- "samples": []
- },
- {
- "name": "AMAZON.StopIntent",
- "samples": []
- },
- {
- "name": "factIntent",
- "slots": [
- {
- "name": "city",
- "type": "cityName",
- "samples": [
- "give me a fact about {city}",
- "tell me some facts about {city}",
- "{city}"
- ]
- }
- ],
- "samples": [
- "give me a fact",
- "get a fact",
- "tell me about {city}",
- "get me a fact for {city}",
- "tell me a fact",
- "tell me a fact about {city}"
- ]
- }
- ],
- "types": [
- {
- "name": "cityName",
- "values": [
- {
- "name": {
- "value": "paris"
- }
- },
- {
- "name": {
- "value": "toronto"
- }
- },
- {
- "name": {
- "value": "sydney"
- }
- },
- {
- "name": {
- "value": "london"
- }
- },
- {
- "name": {
- "value": "new delhi",
- "synonyms": [
- "delhi"
- ]
- }
- }
- ]
- }
- ]
- },
- "dialog": {
- "intents": [
- {
- "name": "factIntent",
- "confirmationRequired": false,
- "prompts": {},
- "slots": [
- {
- "name": "city",
- "type": "cityName",
- "confirmationRequired": false,
- "elicitationRequired": true,
- "prompts": {
- "elicitation": "Elicit.Slot.251925459829.983270759031"
- }
- }
- ]
- }
- ],
- "delegationStrategy": "SKILL_RESPONSE"
- },
- "prompts": [
- {
- "id": "Elicit.Slot.1162780729786.1432530920282",
- "variations": [
- {
- "type": "PlainText",
- "value": "which city are you going to?"
- },
- {
- "type": "PlainText",
- "value": "Where are you going?"
- }
- ]
- },
- {
- "id": "Elicit.Slot.1162780729786.1143025724798",
- "variations": [
- {
- "type": "PlainText",
- "value": "where are you starting your trip?"
- },
- {
- "type": "PlainText",
- "value": "What city are you leaving from?"
- }
- ]
- },
- {
- "id": "Elicit.Slot.1162780729786.801508773141",
- "variations": [
- {
- "type": "PlainText",
- "value": "what date are you flying out?"
- },
- {
- "type": "PlainText",
- "value": "When will you start this trip?"
- }
- ]
- },
- {
- "id": "Elicit.Slot.251925459829.983270759031",
- "variations": [
- {
- "type": "PlainText",
- "value": "which city do you want to know the fact about,
- you can say london or paris or new delhi?"
- }
- ]
- }
- ]
- }
- }


Join the conversation! Your thoughts help the community grow.