Warning: file_get_contents(/data/phpspider/zhask/data//catemap/1/amazon-web-services/14.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Amazon web services 收到来自Lambda的无效响应:无法构造IntentResponse的实例_Amazon Web Services_Aws Lambda_Aws Lex - Fatal编程技术网

Amazon web services 收到来自Lambda的无效响应:无法构造IntentResponse的实例

Amazon web services 收到来自Lambda的无效响应:无法构造IntentResponse的实例,amazon-web-services,aws-lambda,aws-lex,Amazon Web Services,Aws Lambda,Aws Lex,我一直在尝试aws lex上的lambda代码钩子,这就是我将返回的响应 response = { "dialogAction" : { "type": "ElicitSlot", "message": { "contentType": "PlainText", "content": "Please make enter

我一直在尝试aws lex上的lambda代码钩子,这就是我将返回的响应

response = {
            "dialogAction" : {
                "type": "ElicitSlot",
                "message": {    
                    "contentType": "PlainText",
                    "content": "Please make enter value of slot1 first before proceeding."
                },
              "intentName": "AWSLexIntentName",
              "slots": {
                    "slot1" : null,
                    "slot2" : null,
                    "slot3" : null,
                    "slot4" : null,
                    "slot5" : null
              },
              "slotToElicit" : "slot1"
            }
        }
我已经尝试过使用lambda测试事件对其进行测试,但在Lex上进行测试时,我一直会遇到错误

An error has occurred: Invalid Lambda Response: Received invalid response from Lambda: Can not construct instance of IntentResponse, problem: The validated object is null at [Source: {}; line: 1, column: 2]

我对amazon web服务还是新手,在编程方面没有太多的知识,但我无法追溯这个错误,因为在我的任何代码或amazon文档中都找不到这个“源”键。也感谢您花时间阅读此文章。

好吧,我明白了Lex机器人没有任何价值的原因。在我的lambda处理程序中,我收到一个函数的承诺,该函数解析我需要的响应。在处理程序内部,我通过使用promise.then(data,function(){//do stuff})接收此解析,在then函数内部,我返回包含响应的数据值

这导致处理程序返回一个未定义的值,因此我所做的是使用lambda的回调功能而不是返回


很抱歉,如果解释令人困惑,因为我也不清楚这是为什么以及如何工作的。

有没有可能返回的响应是空的?您能说明如何返回该响应吗?回调可能包含两个参数,第一个是错误,第二个是响应。因此,一个常见的错误是调用回调函数并只提供响应(作为错误发送),而实际响应参数为空。我没有使用回调函数。我一直以json文件的形式返回它。看起来使用回调解决了这个问题,因为我一直在使用Promissions,所以不是返回语句将它返回给Lex bot,而是将它返回给另一个then()语句。谢谢。好的,接下来的问题是,如何关闭此线程?