Create Utterances And Prompts In An Alexa Skill Dialog Model


In this article, I am going to demonstrate how to create slots and how to define Alexa speech prompts and user utterances which are one of the components required to create a dialog model for an Alexa skill. Dialog models are created to simplify Alexa skills code to collect and confirm slot values. The dialog model identifies the prompts and utterances to collect, validate, and confirm the slot values and intents.

Components of a dialog model

There are four components to the dialog model,
Required slots and prompts
A required slot represents information that your skill must have in order to fulfil the user's request. For instance, the RegisterBirthday intent requires, at a minimum, the day (day), month (month), and year (year) to save details about date of birth. You can control the order in which Alexa asks for the slot values.
Slot confirmation prompts
You can optionally designate a required slot as requiring confirmation. This means that the user must also confirm the slot value with a yes/no response before proceeding.
Intent confirmation prompts
You can specify that the entire intent requires confirmation. This is common for skills that order products or make reservations. A confirmation prompt typically repeats back to the user all the information previously provided for the user to confirm.
Slot validation rules and prompts
You can configure a set of validation rules that the slot value provided by the user must pass to be considered valid. If the value fails validation, Alexa can use your prompts to ask for a corrected value. You can use slot validation rules with both required and non-required slots.

Creating Custom Alexa Skill

A custom Alexa skill named birthday time has been created. The skill contains an intent name RegisterBirthday intent having day, month and year as different types of slot values.
Different slot types of RegisterBirthday intent

Identify required slots and prompts 

If a slot is required then a skill must get a valid value for it before user's request can be completed.
We can define prompts and utterances to collect these required slot values.
 Section  Description  Examples
 Alexa Speech Prompt
Questions that Alexa speaks to ask the user for the slot value.
The prompts should be specific to collecting just this one slot.
If you provide more than one prompt, Alexa chooses one at random. This gives Alexa a more conversational, human style.
Write the prompts using a conversational style. 
For the day slot, you could have prompts like this:
What city are you leaving from?
Ok. I heard you birthday is in {month} but which day exactly?
Which day is your birthday? 
 User utterances  
Utterances users can say to answer the questions provided in the prompts.
When Alexa asks the user to fill the slot, the service biases the speech models to listen for the response utterances you provide here.
This occurs when you return either Dialog.Delegate or Dialog.ElicitSlot.
Make sure the utterances represent the most likely ways you expect users to answer the question.
Use the standard curly bracket ({ }) slot notation to identify the slot name.
You can include an utterance consisting of just a slot value with no surrounding text again, use the curly bracket notation. 
For the day slot, you might have utterances like this:
the {day}
My birth day is {day}
{month} {day} 
The above examples would support a conversation like this for the day slot:
User: Remember my birthday
Birthday night: When is your birthday?
User: April 1993
Birthday night: Ok. I heard you birthday is in {month} but which day exactly?
User: 16
Alexa Speech Prompts
User utterances
To edit the prompts and utterances for a required slot,
  • In the left-hand navigation, find the intent and its list of slots, then click the slot name.
  • Alternatively, from the page for a particular intent, find the slot in the Intent Slots section below the sample utterances and click the Edit Dialog link.
  • Under Slot Filling, enable the Is the slot required to fulfill the intent option.
  • Fill in the Alexa Speech Prompt and User utterances sections.
Json code for creating required Alexa speech prompts and user utterances is as follows,
  1. {  
  3.             "intents": [  
  5.                 {  
  6.                     "name""RegisterBirthdayIntent",  
  7.                     "slots": [  
  8.                         {  
  9.                             "name""day",  
  10.                             "type""AMAZON.Ordinal",  
  11.                             "samples": [  
  12.                                 "the {day}",  
  13.                                 "{day}",  
  14.                                 "{month} {day}",  
  15.                                 "{month} {day} {year}"  
  16.                             ]  
  17.                         },  
  18.                         {  
  19.                             "name""month",  
  20.                             "type""MonthType",  
  21.                             "samples": [  
  22.                                 "{month}",  
  23.                                 "in {month}",  
  24.                                 "{month} {day}",  
  25.                                 "{month} {day} {year}"  
  26.                             ]  
  27.                         },  
  28.                         {  
  29.                             "name""year",  
  30.                             "type""AMAZON.FOUR_DIGIT_NUMBER",  
  31.                             "samples": [  
  32.                                 "of {year}",  
  33.                                 "I was born in {year}",  
  34.                                 "I was born in the year {year}",  
  35.                                 "year {year}",  
  36.                                 "in {year}",  
  37.                                 "in the year {year}",  
  38.                                 "the year {year}",  
  39.                                 "{year}",  
  40.                                 "{month} {day} {year}",  
  41.                                 "{month} {year}"  
  42.                             ]  
  43.                         }  
  44.                     ],  
  46.                 },  
  48.             ],  
  50.         "dialog": {  
  52.         "prompts": [  
  53.             {  
  54.                 "id""Elicit.Slot.653974572406.1040382425372",  
  55.                 "variations": [  
  57.                     {  
  58.                         "type""PlainText",  
  59.                         "value""when is your birthday?"  
  60.                     },  
  61.                     {  
  62.                         "type""PlainText",  
  63.                         "value""ok in {year} , but which day?"  
  64.                     },  
  65.                     {  
  66.                         "type""PlainText",  
  67.                         "value""which day is your birthday?"  
  68.                     }  
  69.                 ]  
  70.             },  
  71.             {  
  72.                 "id""Elicit.Slot.282358190483.487594834711",  
  73.                 "variations": [  
  74.                     {  
  75.                         "type""PlainText",  
  76.                         "value""please now tell me in which month is your birthday"  
  77.                     },  
  78.                     {  
  79.                         "type""PlainText",  
  80.                         "value""ok but in which month exactly?"  
  81.                     },  
  82.                     {  
  83.                         "type""PlainText",  
  84.                         "value""in which month is your birthday?"  
  85.                     },  
  86.                     {  
  87.                         "type""PlainText",  
  88.                         "value""ok, the day is {day}. but in which month?"  
  89.                     }  
  90.                 ]  
  91.             },  
  94.             {  
  95.                 "id""Elicit.Slot.1253554922892.1358447173887",  
  96.                 "variations": [  
  97.                     {  
  98.                         "type""PlainText",  
  99.                         "value""you're from {month} of which year?"  
  100.                     },  
  101.                     {  
  102.                         "type""PlainText",  
  103.                         "value""ok. {month} {day}. but in which year?"  
  104.                     },  
  105.                     {  
  106.                         "type""PlainText",  
  107.                         "value""please now tell me in which year you were born"  
  108.                     },  
  109.                     {  
  110.                         "type""PlainText",  
  111.                         "value""which year were you born?"  
  112.                     }  
  113.                 ]  
  114.             }  
  117.         ]  
  118.     }  
  119. }  
As we can see from the output, after invocation Alexa asks the user about his date of birth. User responds by saying “April 1993”, therefore Alexa prompts a message asking for day of the month as day is missing from user utterance.


In this article I have demonstrated how to create slots and how to define Alexa speech prompts and user utterances which are one of the components required to create a dialog model for an Alexa skill. I have also explained one of the components of dialog model. Proper examples of Alexa speech prompts and user utterances are provided along with json code snippet of interaction model.