in functions/source/kendra_search_intent_handler_lambda/lambda_function.py [0:0]
def lambda_handler(event, _):
"""
Lambda function handler. Triggers applicable intent handler and returns Lex bot response.
:param event: Event body
:param _: Context (not used)
:return: Lex bot response
"""
logger.info('<help_desk_bot>> Lex event info = %s', json.dumps(event))
session_attributes = event.get('sessionAttributes', None)
if session_attributes is None:
session_attributes = {}
logger.debug('<<help_desk_bot> lambda_handler: session_attributes = %s',
json.dumps(session_attributes))
current_intent = event.get('currentIntent', None)
if current_intent is None:
response_string = 'Sorry, I didn\'t understand. Could you please repeat?'
return helpers.close(session_attributes, 'Fulfilled',
{'contentType': 'CustomPayload', 'content': response_string})
intent_name = current_intent.get('name', None)
if intent_name is None:
response_string = 'Sorry, I didn\'t understand. Could you please repeat?'
return helpers.close(session_attributes, 'Fulfilled',
{'contentType': 'CustomPayload', 'content': response_string})
# see HANDLERS dict at bottom
if HANDLERS.get(intent_name, False):
return HANDLERS[intent_name]['handler'](event, session_attributes)
# dispatch to the event handler
response_string = "The intent " + intent_name + " is not yet supported."
return helpers.close(session_attributes, 'Fulfilled',
{'contentType': 'CustomPayload', 'content': response_string})