我想通过 Lambda 集成将 Amazon Lex Chatbot 中给出的输入存储在 Amazon DynamoDB 中。如何处理来自 Amazon Lambda 的响应。我收到的错误为 - (发生错误:无效的 Lambda 响应:从 Lambda 收到无效响应:意外的 token (END_OBJECT),预期的 FIELD_NAME:缺少包含类型 id 的属性“类型”(对于类 DialogAction )在 [来源:{"dialogAction":{"Type":"Close","fulfillmentState":"failed","message":{"ContentType":"PlainText","Content":"嘿 null,您的请求nullTickets on null at null"}}};行:1,列:164] )
请帮忙解决这个问题。我的 Amazon Lambda 代码如下,
exports.handler = (事件、上下文、回调) => {
var Name = event.currentIntent.slots.Name;
var TicketType = event.currentIntent.slots.TicketType;
var BookingDate = event.currentIntent.slots.BookingDate;
var BookingTime = event.currentIntent.slots.BookingTime;
callback(null, {
"dialogAction": {
"Type":"Close",
"fulfillmentState": "failed",
"message": {
"ContentType": "PlainText",
"Content": "Hey " +Name+ ", Your Requested "+ TicketType + "Tickets on " +BookingDate+" at " +BookingTime+"" ,
}
}
})
}
最佳答案
以下是 Lambda 对 Lex 的典型响应。
“type”有拼写错误,请使用小写(“type”而不是“Type”)
{
"sessionAttributes": {
"key1": "value1",
"key2": "value2"
...
},
"recentIntentSummaryView": [
{
"intentName": "Name",
"checkpointLabel": "Label",
"slots": {
"slot name": "value",
"slot name": "value"
},
"confirmationStatus": "None, Confirmed, or Denied (intent confirmation, if configured)",
"dialogActionType": "ElicitIntent, ElicitSlot, ConfirmIntent, Delegate, or Close",
"fulfillmentState": "Fulfilled or Failed",
"slotToElicit": "Next slot to elicit
}
],
"dialogAction": {
"type": "ElicitIntent, ElicitSlot, ConfirmIntent, Delegate, or Close",
Full structure based on the type field.
}
}
关于amazon-web-services - 如何处理对 Amazon Lex 的 lambda 响应?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/60097648/