从AWS Lambda函数获得对AWS Lex bot的响应会出错吗?
我创建了一个AWS Lex
机器人,并且正在从该bot调用一个lambda
函数.测试lambda
函数时,我得到了正确的响应,但是在机器人程序中,我得到了以下错误:
I have created one AWS Lex
bot and I am invoking one lambda
function from that bot. When testing the lambda
function I am getting proper response but at bot I am getting below error:
发生错误:收到来自Lambda的无效响应:不能 构造IntentResponse的实例:无字符串参数 从字符串值反序列化的构造函数/工厂方法 ('2017-06-22 10:23:55.0'),网址为[Source:"2017-06-22 10:23:55.0";线: 1,列:1]
An error has occurred: Received invalid response from Lambda: Can not construct instance of IntentResponse: no String-argument constructor/factory method to deserialize from String value ('2017-06-22 10:23:55.0') at [Source: "2017-06-22 10:23:55.0"; line: 1, column: 1]
不确定,哪里出了问题以及我在哪里失踪.有人可以帮我吗?
Not sure, what is wrong and where I am missing. Could anyone assist me please?
上述问题的解决方案是,我们需要确保在AWS lex chat bot上使用的lambda函数返回的响应应采用以下格式:
The solution to above problem is that we need to make sure response returned by lambda function, to be used at AWS lex chat bot should be in below format:
{
"sessionAttributes": {
"key1": "value1",
"key2": "value2"
...
},
"dialogAction": {
"type": "ElicitIntent, ElicitSlot, ConfirmIntent, Delegate, or Close",
Full structure based on the type field. See below for details.
}
}
通过这种方式,聊天机器人需要DialogAction和相应的元素来处理消息,即IntentResponse.
By this, chat bot expectd DialogAction and corresponding elements in order to process the message i.e. IntentResponse.
参考: http://docs .aws.amazon.com/lex/latest/dg/lambda-input-response-format.html