首页 > 解决方案 > 亚马逊 lex 响应中的反序列化错误

问题描述

我已将 Amazon Lex 与 Amazon Lambda 连接,我测试了 Amazon Lambda,它按预期工作。

我从 Amazon Lambda 得到以下响应(使用云手表测试):

 {'sessionAttributes': {}, 'dialogAction': {'type': 'ElicitSlot', 'intentName': 'paymentdue', 'slots': {}, 'slotToElicit': '', 'message': 'This is a test message', 'responseCard': '', 'fulfillmentState': 'Fulfilled'}}

但我从 amazon lex 收到以下错误:这里可能是什么问题?

An error has occurred: Invalid Lambda Response: Received invalid response from Lambda: 
Can not construct instance of Message: no String-argument constructor/factory method to deserialize from String value 
('This is a test message') at [Source: {"sessionAttributes": {}, "dialogAction": {"type": "ElicitSlot", "intentName": "paymentdue", "slots": {}, "slotToElicit": "", "message": "This is a test message", "responseCard": "", "fulfillmentState": "Fulfilled"}}; line: 1, column: 138]

有人可以让我知道这个问题吗?

谢谢,
哈利

标签: amazon-web-servicesaws-lambdaamazon-lex

解决方案


当响应类型为ElicitSlot时,Lex 期望看到message如下字段:

"message": {
      "contentType": "PlainText or SSML or CustomPayload",
      "content": "Message to convey to the user. For example, What size pizza would you like?"
    }

您的响应是一个字符串,而不是一个对象。请参阅此处了解更多信息。


推荐阅读