首页 > 解决方案 > alexa 技能的 INVALID_SKILL_RESPONSE

问题描述

我刚刚开始为 Alexa 技能构建自己的 Web 服务。

我的 Web 服务支持 HTTPS,当我使用 alexa 模拟器进行测试时,端点被命中,但我收到错误“INVALID_SKILL_RESPONSE”。

这是我的 php 代码的简单响应:

    return response(
        [
            'version' => '1.0',
            'response' => [
                'outputSpeech' => [
                    'type' => 'PlainText',
                    'text' => 'Hello world',
                ]
            ]
        ],
        200,
        [
            'Content-Type' => 'application/json',
        ]
    );

什么可能导致问题?

标签: alexa-skills-kitalexa-skill

解决方案


我不确定这个response功能是从哪里来的。尝试这样的事情:

<?php
$responseArray = [
        'version' => '1.0',
        'response' => [
              'outputSpeech' => [
                    'type' => 'PlainText',
                    'text' => 'Hello World'
              ],
              'shouldEndSession' => true
        ]
  ];

header( 'Content-Type: application/json' );
echo json_encode( $responseArray );

?>

推荐阅读