An additional way I've found to do this is to check whether the transcript is one of the slot prompt strings. If it is, then it's safe to elicit the slot's value. If not, then you have probably already elicited the slot value and can change the fulfillment_state
to "Fulfilled"
Here's a simple example of eliciting a feedback slot when the bot gets prompted with "Thumbs up" or "Thumbs down":
current_intent = event["sessionState"]["intent"]
slot_to_elicit = event["proposedNextState"]["dialogAction"]["slotToElicit"]
transcript = event["inputTranscript"]
if slot_to_elicit and (transcript in ["Thumbs up", "Thumbs down"]):
response = elicit_feedback_slot(
slot_to_elicit=slot_to_elicit, intent=current_intent
)
else:
text = f"Thank you for your feedback!"
fulfillment_state = "Fulfilled"
response = close(
event=event,
fulfillment_state=fulfillment_state,
message_text=text,
)
I know this is still not a perfect solution, since you need to explicitly match the slot prompts. Maybe use a regex, or leverage Lex by getting the interpreted value rather than transcript. Hopefully Lex will some day have an AMAZON.SearchQuery
slot type..