pythonamazon-web-servicesaws-lambdaamazon-connect

Amazon Connect check holidays lambda function


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.


Solution

  • 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.