Search code examples
c#amazon-web-servicesaws-lambdaamazon-lex

Intercepting AWS Lambda Response to a AWS Lex Query


I'm part of a team that is trying to integrate AWS Lex into one of our web applications. Currently, the approach that we are going for is one where the user asks Lex to run a SQL query. Lex will then decide the appropriate intent based on the user's question (I.E if user wants to search using value A, Lex will choose intent A) and send this information back to our web application which will then run the appropriate method for executing the SQL query (where method name matches the intent name).

To recap, what we want to do is as follows:
1) User tells Lex that they want to search for data using Value A
2) Lex determines the correct intent (Intent A)
3) Lex sends this information to Lambda which then returns the intent name to the web client
4) Our web application intercepts this response from Lambda and executes the correct method
5) Results shown to the user via Lex.

My question is whether or not this is possible, particularly the intercepting of the Lambda response. If so, can anyone please point me to the relevant information as to where I can read up on how to implement this? I've been searching for the last couple of days and have not found any relevant materials for this particular use case.

Thanks a lot!


Solution

    1. User tells Lex that they want to search for data using Value A
    2. Lex determines the correct intent (Intent A)

    I think you should be using single intent and different slots for this, it will be more efficient.

    1. Lex sends this information to Lambda which then returns the intent name to the web client
    2. Our web application intercepts this response from Lambda and executes he correct method

    You should write a Rest API at your web server which will get the data and return output. In your Lambda function you can write simple HTTP request/post method do request the api and get the response.

    1. Results shown to the user via Lex

    After you get the response you can simply return the response to the bot using Close.

    Hope it helps.