Today, I will explain a powerful serverless pattern which I have been developing and seems to be a great approach. AWS Bedrock works with Step Functions along with the Model Context Protocol (MCP) to create a solution which understands large amounts of retail customer feedback data.
The Problem: Feedback overload in retail
At present retailers find themselves overwhelmed by the excessive amount of feedback they receive from customers. Like, seriously, it’s a tsunami. Every day Retailers face thousands of incoming comments alongside multiple messages and reviews. Retailers experience a mental breakdown when they must manage their business operations without automation.
- The speed at which you respond to customers should be fast enough to prevent angry tweets from customers about your business.
- Your new product receives either positive or negative feedback trends which you can measure through analysis of customer feedback.
- Businesses must identify which complaints require immediate action (now) to handle.
- Serverless systems help extract valuable insights that escape human detection when looking at pure data (aside from mere observation of observational data).
Sound familiar? Yeah, thought so. The situation needs serverless solutions to implement proper fixes.
The Architecture and workflow
A complete serverless workflow works as follows:
- the system automatically handles incoming feedback without human involvement.
- The combination of AWS Bedrock + MCP enables the system to produce intelligent personalized responses (AI takes the lead).
- AWS Comprehend analyzes sentiment because feelings matter to the evaluation process.
- Data nerds can find all information stored within DynamoDB for subsequent analysis (happy time for data enthusiasts)
- You will receive notifications about extremely negative feedback which allows you to prevent potential disasters from occurring.
The best part? You get no set-up costs with such a system, and you can scale without limits and only pay by usage. Let’s dive in.
AWS Step Functions: Orchestrate it like the conductor Eleazar de Carvalho
The essential element in this system is Step Functions.
The workflow is orchestrated by Step Functions, which ensure the entire process functions without issues. The visual representation of feedback movement across the system becomes possible through Step Functions. The process of fixing broken components becomes easy to handle because of the built-in debugging features.
The CDK code implementation appears below:
const definition = processFeedback.next(analyzeSentiment).next(checkSentiment);
new sfn.StateMachine(this, 'FeedbackStateMachine', {
definition,
});
Now you’ve got a workflow that’s easy to follow and even easier to fix when things go sideways.
Smart Responses with AWS Bedrock + MCP
First up, we use AWS Bedrock to generate personalized responses. This is where the Model Context Protocol (MCP) shines—it keeps track of the conversation context so the AI doesn’t go off the rails.
Check this out:
const mcp = new ModelContextProtocol({});
const context = mcp.createContext({
user: event.user || 'Anonymous ',
feedback: event.feedback,
});
const response = await bedrock.send(
new InvokeModelCommand({
modelId: 'anthropic.claude-v2',
contentType: 'application/json',
accept: 'application/json',
body: JSON.stringify({
prompt: `Please analyze this and answer carefully: "${context.get('feedback')}"`,
max_tokens: 150,
}),
})
);
The Bedrock platform grants unlimited access to AI models through its feature which eliminates the technical complexities of handling machine learning infrastructure. And MCP? Your AI receives context capabilities through MCP.
Sentiment Analysis with AWS Comprehend
Next, we analyze the sentiment of the feedback using AWS Comprehend. This tells us if the customer is happy, mad, or just meh.
const response = await comprehend.send(
new DetectSentimentCommand({
Text: event.feedback,
LanguageCode: "en",
})
);
context.set("sentiment", response.Sentiment);
Comprehend spits out a sentiment label (POSITIVE, NEGATIVE, NEUTRAL, or MIXED). We use this to decide if we need to sound the alarm.
Alerts for When Sh*t Hits the Fan
If the feedback is super negative, we need to act fast. Here’s how we set up smart alerts:
const checkSentiment = new sfn.Choice(this, 'Check Sentiment')
.when(
sfn.Condition.stringEquals('$.sentiment.sentiment', 'NEGATIVE'),
new tasks.LambdaInvoke(this, 'Send Alert', {
lambdaFunction: alertLambda, // This Lambda sends the alert
resultPath: sfn.JsonPath.DISCARD, // We don’t need the result
})
)
.otherwise(new sfn.Pass(this, 'Feedback OK')); // If it’s not negative, move on
For the alert itself, we use SNS to ping the support team:
await sns.send(new PublishCommand({
TopicArn: TOPIC_ARN,
Message: `⚠️ Alert: Negative Feedback Received!\n\n"${event.feedback}"`,
Subject: "Very Negative Feedback",
}));
Now your team knows exactly when to jump in and save the customer's day.
Cost? Don’t Sweat It
One of the best things about serverless is how cheap it is. You only pay when you’re processing feedback. Let’s break it down for a retailer handling 10,000 feedbacks a month:
- Lambda costs: ~$0.20 (basically free)
- Step Functions: ~$0.25 (chump change)
- DynamoDB: ~$0.50 (store all the things)
- Comprehend: ~$3.00 (feelings aren’t free)
- Bedrock: ~$5.00 (depending on tokens, but still a steal)
- SNS: ~$0.10 (alerts on a budget)
Total? Less than $10/month (I hope so).
For a system that would’ve cost a fortune to build and run a few years ago. That’s what I call a win.
Leveling Up: What’s Next?
Want to take this to the next level? Here are some ideas:
- Multi-language support: Detect the language first, then analyze sentiment. Global domination, here we come.
- Categorization: Use Bedrock to tag feedback (e.g., “product issue,” “shipping complaint”).
- Trend analysis: Add a nightly Lambda to crunch sentiment trends. Spot problems before they blow up.
- Feedback routing: Automatically send complaints to the right team (no more “not my job”).
- Customer segmentation: Tie feedback to customer profiles. Are your VIPs happy? Find out.
Hit me up in the comments if you’ve got questions or are working on something similar.
Top comments (0)