Is this possible to get IntentName by utterance? How can I decide which intent to jump to based on user utterance?


#1

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);

#2

Not sure if I get you right.

Alexa, ask <invocation_name> to get my latest campaign result
and
Alexa, ask <invocation_name> who is my most active contact

are utterances of the same intent? (AccountLinkingIntent)

AccountLinkingIntent() uses toIntent() to navigate to CampaignIntent or ActiveContactIntent which are in the handler, but not in the language model?


#3

Sorry for late reply. In fact I got it to work by handling a session variable and redirecting to my desired intent from YES intent based on the current value in the said session variable.