3
votes

Consider the following scenario (U=User, L=Lex):

U1: Hello

L1: Hello, please give me your name to get started.

U2: Bob

L2: Bob, consider the following question: What colour is the sky?

U3: The sky is usually blue but sometimes the sky is red.

The system reads a database of questions and randomly chooses one to present to the user. This is done via AWS Lambda and the question is presented to the user in message L2.

Is there any way to say that 'the next response from the user should be treated as their answer to the question without defining utterances etc? This is because the questions that the bot sends across can vary to a great degree.

I need a way to pass all of block U3 back to Lambda for processing. How would I achieve this regardless of context? (I am using python for Lambda)

Thanks

1
DialogFlow is better suited for this particular use case.sid8491

1 Answers

1
votes

Lex always passes the entire user's input in the Request under the field inputTranscript.

Lex-Lambda Event Format:

inputTranscript – The text used to process the request.

If the input was text, the inputTranscript field contains the text that was input by the user.

If the input was an audio stream, the inputTranscript field contains the text extracted from the audio stream. This is the text that is actually processed to recognize intents and slot values.

This is the format of the Lex Request received by Lambda as event:

{
  "currentIntent": {
    "name": "intent-name",
    "slots": {...},
    "slotDetails": {...},
    "confirmationStatus": "(None, Confirmed, or Denied)"
  },
  "bot": {...},
  "userId": "XXXX",
  "invocationSource": "(FulfillmentCodeHook or DialogCodeHook)",
  "outputDialogMode": "(Text or Voice)",
  "messageVersion": "1.0",
  "sessionAttributes": {...},
  "requestAttributes": {...}
  "inputTranscript": "Text of full user's input utterance",
}

So in Lambda, you can access the inputTranscipt with:

userInput = event.inputTranscript