2021-12-09

SLA Notifications in Amazon Connect

One of the most important KPIs of any contact center is SLA (service level agreement). It shows the percentage of the calls that were answered before the threshold. For example, 80% of the calls must be answered before 20 seconds of waiting in line.

Since it is such an important metric quite often contact center management would like to be informed about it, so they could act quickly to improve SLA for example by adding more agents on the line.

Of course, you can see SLA in historical and real-time reports, but in this article, I would like to demonstrate how to create automated SLA notifications that will be sending SLA metrics every hour by SMS or by EMail.

In my example, I will be sending SLA notifications every hour for the previous hour. This can be modified based on requirements.

Step 1. 

I will start by creating DynamoDB table that will be used to keep configuration for each Queue.

DynamoDB table - SLA_Notifier with following attributes

  • QueueId     - QueueId in Amazon Connect (see below where to find QueueId)
  • QueueName   - Queue name
  • Channel     - a type of channel (VOICE, CHAT, TASK).  You need this field because normally you would have different SLAs for each type of contact (calls, chats, tasks).
  • Threshold  - SLA threshold (for example 20 seconds)
  • SendEmail   - yes/no. Do you want to send SLA notifications by Email?
  • SendSMS     - yes/no. Do you want to send SLA notifications by SMS?
  • email       - send Email to this address
  • phoneNumber - send SMS to this phone number 



* Where to find QueueID:

1. Connect to Amazon Connect interface
2. Go to Routing - Queues
3. Select desired Queue
4. Click "Show additional queue information"
5. Take the last 36 characters in ARN field after queue/ - this is QueueID



Step 2.

I created Lambda function SLA_Notifier using Python 3.9 that does the following:

1) grabs all data from DynamoDB table SLA_Notifier
2) for each queue in the table it gets SLA for the last X minutes. Where X is configurable.
3)  for each line in the table it identifies if we need to send SMS and/or send Email
4)  sends SMS and/or EMail as required

Source code of this function on my GitHub:

Before you can use it you have to configure the following parameters 

************
    # Amazon Connect InstanceId
    InstanceId="838ab265-dd60-476b-976c-0ce5fac44809"
    
    #Statistical interval in minutes (SLA for last X minutes)
    statInterval="60"
    
    # Region name of Amazon SES and Amazon SNS
    region_name="us-east-1"
    
    # MailFrom for EMail notification
    MailFrom = "sla_notifier@ecorp.com"
    
    # Subject for EMail notifications
    Subject='SLA Notifier'

**************

Read this article to find your Amazon Connect InstanceId



IMPORTANT:
 In my example, I assume that you already configured Amazon SES so that you would be able to send emails using MailFrom address. 

*******

After you add this lambda function I recommend increasing default timeout  (by default it is 3 seconds) to 10 seconds to give our function enough time to complete execution.
  • In AWS Management console open Lambda
  • Go to your function
  • Go to Configuration - General configuration
  • Click edit and change timeout to 10 seconds


Step 3.

The last step is to create a schedule to run our Lambda function every hour.
To do that do the following:

1. In AWS console select Amazon EventBridge
2. Go to Rules
3. Click "Create rule"
4. Specify rule name (for example "SLA_Notifier")
5. Define pattern - select "Schedule"
6. Select "Cron expression"
7. Enter following cron expression 0 * * * ? *
It means that our rule will be triggered at 0 minutes of every hour.
8. Scroll down to "Select targets"
9. In the Target list select "Lambda function"
10. And select our function "SLA_Notifier"


11. Save this rule

*****************************

Some possible modifications:

1) The same way I send SLA it is easy to add additional metrics to notifications.
Anything that can be returned by GetMetricData function of Amazon Connect API can be easily added to the notification.
2) You can add extra logic and only send notifications if SLA (or any other metric) is within a certain range (for example if SLA drops below 70%)
3) You can adjust statistical interval and cron expression to send notifications more or less often.







No comments:

Post a Comment