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.
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
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'])