如何解决此 AWS lambda 错误 - 发生错误:收到来自 Lambda 的错误响应:未处理? [英] How to troubleshoot this AWS lambda error - An error has occurred: Received error response from Lambda: Unhandled?
问题描述
我是 AWS 的新手.我正在使用 aws lex 和 aws lambda c# 构建聊天机器人.我正在使用示例 aws lambda C# 程序
I'm new to AWS. I'm build chatbot using aws lex and aws lambda c#. I'm using sample aws lambda C# program
namespace AWSLambda4
{
public class Function
{
/// <summary>
/// A simple function that takes a string and does a ToUpper
/// </summary>
/// <param name="input"></param>
/// <param name="context"></param>
/// <returns></returns>
public string FunctionHandler(string input, ILambdaContext context)
{
try
{
return input?.ToUpper();
}
catch (Exception e)
{
return "sorry i could not process your request due to " + e.Message;
}
}
}
}
我在 aws lex 中创建了一个槽来映射第一个参数 input .但我总是收到此错误发生错误:收到来自 Lambda 的错误响应:未处理
I created a slot in aws lex to map first parameter input . But i'm always getting this error An error has occurred: Received error response from Lambda: Unhandled
在 Chrome 网络选项卡中,我可以看到与身份验证相关的 Error- 424 Failed Dependency.
In Chrome network tab i could see Error- 424 Failed Dependency which is related to authentication.
请帮助如何解决 aws lex 使用的 AWS lambda C# 错误.我遇到了 cloudwatch,但我不确定.
Please help how to troubleshoot AWS lambda C# error which is used by aws lex. I came across cloudwatch but I'm not sure about that.
谢谢!
推荐答案
这对我有用:
Lex 以 LexEvent
类类型发送请求,并期待 LexResponse
类类型的响应.所以我将参数从 string
更改为 LexEvent
并将类型从 string
返回到 LexResponse
.
Lex sends request in LexEvent
Class type and expects response in LexResponse
Class type.So i changed my parameter from string
to LexEvent
and return type from string
to LexResponse
.
public LexResponse FunctionHandler(LexEvent lexEvent, ILambdaContext context)
{
//Your logic goes here.
IIntentProcessor process;
switch (lexEvent.CurrentIntent.Name)
{
case "BookHotel":
process = new BookHotelIntentProcessor();
break;
case "BookCar":
process = new BookCarIntentProcessor();
break;
case "Greetings":
process = new GreetingIntentProcessor();
break;
case "Help":
process = new HelpIntentProcessor();
break;
default:
throw new Exception($"Intent with name {lexEvent.CurrentIntent.Name} not supported");
}
return process.Process(lexEvent, context);// This is my custom logic to return LexResponse
}
但我不确定问题的根本原因.
But i'm not sure about the root cause of the issue.
这篇关于如何解决此 AWS lambda 错误 - 发生错误:收到来自 Lambda 的错误响应:未处理?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!