Alexa Intent发送两个请求并失败



我要做的事情:

我有一个非常简单的Alexa技能,它可以收听命令词:

{
"intents": [{
"intent": "AffiliateEmpire",
"slots": [
{
"name": "affiliate_action",
"type": "AFFILIATE_ACTIONS"
},
{
"name": "date",
"type": AMAZON.DATE
}
}]
}

自定义插槽类型为:

AFFILIATE_ACTIONS   commissions | earnings | sales | summary

我的话语示例是:

AffiliateEmpire for affiliate {affiliate_action}
AffiliateEmpire get {affiliate_action} for {date}

这与我的PHP服务器通信,我在那里监听请求类型。

问题出在哪里

当我在没有任何意图的情况下调用命令字时,它会向我的服务器发出"LaunchRequest",并正确地返回cardoutputSpeech

如果我请求意向,它会向我的服务器发送IntentRequest,但也会发送SessionEndedRequest

我处理IntentRequest,并按照以下行向它发送一个json编码的响应:

array(
'version'           => '1.0',
'response'          => array(
'outputSpeech' => array(
'type' => 'PlainText',
'text' => 'Some simple response'
)),
'shouldEndSession'  => true,
'sessionAttributes' => array()
));

我的Amazon Echo从不说Some simple response,而是给我There was a problem communicating with the requested skill

在此之前,我也有类似的工作技能,但我看不出自己做错了什么。

我已经试过了

我使用php为每个原始请求、json_edecoded请求和我发送回亚马逊的响应编写一个日志文件。我也在使用测试工具,但是这给了我The remote endpoint could not be called, or the response it returned was invalid.。我知道它可以在每次看到写入的日志文件时调用我的端点。

为什么它调用了我的意图,却通过结束会话导致错误?

尝试SSML来响应alexa请求,例如:

{
"version": "1.0",
"response": {
"directives": [],
"shouldEndSession": false,
"outputSpeech": {
"type": "SSML",
"ssml": "<speak>I am going to book a cab for you @ your provided time.</speak>"
}
}
}

您得到的错误。。。endpoint could not be called, or the response it returned was invalid表明您发送回Alexa服务的json格式不正确。您正在接收请求,这就是记录请求的方式。现在,您只需要对发送回的响应进行故障排除。很可能是小事情。以下是json响应格式的文档:https://developer.amazon.com/docs/custom-skills/request-and-response-json-reference.html.如果您可以共享php代码的json输出,那么将更容易帮助进行故障排除。

此外,我认为您需要更改为'shouldEndSession' => false

array(
'version'           => '1.0',
'response'          => array(
'outputSpeech' => array(
'type' => 'PlainText',
'text' => 'Some simple response'
)),
'shouldEndSession'  => false,
'sessionAttributes' => array()
));

最新更新