in lambda/classify-emails-lambda/lambda_function.py [0:0]
def lambda_handler(event, context):
email, meta = validate_params(event)
logger.info("Executing the email classification lambda function with email content {}".format(email['body']))
results = call_endpoint(email['body'])
logger.info("Classification results returned. {}".format(results))
best_intent = best_class(results)
logger.info("Best matched intent is [{}]".format(best_intent['Name']))
if(is_good_enough(best_intent)):
logger.info("Classification passed the threashold. Hence sending responding back to the customer.")
send_user_email(event['email'], best_intent['Name'])
else:
logger.info("Classification failed the threashold. Hence sending to support.")
send_to_human_workflow_topic(event['email'])
return best_intent