使用Alexa Simulator时,请求的技能响应存在问题,但与Manual JSON一起使用

时间:2018-02-05 11:47:30

标签: alexa alexa-skills-kit alexa-skill alexa-voice-service

我在新创建的alexa技能方面遇到了一些问题。

在Alexa Simulator的文本框中键入请求始终返回"请求的技能响应"存在问题。输出JSON低于。

{
  "body":{
    "version":"1.0",
    "response":{
      "outputSpeech":{
        "type":"PlainText",
        "text":"Hello i am here"
      },
      "card":{
        "type":"Simple",
        "title":"Welcome",
        "content":"Hello i am here"
      },
      "directives":[
        {
          "type":"Display.RenderTemplate",
          "template":{
            "type":"BodyTemplate2",
            "token":"",
            "backgroundImage":{
              "contentDescription":"Description for the background image",
              "sources":[
                {
                  "url":"URL for the background image - must be secure (https)",
                  "size":"x-small",
                  "widthPixels":0,
                  "heightPixels":0
                }
              ]
            },
            "image":{
              "contentDescription":"Description for the main image",
              "sources":[
                {
                  "url":"URL for the main image - must be secure (https)",
                  "size":"x-small",
                  "widthPixels":0,
                  "heightPixels":0
                }
              ]
            },
            "title":"Welcome",
            "textContent":{
              "primaryText":{
                "type":"RichText",
                "text":"Welcome"
              },
              "secondaryText":{
                "type":"RichText",
                "text":"Hello i am here"
              }
            },
            "backButton":"HIDDEN"
          }
        }
      ],
      "shouldEndSession":false
    },
    "sessionAttributes":{

    }
  }
}

但是,当我从请求中复制JSON输入和用户手动JSON进行测试时,它的效果非常好,但返回的JSON格式略有不同

{
  "status":"SUCCESSFUL",
  "result":{
    "skillExecutionInfo":{
      "invocationRequest":{
        "endpoint":"url here",
        "body":{
          "version":"1.0",
          "session":{
            "new":true,
            "sessionId":"amzn1.echo-api.session.b62b79ba-1dde-4b22-9bf5-492943a008bc",
            "application":{
              "applicationId":"amzn1.ask.skill.7c4d08db-82be-4e18-9a62-7a95c58dd69f"
            },
            "user":{
              "userId":"amzn1.ask.account."
            }
          },
          "context":{
            "AudioPlayer":{
              "playerActivity":"IDLE"
            },
            "Display":{

            },
            "System":{
              "application":{
                "applicationId":"amzn1.ask.skill.7c4d08db-82be-4e18-9a62-7a95c58dd69f"
              },
              "user":{
                "userId":"amzn1.ask.account."
              },
              "device":{
                "deviceId":"amzn1.ask.device.",
                "supportedInterfaces":{
                  "AudioPlayer":{

                  },
                  "Display":{
                    "templateVersion":"1.0",
                    "markupVersion":"1.0"
                  }
                }
              },
              "apiEndpoint":"https://api.amazonalexa.com",
              "apiAccessToken":"eyJ0eXAiOiJKV1"
            }
          },
          "request":{
            "type":"LaunchRequest",
            "requestId":"amzn1.echo-api.request.",
            "timestamp":"2018-02-05T11:35:53Z",
            "locale":"en-GB"
          }
        }
      },
      "invocationResponse":{
        "body":{
          "response":{
            "card":{
              "type":"Simple",
              "title":"Welcome",
              "content":"Hello i am here"
            },
            "directives":[
              {
                "template":{
                  "type":"BodyTemplate2",
                  "token":"",
                  "title":"Welcome",
                  "textContent":{
                    "primaryText":{
                      "type":"RichText",
                      "text":"Welcome"
                    },
                    "secondaryText":{
                      "type":"RichText",
                      "text":"Hello i am here"
                    }
                  },
                  "backButton":"HIDDEN",
                  "backgroundImage":{
                    "contentDescription":"Description for the background image",
                    "sources":[
                      {
                        "url":"URL for the background image - must be secure (https)",
                        "size":"X_SMALL",
                        "widthPixels":0,
                        "heightPixels":0
                      }
                    ]
                  },
                  "image":{
                    "contentDescription":"Description for the main image",
                    "sources":[
                      {
                        "url":"URL for the main image - must be secure (https)",
                        "size":"X_SMALL",
                        "widthPixels":0,
                        "heightPixels":0
                      }
                    ]
                  }
                },
                "type":"Display.RenderTemplate"
              }
            ],
            "outputSpeech":{
              "type":"PlainText",
              "text":"Hello i am here"
            },
            "shouldEndSession":false
          },
          "sessionAttributes":{

          },
          "version":"1.0"
        }
      },
      "metrics":{
        "skillExecutionTimeInMilliseconds":254
      }
    },
    "error":null
  }
}

知道问题可能是什么感谢。

1 个答案:

答案 0 :(得分:1)

对于遇到相同问题的任何人。如果响应中包含0:000> dd 0x03966ce8+0x008 L1 // for a CStringArray, m_nSize is at memory address +0x008 // L1 means: limit the amount of answers to one byte 03966cf0 00000010 // the result only contains one line. 指令,请确保在Alexa开发人员控制台上启用了显示界面。

从您熟练掌握的Alexa开发人员控制台中,导航至Display.RenderTemplate并确保已启用Interfaces