aws-lex-web-ui icon indicating copy to clipboard operation
aws-lex-web-ui copied to clipboard

We want to put AWS API Gateway between AWS LEX and AWS Lex Web UI

Open PranaliYangandul912 opened this issue 1 year ago • 2 comments

The AWS Lex Web UI sample - https://github.com/aws-samples/aws-lex-web-ui code on github calls lex directly from UI

We want to call lex from AWS Lambda , integrate this lambda with API Gateway And use this API Gateway endpoint in UI to trigger the lambda which will call lex But we are facing some challenges in response formats We have used AWS SDK recognizeText method to call lex from lambda , this method immediately returns the response and data parameter is always null Also We are not able to structure the response as we are getting different response formats after integrating UI with API Gateway.

PranaliYangandul912 avatar Aug 24 '22 05:08 PranaliYangandul912

@PranaliYangandul912 Sounds like you are not using the lex-web-ui and your question is centered around calling lex runtime api from a lambda. Probably best to post this question in an AWS support forum for lex runtime. The lex-web-ui implementation calls lex runtime api directly. My first inclination is that your lambda is running in asynchronous mode when calling lex runtime and is not waiting for the response from lex runtime api. Hence response will not contain valid values. What language are you using?

bobpskier avatar Aug 26 '22 13:08 bobpskier

I am using Nodejs Language in Lambda. I am using this recognizeText method and i am getting immediate response having data parameter as null , its not waiting for actual response. you can refer below lambda code for calling lex The lex web ui directly calls lex and UI waits for response , can we mimic this from AWS Lambda , can lambda wait for response and can API Gateway send this back to UI?

var AWS = require('aws-sdk'); AWS.config.region = 'us-east-1'; var lexruntimev2 = new AWS.LexRuntimeV2(); exports.intents = async (event, context, callback) => { let response; try {

let lexparams={

     botAliasId: '',
     botId: '',
     localeId: 'en_US',
     sessionId: 'test_session',
     text: 'help',
     sessionState: {
    sessionAttributes: { 'uniqueId':"1234" }
      }
    }
    response=await lexruntimev2.recognizeText(lexparams)
 
}catch(e) {
	console.log(e);

}
console.log(response)

// return response

};

PranaliYangandul912 avatar Aug 26 '22 14:08 PranaliYangandul912