alexa-skills-kitjovo-framework

Alexa voice with Jovo Framework: Is this possible to get IntentName by utterance? How can I decide which intent to jump to based on user utterance?


I have built an Alexa skill with the following flow:

LAUNCH -> AccountLinkingIntent -> CampaignIntent

In AccountLinkingIntent, presently I am routing to CampaignIntent if Account is already linked.

Up to this everything is working fine. Now I have to add another Intent ActiveContactIntent so that the flow becomes:

LAUNCH -> AccountLinkingIntent -> CampaignIntent / ActiveContactIntent i.e, From AccountLinking I need to decide which Intent to route to.

The invocation goes like this (CampaignIntent):

Alexa, ask <invocation_name> to get my latest campaign result

OR (ActiveContactIntent)

Alexa, ask <invocation_name> who is my most active contact

Based on the utterance, I need to tell Alexa where to go. So far I have the following in AccountLinkingIntent

... return this.toIntent("CampaignIntent"); ...

But now I need to decide the same as this:

...
if( ... ) {
   return this.toIntent("CampaignIntent");
} else {
   return this.toIntent("ActiveContactIntent");
}
...

Is there any way to get the IntentName by the utterance so that I can check by the same such as:

...
if( intent_name_by_utterance === "CampaignIntent" ) {
   return this.toIntent("CampaignIntent");
} else {
   return this.toIntent("ActiveContactIntent");
}
...

Or probably, if it is possible to get intent_name_by_utterance I may also pass the value as the argument of toIntent method if it is allowed to pass a variable!

return this.toIntent(intent_name_by_utterance);

UPDATE:

I have tried the following to see whether the intent name is being returned:

LAUNCH() { return this.toIntent("LinkAccountIntent"); },

async LinkAccountIntent() { const intent_name = this.$request.getIntentName(); this.tell(Current intent is: ${intent_name}); },

Invoked the skill in following two fashions:

Alexa, ask <invocation-name> to give me my latest campaign results

Alexa, ask <invocation-name> who is my most active contact

give me my latest campaign results AND who is my most active contact are the utterances for respective intents.

I am using Alexa Test console for testing. In both cases, I was expecting the name of the intent (this.$request.getIntentName()), ending up with

Hmm, I don't know that one.

My intention is to call an intent by its utterance directly by waking up the skill using its invocation name.

Any suggestion?


Solution

  • I think you should treat both intends separately and not through the launch, because for example in the case

    "Alexa, ask who is my most active contact"

    Alexa skips the launch and jumps directly to resolve the intend ActiveContactIntent.
    So just as you have the LAUNCH(){} function you must also have CampaignIntent(){} and ActiveContactIntent(){}. That way you will avoid Alexa answering

    Hmm, I don't know that one.

    To verify that the user has already linked his account, you would have to enter a code like the one below:

    if (!this.$request.getAccessToken()) {
            this.$alexaSkill.showAccountLinkingCard();
            this.tell('Please link you Account');
        } else {
            //code for your respective action
        }
    

    I recommend you to check the documentation about "routing with jovo" to have a little more clarity about this topic. You can review it at the following link: https://www.jovo.tech/docs/routing