How to troubleshoot this AWS lambda error - An error has occurred: Received error response from Lambda: Unhandled?

江枫思渺然 提交于 2019-11-28 13:59:46

The communication between Lex and Lambda is not straight forward like normal functions. Amazon Lex expects output from Lambda in a particular JSON format and data like slot details etc are also sent to Lambda in a similar JSON. You can find the blueprints for them here: Lambda Function Input Event and Response Format. Make sure your C# code also return a JSON in the similar fashion, so that Lex can understand and do the further processing.

Hope it helps!

Here is what worked for me:

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.

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!