- Newest
- Most votes
- Most comments
Please share a little more background. Are you talking about Lex that you want to capture the slot value?
For a generic answer, once you have output the entire contents of an event, check its structure and the location of the expected value.
As mentioned above you need to get the slot object from the intent on the sessionState:
event.sessionState.intent.slots.mySlot.value
However, this will get you the whole slot object which looks like this (in its most basic form):
{
mySlot: {
"shape": "Scalar",
"value": {
"originalValue": string,
"interpretedValue": string,
"resolvedValues": [
string,
...
]
}
}
}
So to get the actual resolved string assigned to the slot you need to get the interpretedValue from the value object:
event.sessionState.intent.slots.mySlot.value.interpretedValue
The originalValue is the text from the utterance, the interpretedValue is the final resolved value, and the resolvedValues array is other options that the slot could resolve to. Check out the docs to see more about the Slot object https://docs.aws.amazon.com/lexv2/latest/dg/lambda-common-structures.html#lambda-slot (especially if you are using multi-value or composite, as the syntax to get the final value will differ).
You can see some example code here: https://github.com/aws-samples/amazon-lex-v2-lambda-integration-examples/blob/main/src/reminderBotLex2Lambda/intentHandlers/callIntentHandler.ts
Relevant content
- asked 9 months ago
- asked 3 months ago
- AWS OFFICIALUpdated 7 months ago
- AWS OFFICIALUpdated 6 months ago
- AWS OFFICIALUpdated 2 years ago
- AWS OFFICIALUpdated 3 years ago
I am working on Lex v2. While invoking hook (Lambda) from conditional branch I wish to set slot value, which should be fetched by Lambda.
I recommend outputting the contents of an event as in the first answer to check the structure.
I assume the value you seek is "event.sessionState.intent.slots.mySlot.value".
https://docs.aws.amazon.com/lexv2/latest/dg/lambda-input-format.html