这是我调用AWS Lambda函数后得到的错误。
发生了一个错误。Invalid Lambda Response: 收到来自Lambda的无效响应。无法构造IntentResponse实例:没有String-argument constructorfactory方法从String值('Thanks, your pizza has been ordered.')反序列化在[Source: "Thanks, your pizza has been ordered."; line: 1, column: 1]。
exports.handler = async (event) => {
const response = {
"dialogAction": {
"type": "Close",
"fulfillmentState": "Fulfilled or Failed",
"message": {
"contentType": "PlainText or SSML",
"content": "Thanks, your pizza has been ordered."
}
}
};
return response.dialogAction.message.content;
};
看起来你的响应是从一个示例文档中获取的。
"dialogAction": {
"type": "Close",
"fulfillmentState": "Fulfilled or Failed",
"message": {
"contentType": "PlainText or SSML",
"content": "This example won't work as is."
}
}
很多人都犯了同样的错误,但是对于这两个人来说 fulfillmentState
和 contentType
您必须选择其中之一或其他示例值,并完全按照所示的正确大写。
所以要说明的是
设置 fulfillmentState
到任一 Fulfilled
或 Failed
还有
设置 contentType
的信息,到任何 PlainText
或 SSML
"dialogAction": {
"type": "Close",
"fulfillmentState": "Fulfilled",
"message": {
"contentType": "PlainText",
"content": "This is a proper example response."
}
}