Call Center Analytics: Part 3 - Sentiment Analysis with Amazon Comprehend
In the customer service landscape, understanding the emotional undertones of customer interactions at the click of a button can be extremely helpful. Se...

Todd Bernson
2024-10-10

In the customer service landscape, understanding the emotional undertones of customer interactions at the click of a button can be extremely helpful. Sentiment analysis is key in unlocking the "emotional data" from customer calls, allowing companies to fine-tune their customer service and product offerings.

In this article, I show how I've used Amazon Comprehend to perform sentiment analysis, offer a technical walkthrough, and explore the nuances of Natural Language Processing (NLP) as they apply to real-world call center data.
Check out the code repo here.
Amazon Comprehend Basics
Before diving into sentiment analysis, lets grasp the capabilities of Amazon Comprehend. As an AWS service, Comprehend provides NLP in a fully managed and continuous learning environment. It identifies the language of the text, extracts key phrases, places, people, brands, or events, understands how positive or negative the text is, and automatically organizes a collection of text files by topic.
Understanding how to harness these capabilities within AWS begins with configuring the service to meet the specific needs of your call center data.
Performing Sentiment Analysis
Setting up sentiment analysis with Amazon Comprehend is straightforward but requires attention to detail. We must configure the Lambda to have permission to utilize Comprehend.
Calling Comprehend from the Lambda
def process_transcript(transcript, speaker_labels):
dialogue_entries = []
last_speaker = None
for segment in speaker_labels['segments']:
speaker_label = segment['speaker_label']
speaker_name = {"spk_0": "Customer", "spk_1": "Agent"}[speaker_label]
if last_speaker != speaker_label:
if last_speaker is not None:
dialogue_entries.append("\n")
dialogue_entries.append(f"{speaker_name}:")
last_speaker = speaker_label
segment_dialogue = ""
for item in segment['items']:
word_info = next((word for word in transcript['items'] if
'start_time' in word and word['start_time'] == item['start_time']), None)
if word_info and 'alternatives' in word_info and len(word_info['alternatives']) > 0:
if segment_dialogue:
segment_dialogue += " "
segment_dialogue += word_info['alternatives'][0]['content']
if segment_dialogue:
dialogue_entries.append(f" {segment_dialogue}")
formatted_script = "".join(dialogue_entries)
return formatted_script
Integrating with Lambda and DynamoDB
The real power of sentiment analysis comes with its integration into the broader architecture. Using AWS Lambda, the sentiment analysis results can be processed and then sent to DynamoDB for storage. This integration allows the sentiment data to be actionable, informing business decisions and customer service strategies.
With the sentiment data stored in DynamoDB, retrieving and analyzing historical sentiment trends becomes possible, adding a new dimension to customer interaction analytics.
Advanced Sentiment Analysis Techniques
While Amazon Comprehend provides a robust platform for sentiment analysis, its application presents challenges. Language is inherently complex; customer calls often include slang, jargon, and varying dialects. To address this, Comprehend allows for customization and training to better accommodate the unique communication styles encountered in calls.
Implementing sentiment analysis using Amazon Comprehend can profoundly impact the quality of customer service. By providing a window into the customer's emotional journey, businesses can pivot and adapt to respond to their clientele's needs. As AWS continues to enhance Comprehend, the potential for even more nuanced analysis grows, promising a future where customer sentiment is not just heard but understood at a granular level.
Visit my website here.
Read More
View all posts
AI/ML
Why Enterprise AI Must Be Application-Led, Not Agent-Led
A deep dive by Todd Bernson, CTO and Chief AI Officer, on why enterprise AI systems should be architected as application-led, deterministic platforms with embedded agentic AI—not fully autonomous agents. This article explains how API-first, governed, multi-channel architectures deliver higher reliability, compliance, scalability, and business value in real-world Fortune-500 environments.

Todd Bernson
2025-12-02

AI/ML
Application-First Agentic AI
Application-first agentic AI is emerging as the only reliable path to real enterprise ROI. In this in-depth analysis, Todd Bernson, CTO & CAIO, breaks down why most generative AI initiatives stall in production—and how disciplined enterprise architecture, deterministic workflows, and narrowly scoped AI agents can finally unlock repeatable business value. Using a real sprint-intelligence system as a case study, the article shows how organizations can combine serverless engineering, structured orchestration, and constrained LLM reasoning to reduce reporting effort, increase trust, eliminate hallucinations, and deliver actionable insights across engineering, operations, compliance, and customer experience.

Todd Bernson
2025-11-28
AI/ML
Why 95% of AI Projects Fail and How to Be Among the 5% That Succeed

Lee Hylton
2025-08-22