How to write a model for an intent with multiple slots


#1

I need to create an intent with multiple slots and alexa to ask for values of each slot one at a time.

The slots are like this:

  • startdate
  • enddate
  • activity
  • contactid

I initially wrote my the model like this:

{
      "name": "ActivityIntent",
      "phrases": ["{startdate, enddate, activity, activitycontactid}"],
      "inputs": [
        {
          "name": "startdate",
          "type": { "alexa": "AMAZON.DATE" },
          "phrases": [
            "start date is {startdate}",
            "{startdate}",
            "start with {startdate}"
          ]
        },
        {
          "name": "enddate",
          "type": { "alexa": "AMAZON.DATE" },
          "phrases": [
            "end date is {enddate}",
            "{enddate}",
            "end with {endtdate}"
          ]
        },
        {
          "name": "activity",
          "type": { "alexa": "AMAZON.Person" },
          "phrases": ["give me {activity} activity report", "{activity}"]
        },
        {
          "name": "activitycontactid",
          "type": { "alexa": "AMAZON.NUMBER" },
          "phrases": [
            "{activitycontactid}",
            "i want a report on {activitycontactid}",
            "give me a report for {activitycontactid}"
          ]
        }
      ]
    }

But after building the model, it ignored the phrases inside each slot and did not add them in alexa compatible model. Probably phrases cannot be added inside a slot definition.

But then I realized I need to ask user question for each slot as well as user has to reply back with a value. So I compared with another skill which I created directly on alexa console and this looks like (here each slot has samples):

"name": "PersonIntent",
"slots": [
       {
           "name": "firstName",
           "type": "AMAZON.US_FIRST_NAME",
           "samples": [
               "My first name is {firstName}",
               "First name is {firstName}",
               "{firstName}"
            ]
        },
        {
            "name": "lastName",
            "type": "LAST_NAME",
            "samples": [
                "My last name is {lastName}",
                 "Last name is {lastName}",
                 "{lastName}"
            ]
         },
     ]

and each of these slot has an utterance which alexa will ask user like when asking for first name. alexa asks me What is your first name, and so on. Those are placed in this skill’s JSON like this:

dialog: {
    intents:[
        "name": "PersonIntent",
        "delegationStrategy": "ALWAYS",
        "confirmationRequired": false,
        "prompts": {},
        "slots": [
              {
                 "name": "firstName",
                 "type": "AMAZON.US_FIRST_NAME",
                 "confirmationRequired": false,
                 "elicitationRequired": true,
                 "prompts": {
                      "elicitation": "Elicit.Slot.1352805828328.1198316563612"
                  }
              },
              {
                  "name": "lastName",
                  "type": "LAST_NAME",
                  "confirmationRequired": false,
                  "elicitationRequired": true,
                  "prompts": {
                       "elicitation": "Elicit.Slot.1352805828328.939347850947"
                   }
               },        
        ]
    ]
}

Here is the complete JSON of the skill I created at alexa console with multiple slots for one intent:

{
    "interactionModel": {
        "languageModel": {
            "invocationName": "interview process",
            "intents": [
                {
                    "name": "AMAZON.FallbackIntent",
                    "samples": []
                },
                {
                    "name": "AMAZON.CancelIntent",
                    "samples": []
                },
                {
                    "name": "AMAZON.HelpIntent",
                    "samples": []
                },
                {
                    "name": "AMAZON.StopIntent",
                    "samples": []
                },
                {
                    "name": "AMAZON.NavigateHomeIntent",
                    "samples": []
                },
                {
                    "name": "iAmReady",
                    "slots": [
                        {
                            "name": "firstName",
                            "type": "AMAZON.US_FIRST_NAME",
                            "samples": [
                                "My first name is {firstName}",
                                "First name is {firstName}",
                                "{firstName}"
                            ]
                        },
                        {
                            "name": "lastName",
                            "type": "LAST_NAME",
                            "samples": [
                                "My last name is {lastName}",
                                "Last name is {lastName}",
                                "{lastName}"
                            ]
                        },
                        {
                            "name": "streetAddress",
                            "type": "AMAZON.StreetAddress",
                            "samples": [
                                "{streetAddress}"
                            ]
                        },
                        {
                            "name": "yourCity",
                            "type": "AMAZON.US_CITY",
                            "samples": [
                                "I live in {yourCity}",
                                "{yourCity}"
                            ]
                        },
                        {
                            "name": "yourState",
                            "type": "AMAZON.US_STATE",
                            "samples": [
                                "{yourCity} comes under {yourState}",
                                "{yourCity} falls under {yourState}",
                                "{yourState}"
                            ]
                        },
                        {
                            "name": "zipCode",
                            "type": "ZIP_CODE",
                            "samples": [
                                "{zipCode}"
                            ]
                        },
                        {
                            "name": "phoneNuber",
                            "type": "AMAZON.PhoneNumber",
                            "samples": [
                                "{phoneNuber}"
                            ]
                        },
                        {
                            "name": "emailAddress",
                            "type": "EMAIL_ADDRESS",
                            "samples": [
                                "{emailAddress}"
                            ]
                        }
                    ],
                    "samples": [
                        "I am ready"
                    ]
                },
                {
                    "name": "fakeIntent",
                    "slots": [],
                    "samples": [
                        "fake intent"
                    ]
                }
            ],
            "types": [
                {
                    "name": "EMAIL_ADDRESS",
                    "values": [
                        {
                            "name": {
                                "value": "[email protected]"
                            }
                        },
                        {
                            "name": {
                                "value": "[email protected]"
                            }
                        }
                    ]
                },
                {
                    "name": "ZIP_CODE",
                    "values": [
                        {
                            "name": {
                                "value": "11001"
                            }
                        }
                    ]
                },
                {
                    "name": "LAST_NAME",
                    "values": [
                        {
                            "name": {
                                "value": "Sarkar"
                            }
                        }
                    ]
                }
            ]
        },
        "dialog": {
            "intents": [
                {
                    "name": "iAmReady",
                    "delegationStrategy": "ALWAYS",
                    "confirmationRequired": false,
                    "prompts": {},
                    "slots": [
                        {
                            "name": "firstName",
                            "type": "AMAZON.US_FIRST_NAME",
                            "confirmationRequired": false,
                            "elicitationRequired": true,
                            "prompts": {
                                "elicitation": "Elicit.Slot.1352805828328.1198316563612"
                            }
                        },
                        {
                            "name": "lastName",
                            "type": "LAST_NAME",
                            "confirmationRequired": false,
                            "elicitationRequired": true,
                            "prompts": {
                                "elicitation": "Elicit.Slot.1352805828328.939347850947"
                            }
                        },
                        {
                            "name": "streetAddress",
                            "type": "AMAZON.StreetAddress",
                            "confirmationRequired": false,
                            "elicitationRequired": true,
                            "prompts": {
                                "elicitation": "Elicit.Slot.1352805828328.697843016744"
                            }
                        },
                        {
                            "name": "yourCity",
                            "type": "AMAZON.US_CITY",
                            "confirmationRequired": false,
                            "elicitationRequired": true,
                            "prompts": {
                                "elicitation": "Elicit.Slot.1352805828328.794835807148"
                            }
                        },
                        {
                            "name": "yourState",
                            "type": "AMAZON.US_STATE",
                            "confirmationRequired": false,
                            "elicitationRequired": true,
                            "prompts": {
                                "elicitation": "Elicit.Slot.1353763301158.639242474037"
                            }
                        },
                        {
                            "name": "zipCode",
                            "type": "ZIP_CODE",
                            "confirmationRequired": false,
                            "elicitationRequired": true,
                            "prompts": {
                                "elicitation": "Elicit.Slot.1352805828328.170611106719"
                            }
                        },
                        {
                            "name": "phoneNuber",
                            "type": "AMAZON.PhoneNumber",
                            "confirmationRequired": false,
                            "elicitationRequired": true,
                            "prompts": {
                                "elicitation": "Elicit.Slot.1353763301158.715705151837"
                            }
                        },
                        {
                            "name": "emailAddress",
                            "type": "EMAIL_ADDRESS",
                            "confirmationRequired": false,
                            "elicitationRequired": true,
                            "prompts": {
                                "elicitation": "Elicit.Slot.1352805828328.713279428622"
                            }
                        }
                    ]
                }
            ],
            "delegationStrategy": "ALWAYS"
        },
        "prompts": [
            {
                "id": "Elicit.Slot.1352805828328.1198316563612",
                "variations": [
                    {
                        "type": "PlainText",
                        "value": "What is your first name?"
                    }
                ]
            },
            {
                "id": "Elicit.Slot.1352805828328.939347850947",
                "variations": [
                    {
                        "type": "PlainText",
                        "value": "What is your last name?"
                    }
                ]
            },
            {
                "id": "Elicit.Slot.1352805828328.697843016744",
                "variations": [
                    {
                        "type": "PlainText",
                        "value": "Please tell us your street address. Prefix house or apartment number to the street address."
                    }
                ]
            },
            {
                "id": "Elicit.Slot.1352805828328.794835807148",
                "variations": [
                    {
                        "type": "PlainText",
                        "value": "Which city do you live in?"
                    }
                ]
            },
            {
                "id": "Elicit.Slot.1352805828328.170611106719",
                "variations": [
                    {
                        "type": "PlainText",
                        "value": "You are doing great. Please tell us your Zip or Area Code."
                    }
                ]
            },
            {
                "id": "Elicit.Slot.1352805828328.713279428622",
                "variations": [
                    {
                        "type": "PlainText",
                        "value": "Here comes the last one. Please provide your email address. Make sure you are providing us an active email address and have access to it."
                    }
                ]
            },
            {
                "id": "Elicit.Slot.1353763301158.639242474037",
                "variations": [
                    {
                        "type": "PlainText",
                        "value": "Which state does {yourCity} come under?"
                    }
                ]
            },
            {
                "id": "Elicit.Slot.1353763301158.715705151837",
                "variations": [
                    {
                        "type": "PlainText",
                        "value": "Thank you for your persistance. Please provide us your phone number for future communications."
                    }
                ]
            }
        ]
    }
}

Sorry for such a long post. I only wanted to make sure that I put everything in place.

How do I write a model in JOVO which builds to something like above? A sample model to accomplish the above scenario would be a great help.


#2

You can reference inputs in a phrase like this:

"phrases": ["{startdate}, {enddate}, {activity}, {activitycontactid}"],

Also, if you want to learn more about migrating an existing Alexa Skill Interaction model to Jovo, take a look at this course:

https://www.jovo.tech/courses/project-4-quiz-game-ask-sdk-jovo/step-2-interaction-model


#3

Yes, I remember you already told me that @jan but how do I accomplish the rest of things like tell alexa to ask user one question for providing value for each slot at a time? Please tell me how would I write a model which after building matches the one I shared (created directly in alexa console)


#4

in fact I want it other way round. jovo get will fetch the model from alexa, but that will not help me to understand how to write the model in JOVO which upon built creates the similar model as in alexa.

I am eagerly looking forward to deep drive into JOVO and so badly seeking for your help.


#5

The Dialog Interface stuff needs to be done in the Alexa Console right now (because the elicitations have IDs), so I would advise you to start building it on Alexa and then only importing it into Jovo.


#6

Thanks @jan! So it would be like building the model in alexa itself and then importing the same into my JOVO application. Rest of the functionalities can be developed using JOVO. Have I understood it right?


#7

Yes. Actually, it’s even optional to import the language model into Jovo. There is no need to have the language model locally when running the app. The models folder is just there to have a consolidated language model that can later be translated into Alexa or Dialogflow.


#8

Understood! But this brings in another question!

If I want to run the project locally using JOVO debugger (for testing before actually deploying it), I would need a model for that too, right?
And importing from alexa will put the model inside “platform” forlder, which is not used locallyif I have understood correctly. In that case, the JOVO model and alexa model will differ.

How can I deal with this situation? Will replacing the JOVO language model with the one I imported from alexa let me run the skill locally using the debugger tool?


#9

Yes, the Debugger uses the Jovo model in the models folder.

For this, use jovo build --reverse. You can find more details here: https://www.jovo.tech/courses/project-4-quiz-game-ask-sdk-jovo/step-2-interaction-model#jovo-build-reverse


#10

Hi @jan wondering if there is an option to use jovo deploy including the skill backend i.e. lambda. Like ask deploy deploys the lambda function along with the the skill?