我已经使用以下流程构建了 Alexa 技能:
LAUNCH -> AccountLinkingIntent -> CampaignIntent
在AccountLinkingIntent
,目前我正在路由到CampaignIntent
如果 Account 已经链接。
到目前为止,一切正常。现在我必须添加另一个 IntentActiveContactIntent
以便流程变为:
LAUNCH -> AccountLinkingIntent -> CampaignIntent / ActiveContactIntent
即,从AccountLinking
我需要决定路由到哪个 Intent。
调用是这样的(CampaignIntent):
Alexa, ask <invocation_name> to get my latest campaign result
或(ActiveContactIntent)
Alexa, ask <invocation_name> who is my most active contact
根据话语,我需要告诉 Alexa 去哪里。到目前为止,我有以下内容AccountLinkingIntent
...返回 this.toIntent("CampaignIntent"); ...
但现在我需要做出与此相同的决定:
...
if( ... ) {
return this.toIntent("CampaignIntent");
} else {
return this.toIntent("ActiveContactIntent");
}
...
有什么方法可以IntentName
通过话语获得,以便我可以通过相同的方式进行检查,例如:
...
if( intent_name_by_utterance === "CampaignIntent" ) {
return this.toIntent("CampaignIntent");
} else {
return this.toIntent("ActiveContactIntent");
}
...
或者,如果有可能,如果允许传递变量intent_name_by_utterance
,我也可以将值作为方法的参数传递!toIntent
return this.toIntent(intent_name_by_utterance);
更新:
我尝试了以下方法来查看是否返回了意图名称:
LAUNCH() { return this.toIntent("LinkAccountIntent"); },
异步 LinkAccountIntent() { const intent_name = this.$request.getIntentName(); this.tell( Current intent is: ${intent_name}
); },
以以下两种方式调用该技能:
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
ANDwho is my most active contact
是各自意图的话语。
我正在使用 Alexa 测试控制台进行测试。在这两种情况下,我都在期待意图的名称 ( this.$request.getIntentName()
),最后是
嗯,我不知道那个。
我的意图是通过使用调用名称唤醒技能,直接通过其话语调用意图。
有什么建议吗?