0

我已经使用以下流程构建了 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 resultsANDwho is my most active contact是各自意图的话语。

我正在使用 Alexa 测试控制台进行测试。在这两种情况下,我都在期待意图的名称 ( this.$request.getIntentName()),最后是

嗯,我不知道那个。

我的意图是通过使用调用名称唤醒技能,直接通过其话语调用意图。

有什么建议吗?

4

1 回答 1

1

我认为你应该分别对待这两个意图,而不是通过发布,因为例如在这种情况下

“Alexa,问谁是我最活跃的联系人”

Alexa跳过launch并直接跳转以解决意图ActiveContactIntent
因此,正如您拥有LAUNCH(){}功能一样,您还必须拥有CampaignIntent(){}and ActiveContactIntent(){}。这样你就可以避免 Alexa 回答

嗯,我不知道那个。

要验证用户是否已经关联了他的帐户,您必须输入如下代码:

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

我建议您查看有关“使用 jovo 路由”的文档,以便更清楚地了解该主题。您可以在以下链接查看它: https ://www.jovo.tech/docs/routing

于 2020-10-13T17:17:51.380 回答