【问题标题】:Alexa Intent sends two requests and failsAlexa Intent 发送两个请求并失败
【发布时间】:2017-10-30 23:24:46
【问题描述】:

我想做的事:

我有一个非常简单的 Alexa Skill 可以监听命令词:

{
    "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_decoded 请求和我发送回亚马逊的响应编写一个日志文件。我也在使用测试工具,但这给了我The remote endpoint could not be called, or the response it returned was invalid.。我知道它可以调用我的端点,因为我每次看到写入的日志文件。

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

【问题讨论】:

    标签: alexa-skill


    【解决方案1】:

    尝试使用 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>"
        }
      }
    }
    

    【讨论】:

      【解决方案2】:

      您遇到的错误...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' =&gt; false

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

      【讨论】:

        猜你喜欢
        • 2020-04-06
        • 2016-02-22
        • 2013-12-26
        • 2019-05-09
        • 2019-03-31
        • 2020-11-09
        • 1970-01-01
        • 1970-01-01
        • 1970-01-01
        相关资源
        最近更新 更多