Search code examples
amazon-lexaws-lex

How to access the raw input text and the entire conversation in AWS Lex


  1. How can I access to raw text the lead to the intent in lex
  2. How can I extract the entire conversation including the user input and the Lex responses

I thought of creating a lambda & API gateway to capture the input and record it before sending it to Lex , and on each intent lambda record the response , but seems like a round about way.


Solution

    1. In the event which you receive in Lambda function, you can get raw text from inputTranscript

    {'messageVersion': '1.0', 'invocationSource': 'DialogCodeHook', 'userId': '', 'sessionAttributes': {}, 'requestAttributes': {}, 'bot': {'name': 'bot_name', 'alias': 'bot_alias', 'version': '$LATEST'}, 'outputDialogMode': 'Text', 'currentIntent': {'name': 'invoked_intent_name', 'slots': {}, 'slotDetails': {}, 'confirmationStatus': 'None'}, 'inputTranscript': 'user message which triggered the intent'}

    1. For storing the conversation, in the Lambda function, just before you provide the response to the user, you can write a function to store the conversation i.e user query and response from bot.

    Hope it helps.