2021-11-20

Post Call Surveys in Amazon Connect

 One of the features of Contact centers is the ability to offer a client Post Call Survey.

In your Post Call Survey, you can ask the client to rate the quality of service or any other related questions.

It can be done in multiple ways - by sending client email form right after the call, by sending an SMS, or by asking the client to stay on the line after the agent disconnects and answer questions in the IVR. In this article, I would like to demonstrate how to build IVR Post Call Survey that is automatically triggered by the system once the agent disconnects from the call.

Step 1.

Create DynamoDB table that we will use to save results of Post Call Survey

Table name - PostCallSurveys

Columns:

  • ContactId  - unique ID of the call
  • answer  -  client's answer to post call survey
  • datetime - timestamp
  • phoneNumber - caller number (CLID) of the client


Step 2.

Now we will create Lambda function using Python 3.9 that is called savePostCallSurvey.

What it does:

1) Takes following attributes from the call

  • ContactId
  • Caller Number (CLID)
  • Client's answer to Survey
2) Saves this information to DynamoDB table PostCallSurveys

Here is the full text of my Lambda function:

import boto3
from botocore.exceptions import ClientError
from datetime import datetime

def lambda_handler(event, context):


    print(event)
    dynamodb = boto3.resource('dynamodb')
    table = dynamodb.Table('PostCallSurveys')
    
    ContactId=event['Details']['ContactData']['ContactId']
    CLID=event['Details']['ContactData']['CustomerEndpoint']['Address']
    
    current_date =datetime.now()
    curren_date_string=current_date.strftime("%Y-%m-%d %H:%M:%S")
    
    answer=event['Details']['ContactData']['Attributes']['answer']
    
    try:
        response = table.put_item(
           Item={
                'ContactId':ContactId,
                'phoneNumber': CLID,
                'datetime': curren_date_string,
                'answer': answer
            }
        )
        
        return response

    
            
    except ClientError as e:
        print(e.response['Error']['Message'])
    

You can also download it from my GitHub:


Step 3.

Next,  we will create a call flow that will be used to offer the client Post call survey.

You can download it from my GitHub:



How it works:

1) First we will use Store Customer input block to play "Please rate the quality of our service from 1 to 5" and capture user input.


2) After that we will save result to user defined attributed called "answer".

3) Now we will invoke our lambda function savePostCallSurvey to save results to the database.

Step 4.

The last step will be -  activate our Post Call Survey flow so that it will be automatically offered to the client when the agent disconnects.

In order to do that in our main IVR flow, we need to add Set disconnect flow action that will be called before we transfer call to the queue. 

Set disconnect flow allows to specify a flow that will be executed when the agent disconnect from the call.

In the Set disconnect flow we will select our Post Call Survey flow that we previously created in Step 3.


You can download it from my GitHub:
https://github.com/contactcenterdude/amazon-connect/blob/main/PostCallSurveys/MainFlow_flow.json

BONUS:

As I mentioned at the very beginning of this article Post Call survey can be also offered by sending an email.
It can be achieved by creating another flow that sends an email to a client. The same way we triggered IVR Post Call Survey by using Set disconnect flow we can also trigger flow that sends email.