How Jovo states are mapped into Alexa canHandle?

amazon-alexa

#1

Hi!

I understood that Jovo can only choose Intents that are inside its current state, but in our current application while being in an initialState, Alexa can choose in some cases the “intent2”.

initialState {
intent1
}

state2 {
intent2
}

Am I missing something? I understand that if Alexa canHandle() function returns false, the intent cannot be selected by Alexa…

Best Regards,

Juan

#2

Hey @jlopezr,

can you tell me in more detail what’s exactly happening here? Does intent2 get triggered while being in initialState? Or does Alexa just match intent2, and your handler goes to Unhandled?


#3

Let me elaborate a little more on the example with a simplification of our app.

We have two intents:

  • SearchIntent that provides an initial query for searching recipes.

  • MoreRecipesIntent that asks the system for the next 3 recipes that match the query.

app.js (Intents)

We have 3 states:

  • the initial state, that greets the user and jumps to state1.
  • state1 where the system is waiting for a recipe query.
  • state2 where the system has shown the first 3 recipes and the user can ask for more recipes.

The SearchIntent has a lot of utterances (example recipes from our database) and we expect that if words not in our database are told, the voice model understand that the unknown word is a new recipe or ingredient not yet in the database.

Let’s make a test with “cachopo” (a spanish recipe not added yet to the voice model)

Training model

The considered intents are the SearchIntent with the “right” slots. But the selected intent is the MoreRecipesIntent that doesn’t make too much sense. This intent has utterances like “busca más recetas” where the word cachopo does not appear but it allows us to show you the doubt we have when we execute the skill.

With this voice model we expect that if MoreRecipesIntent is not enabled because we are in the state1, Alexa skips this selected intent and chooses the second one: SearchIntent. However when we execute the skill, it skips the considered intents and jumps directly to the fallback intent as shown next:

Testing with Jovo

  • Alexa developer console (Test)

We also include the Jovo request and response JSONs.

Request:

{
   "version": "1.0",
   "session": {
      "new": false,
      "sessionId": "****************************************",
      "application": {
         "applicationId": "****************************************"
      },
      "attributes": {
         "_JOVO_STATE_": "State1"
      },
      "user": {
         "userId": "****************************************"
      }
   },
   "context": {
      "Viewports": [
         {
            "type": "APL",
            "id": "main",
            "shape": "RECTANGLE",
            "dpi": 213,
            "presentationType": "STANDARD",
            "canRotate": false,
            "configuration": {
               "current": {
                  "video": {
                     "codecs": [
                        "H_264_42",
                        "H_264_41"
                     ]
                  },
                  "size": {
                     "type": "DISCRETE",
                     "pixelWidth": 1280,
                     "pixelHeight": 800
                  }
               }
            }
         }
      ],
      "Viewport": {
         "experiences": [
            {
               "arcMinuteWidth": 346,
               "arcMinuteHeight": 216,
               "canRotate": false,
               "canResize": false
            }
         ],
         "shape": "RECTANGLE",
         "pixelWidth": 1280,
         "pixelHeight": 800,
         "dpi": 213,
         "currentPixelWidth": 1280,
         "currentPixelHeight": 800,
         "touch": [
            "SINGLE"
         ],
         "video": {
            "codecs": [
               "H_264_42",
               "H_264_41"
            ]
         }
      },
      "Extensions": {
         "available": {
            "aplext:backstack:10": {}
         }
      },
      "System": {
         "application": {
            "applicationId": "****************************************"
         },
         "user": {
            "userId": "****************************************"
         },
         "device": {
            "deviceId": "****************************************",
            "supportedInterfaces": {}
         },
         "apiEndpoint": "****************************************",
         "apiAccessToken": "****************************************”
      }
   },
   "request": {
      "type": "IntentRequest",
      "requestId": "****************************************",
      "locale": "es-ES",
      "timestamp": "2020-10-26T09:39:52Z",
      "intent": {
         "name": "MoreRecipesIntent",
         "confirmationStatus": "NONE"
      }
   }
}

Response:

{
   "version": "1.0",
   "response": {
      "shouldEndSession": false,
      "outputSpeech": {
         "type": "SSML",
         "ssml": "<speak>Fallback</speak>"
      },
      "reprompt": {
      },
      "reprompt": {
         "outputSpeech": {
            "type": "SSML",
            "ssml": "<speak>Fallback</speak>"
         }
      }
   },
   "sessionAttributes": {
      "_JOVO_STATE_": "State1"
   }
}

Is this the expected behaviour? We can modify something to make Alexa choose the next considered intent.

Best Regards,

Juan


#4

Answering from mobile, but I think you’re confused with what handles what in terms of intent matching and app logic. Basically, you provide a language model to Alexa, which then trains upon that model to learn to match different utterances to the specified intents. Alexa then sends a request to Jovo with the matched intent and other data, which you can then act upon in your handler. So, as Alexa matches the MoreRecipeIntent and you set the state to State1 (as you can see in the request object that you posted), Jovo tries to match this intent, but since you only provide SearchIntent in that state, it goes to Unhandled. What I would suggest you do is either tweak your language model further, so Alexa can match the correct intent, or to provide MoreRecipeIntent inside State1 and go to SearchIntent manually.