Can anyone provide any insight on exactly how to use the inputTranscript lex event to feed that input back to a slot as its value, to allow for an open slot type? I can capture the user input no problem, its just sending it back as the slot value where I'm encountering issues. From what I can see from researching, this is the best way to accomplish the ability to accept any value into a slot. I just cant seem to be able to actually get it to work. I've read a few posts stating to create the slot, then use the elicit slot function but nothing out there is very detailed. Thanks
Asked
Active
Viewed 805 times
1 Answers
1
Suppose you have a slot anyString
in your intent.
First thing you need to do is uncheck the required checkbox for this slot.
Now in Options, choose Initialization and validation code hook
and select your Lambda function.
IN DialogCodeHook
we can grab the user input and assign it to our slot anyString
using below code:
slots = intent_request['currentIntent']['slots']
slots['anyString'] = intent_request['inputTranscript']
You can read more about dialogAction
here.
Hope it helps.

sid8491
- 6,622
- 6
- 38
- 64
-
Exactly what @sid said, and we just pass the updated `slots` array back to Lex through the`elicitSlot` function. – Jay A. Little Jan 08 '19 at 14:43
-
@JayA.Little pass the `slots` array back to Lex for what? `elicitSlot` is used for re-prompting the value for slot, right? – sid8491 Jan 08 '19 at 16:00
-
Thanks guys. @JayA.Little Just a question though when using the elicit slot function, I must be passing the info wrong. Are you re-eliciting the same slot? – MarkMc17 Jan 08 '19 at 16:51
-
`def open_slot(intent_request): slots = intent_request['currentIntent']['slots'] slots['phrase'] = intent_request['inputTranscript'] slot_to_elicit = ? return elicit_slot(intent_request['sessionAttributes'], intent_request['currentIntent']['name'], slots, slot_to_elicit, { 'contentType': 'PlainText', 'content': 'Test Test.' })` – MarkMc17 Jan 08 '19 at 16:56
-
@MarkMc17 in `slot_to_elicit` you give the name of slot which you want to re-prompt – sid8491 Jan 08 '19 at 17:28
-
Yeah the slots need to be passed back to Lex so that they are maintained on the next turn, but I didn't mean to re-prompt the same slot. I meant eliciting the next slot. I saw in the OP question that the confusion is also what to do after setting the slot with the inputTranscript. So simply fill the slot, then elicit the next slot, or however you want to handle the slot from there. Maybe this intent only has one slot and you just want to respond appropriately, in that case you don't want to elicitSlot. So you could improve the question or make it a new question @MarkMC if that's what you want. – Jay A. Little Jan 09 '19 at 09:15
-
1So just to clarify, elicitSlot is not only for **re-**eliciting but also first-time eliciting of any slot. – Jay A. Little Jan 09 '19 at 09:18
-
@JayA.Little yeah i meant eliciting as well...poor choice of words from my side. – sid8491 Jan 09 '19 at 15:58