这是我在调用 AWS Lambda 函数后收到的错误:
发生错误:无效的 Lambda 响应:收到来自 Lambda 的无效响应:无法构造 IntentResponse:没有字符串参数构造函数/工厂方法可以从字符串值反序列化("谢谢,您的披萨已订购"(,位于 [来源:"谢谢,您的披萨已订购。
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."
}
}