in lambda/src/gather_symptom_bot.py [0:0]
def fall_back(intent_request):
# if no prev intent or prev intent is asking for symptoms
session_attributes = helper.get_attribute(intent_request, 'sessionAttributes')
current_intent = helper.get_attribute(intent_request, 'currentIntent')
slots = helper.get_attribute(current_intent, 'slots')
confirmation_status = helper.get_attribute(current_intent, 'confirmationStatus')
# TODO: if prev intent is asking for body part
# TODO: too many failed attempts should terminate.
if confirmation_status == helper.ConfirmationStatus.NONE.value:
user_utterance = intent_request['inputTranscript']
if user_utterance == '':
return helper.elicit_slot(session_attributes, INTENT_REPORT_SYMPTOM, slots, SLOT_SYMPTOM_ONE,
msg_strings.get('CLARIFICATION'))
message = f"your said '{user_utterance}', is that right?"
slots[SLOT_SYMPTOM_ONE] = user_utterance
helper.append_session_attr(session_attributes, UNKNOWN_SYMPTOM_ATTR, user_utterance)
return helper.confirm_intent(session_attributes, INTENT_REPORT_SYMPTOM, slots, message_content=message,
message_type='PlainText')
elif confirmation_status == helper.ConfirmationStatus.DENIED.value:
return helper.elicit_slot(session_attributes, INTENT_REPORT_SYMPTOM, slots, SLOT_SYMPTOM_ONE,
msg_strings.get('AFTER_SYMPTOM_DENY'))
else:
return helper.elicit_slot(session_attributes, INTENT_REPORT_SYMPTOM, slots, SLOT_SYMPTOM_ONE,
msg_strings.get('CLARIFICATION'))