Amazon Connect check holidays lambda function

Question:

Is it possible to build a lambda function for Amazon connect using AWS that checks the date against holidays and determines whether the flow is in or out of hours.

Asked By: user9424128

||

Answers:

This is actually a common request. Just create a Lambda function that compares today’s date against an array of holidays or you can hit a database that contains your holidays. Have Lambda return whether “holiday” is true or false.

This guide will show you how to format the response from Lambda.
https://docs.aws.amazon.com/connect/latest/adminguide/connect-lambda-functions.html

The picture below demonstrates how to wire up your contact flow to hit the Lambda function and then use “Check contact attributes” to determine if the callback from Lambda returns “holiday” as true or false.

enter image description here

The picture below here demonstrates how to use the check contact attributes step to act upon the “holiday” attribute returned from your Lambda function.

enter image description here

I’ve modified your python code a bit. Try something like this to get you started.

from datetime import date

def lambda_handler(event, context):
    
    d1 = str(date.today())
    d2 = '2018-03-06'
    if d1 == d2:
        return {"holiday":"True"}
    else:
        return {"holiday":"False"}

Hope this helps.

Answered By: Parrett Apps

I’m late to the party here but I appreciate your post – very helpful!
One potential "gotcha" could arise from the capitalization of the words "True" and "False" in your Python code and then using lower case for checking conditions in the Contact Attributes. This could result in No Match condition being met.

Answered By: user_8675309