<section class="blog-post-content"><h2>Introduction</h2><p>Organizations want contact center reporting and analytic capabilities for agents’ activities. This enables them to manage agent staffing and optimizing the contact center work force operations. Contact center platforms with limited integration capability make it challenging to generate custom reports and perform advanced agent activity analytics. <a href="https://docs.aws.amazon.com/connect/latest/adminguide/agent-event-streams.html">Amazon Connect agent event streams</a> are <a href="https://aws.amazon.com/kinesis">Amazon Kinesis Data Streams</a> that provide you with near real-time reporting of agent activity within your <a href="https://aws.amazon.com/connect/">Amazon Connect</a> instance.</p><p>In this blog you will learn how to enable Agent Event Stream, stream data out of Amazon Connect, and develop an analytics solution using <a href="https://aws.amazon.com/quicksight/">Amazon QuickSight</a>.</p><h2>Overview</h2><p><img class="size-full wp-image-7098 aligncenter" src="https://d2908q01vomqb2.cloudfront.net/af3e133428b9e25c55bc59fe534248e6a0c0f17b/2022/09/19/blog-5-aes-1.png" alt="Architecture diagram for the solution." width="869" height="318" /></p><p class="c4">Fig 1 – High-level architecture diagram</p><p>In this architecture, you will use Amazon Kinesis Streams to capture Amazon Connect Agent Event data in an <a href="https://aws.amazon.com/s3/">Amazon Simple Storage Service</a> (S3) bucket. <a href="https://aws.amazon.com/kinesis/data-streams/">Amazon Kinesis Data Streams</a> streams the Agent event data into S3 by using an <a href="https://aws.amazon.com/kinesis">Amazon Kinesis Data Firehose</a>. Using a data stream in the middle provides the advantage of using Agent Event data in other processes/solutions at the same time. For example, this data stream can be used to transfer the agent event records to <a href="https://aws.amazon.com/dynamodb/">Amazon DynamoDB</a> database for the data to be consumed in third-party applications.</p><p><a href="https://aws.amazon.com/glue/">AWS Glue</a> catalog has the table definitions for the contact event stream. You can run queries in <a href="https://aws.amazon.com/athena/">Amazon Athena</a> and generate reports. For visualization, you can use Amazon QuickSight.</p><p>This solution uses a parameter named “Project Name” that defines the solution domain. You can deploy this solution multiple times with different project names to maintain isolation. Because it will be used to name fundamental components, such as an Amazon S3 bucket, the project name must be unique globally.</p><h2>Prerequisites</h2><p>To follow along with the solution presented in this blog post, you should be familiar with the following AWS services and features:</p><h2>Walkthrough</h2><ol><li>Sign in to the AWS Management Console.</li><li><strong>Download the CloudFormation</strong> template from <a href="https://aws-contact-center-blog.s3.us-west-2.amazonaws.com/analyze-amazon-connect-agent-event-stream-amazon-quicksight%E2%80%93part-5/agentevents2.yaml"><strong>here</strong></a> onto your local machine.</li><li>In your preferred Region, <strong>create</strong> a CloudFormation stack using the template file downloaded in step 2.<img class="size-full wp-image-7099 aligncenter" src="https://d2908q01vomqb2.cloudfront.net/af3e133428b9e25c55bc59fe534248e6a0c0f17b/2022/09/19/blog-5-aes-2.png" alt="Enter the CloudFormation Stack details" width="1017" height="568" /></li><li>Keep the defaults on the remaining options page and <strong>select</strong> Create Stack</li></ol><h2>Validation</h2><p>In this step, you generate data by making or receiving calls using Amazon Connect. You can go to <a href="https://docs.aws.amazon.com/connect/latest/userguide/agentconsole-guide.html">Amazon Connect Contact Control Panel (CCP)</a> to receive calls using a software phone or desktop phone. Within a few minutes, Agent Event stream data will appear in the bucket named as your project name under “ae-base” as “.parquet” files.</p><ol><li>Navigate to Amazon Athena table, you should see “connect-ae” table. <strong>Click</strong> on three dots besides the connect_ae table, then <strong>select</strong> Preview Table.<img class="wp-image-7194 aligncenter" src="https://d2908q01vomqb2.cloudfront.net/af3e133428b9e25c55bc59fe534248e6a0c0f17b/2022/09/20/blog-5-aes-3.1.png" alt="Athena table screenshot" width="716" height="367" /></li><li>Athena displays the query results when you run it.<img class="size-full wp-image-7101 aligncenter" src="https://d2908q01vomqb2.cloudfront.net/af3e133428b9e25c55bc59fe534248e6a0c0f17b/2022/09/19/blog-5-aes-4.png" alt="Athena query result set screens shot" width="1378" height="615" /></li></ol><h2>Visualize in Amazon QuickSight</h2><p>Amazon Athena allows you to visualize the results of your query directly within Amazon QuickSight. Before connecting Amazon QuickSight to Athena, you must grant Amazon QuickSight access to Athena and its associated Amazon S3 bucket. For more information, see <a href="https://docs.aws.amazon.com/quicksight/latest/user/managing-users.html">managing Amazon QuickSight permissions to AWS resources</a>. After granting the access permissions, you create a new dataset in Amazon QuickSight based on the Athena table that was created.</p><p>Next create a new analysis in Amazon QuickSight:</p><ol><li>Navigate to QuickSight and <strong>select</strong> Analysis.</li><li><strong>Click</strong> on New Dataset, then <strong>select</strong> Athena and give the data source a name.</li><li>In the example below, the name chosen is ‘aes-reporting’. Afterwards, <strong>click</strong> on Create data source.<img class="size-full wp-image-7102 aligncenter" src="https://d2908q01vomqb2.cloudfront.net/af3e133428b9e25c55bc59fe534248e6a0c0f17b/2022/09/19/blog-5-aes-5.png" alt="QuickSight screen shot to enter the data source name" width="1463" height="327" /></li><li>Choose the name of the database (same name as your project name) and table/view, created as part of the blog, then <strong>click</strong> Select. (Make sure the QuickSight instance is in the same Region where you ran the CloudFormation template)<img class="size-full wp-image-7103 aligncenter" src="https://d2908q01vomqb2.cloudfront.net/af3e133428b9e25c55bc59fe534248e6a0c0f17b/2022/09/19/blog-5-aes-6.png" alt="QuickSight screen shot to select table" width="1503" height="527" /></li><li>Finally, <strong>click</strong> Visualize to complete the dataset creation.<img class="size-full wp-image-7104 aligncenter" src="https://d2908q01vomqb2.cloudfront.net/af3e133428b9e25c55bc59fe534248e6a0c0f17b/2022/09/19/blog-5-aes-7.png" alt="QuickSight screen shot to confirm the SPICE storage" width="1492" height="381" /></li><li>In the next screen, you should see the Agent Event Analysis page to configure analytics in the sheet.<ol><li>Login-Logout Report uses the login-logout view created from the Agent Event Stream table. The view analyzes all the logins and logouts for the agent in the filtered date time period. Then calculating the time elapsed between the login event and the subsequent logout event. The view also omits the agent events on the default Routing Profile. If there is a login event but a missing subsequent logout event, then it set the logout event as unavailable or NA. See a screenshot of the LOGIN-LOGOUT report below.<img class="size-full wp-image-7105 aligncenter" src="https://d2908q01vomqb2.cloudfront.net/af3e133428b9e25c55bc59fe534248e6a0c0f17b/2022/09/19/blog-5-aes-8.png" alt="The login-logout report screen shot" width="1429" height="615" /></li><li>Agent-Status report uses the Agent-Status view created from Agent Event Stream Table. The view analyzes all the event types like (Login, Logout, Status Change) except the Heart Beat. The view also omits the agent events from the Default Routing Profile. The report calculates the time spent by an agent in each of the status. Refer to the visual of the Agent Status Report below.<img class="size-full wp-image-7106 aligncenter" src="https://d2908q01vomqb2.cloudfront.net/af3e133428b9e25c55bc59fe534248e6a0c0f17b/2022/09/19/blog-5-aes-9.png" alt="Agent status report screenshot" width="1431" height="527" /></li><li>Agent-Status-Summary view aggregates the status time from the Agent-Status view by the agent status. This view can build graph and pie-chart on the QuickSight. Refer to the screenshot of the agent summary below.<table class="c5" style="width: 852px;"><tbody><tr><td><img class="alignleft size-full wp-image-7107" src="https://d2908q01vomqb2.cloudfront.net/af3e133428b9e25c55bc59fe534248e6a0c0f17b/2022/09/19/blog-5-aes-10.png" alt="Agent status summary table" width="1446" height="652" /></td><td><img class="alignleft size-full wp-image-7097" src="https://d2908q01vomqb2.cloudfront.net/af3e133428b9e25c55bc59fe534248e6a0c0f17b/2022/09/19/blog-5-aes-11.png" alt="Agent status summary pie chart" width="1429" height="969" /></td></tr></tbody></table></li></ol></li></ol><p>After following the steps above, you can use Amazon QuickSight to add different columns from the call records and perform visualizations. You can also create views within Amazon Athena to build enhanced visualizations. If interested in exploring more, review <a href="https://aws.amazon.com/blogs/big-data/analyze-and-visualize-nested-json-data-with-amazon-athena-and-amazon-quicksight/">this</a> blog post. Last, you can also build dashboards that continuously monitor your Amazon Connect instance and <a href="https://docs.aws.amazon.com/quicksight/latest/user/sharing-a-dashboard.html">share those dashboards</a> with others in your organization.</p><h2>Cleanup</h2><p>In order to delete the resources created by the stack:</p><ul><li>Delete the CloudFormation template.</li><li>Delete the objects and the Amazon S3 bucket created from the CloudFormation template.</li><li>Delete the Glue database created from the CloudFormation template.</li></ul><h2>Conclusion</h2><p>In this blog, you learned one way to analyze and visualize your Agent Event stream using Amazon QuickSight. We showed how Amazon Kinesis and Amazon Athena process agent event to build customized and enhanced visuals. To build further analysis, by creating views within Amazon Athena, check <a href="https://aws.amazon.com/blogs/big-data/analyze-and-visualize-nested-json-data-with-amazon-athena-and-amazon-quicksight/">this</a> blog post for more details.</p><h4>Author Bio</h4><table><tbody><tr><td><img class="alignleft size-full wp-image-6076" src="https://d2908q01vomqb2.cloudfront.net/af3e133428b9e25c55bc59fe534248e6a0c0f17b/2022/04/26/mehmet-bio.jpg" alt="" width="120" height="106" /></td><td>Mehmet Demir is a Senior Solutions Architect at Amazon Web Services (AWS) based in Toronto, Canada. He helps customers in building well-architected solutions that support business innovation</td></tr><tr><td><img class="alignleft wp-image-7187" src="https://d2908q01vomqb2.cloudfront.net/af3e133428b9e25c55bc59fe534248e6a0c0f17b/2022/09/20/kt.png" alt="" width="99" height="134" /></td><td>Kalyan Thandri is a consultant at AWS. He designs and implement Amazon Connect Contact Center solutions for AWS customers.</td></tr><tr><td><img class="alignleft size-full wp-image-6078" src="https://d2908q01vomqb2.cloudfront.net/af3e133428b9e25c55bc59fe534248e6a0c0f17b/2022/04/26/ankur-bio.jpg" alt="" width="104" height="81" /></td><td>Ankur Taunk is a Senior Specialist Solutions Architect at AWS. He helps customer achieve their desired business outcomes in the Contact Center space leveraging Amazon Connect.</td></tr></tbody></table></section>