【发布时间】:2019-09-16 14:08:06
【问题描述】:
我在 lex 控制台中设置了一个机器人,它从用户那里收集数据,例如他们感兴趣的产品/服务以及电子邮件 ID、电话号码等。现在,每次访问者与机器人交互时,我都想接收包含聊天对话的电子邮件。
我还创建了一个由 lex 实现触发的 lambda 函数,但我在 bot ui 上收到此错误 发生错误:无效的 Lambda 响应:收到来自 Lambda 的无效响应:无法构造 IntentResponse 的实例:没有字符串-参数构造函数/工厂方法从字符串值反序列化
根据文档,我已重建响应并返回它。
import json
def lambda_handler(event, context):
print(event)
var1 = '''dialogAction": {
"type": "close",
"fulfillmentState": "fulfilled",
"message": {
"contentType": "PlainText or SSML or CustomPayload",
"content": "Message to convey to the user. For example, What size pizza would you like?"
},
}
}'''
return(var1)
这是错误的样子:-
An error has occurred: Invalid Lambda Response: Received invalid response from Lambda: Can not construct instance of IntentResponse: no String-argument constructor/factory method to deserialize from String value ('"dialogAction": { "type": "close", "fulfillmentState": "fulfilled", "message": { "contentType": "PlainText or SSML or CustomPayload", "content": "Message to convey to the user. For example, What size pizza would you like?" }, } }') at [Source: "\"dialogAction\": {\n \"type\": \"close\",\n \"fulfillmentState\": \"fulfilled\",\n \"message\": {\n \"contentType\": \"PlainText or SSML or CustomPayload\",\n \"content\": \"Message to convey to the user. For example, What size pizza would you like?\"\n },\n }\n }"; line: 1, column: 1]
【问题讨论】:
标签: python-3.x aws-lambda chatbot amazon-lex