AWS Logo
Menu

Detect sentiment from customer reviews with Amazon Comprehend and MongoDB Atlas

Integrate Amazon Comprehend with MongoDB Atlas to detect customers reviews sentiment

Domenica Siviglia
Amazon Employee
Published Dec 19, 2024
Today is very important to analyse customers reviews and have the ability to proactively address issues and gain insights. Sentiment analysis is the process of analyzing digital text to determine if the emotional tone of the message is positive, negative, or neutral. Amazon Comprehend is a text analytics service that allows you to detect sentiment. It uses machine learning (ML) to discover insights from text. MongoDB Atlas is a fully-managed cloud database that handles all the complexity of deploying, managing, and healing your deployments in the cloud.
In this blog post , I'll show you how to leverage Amazon Comprehend and MongoDB Atlas to detect customer sentiment.

Overview

The following diagram shows the high level architecture of an example scenario to ingest data from MongoDB Atlas into AWS Cloud using Amazon EventBridge and trigger a Review Sentiment Analysis function that calls Amazon Comprehend to run text analytics on the review and log the overall sentiment analysis.
MongoDB stores data records as BSON documents, which are gathered together in collections. A database stores one or more collections of documents.
This walkthrough shows you how to:
  1. Create a MongoDB cluster
  2. Create a database trigger associated to a collection
  3. Create an event bus in AWS, linked to the partner event source.
  4. Create a Lambda function that calls Amazon Comprehend API and the associated role with permissions.
  5. Create an EventBridge rule and associate it to the Lambda function.
  6. Verify the process
Steps 3–5 create and configure the AWS resources using the AWS Serverless Application Model (AWS SAM). To set up the sample application, visit the GitHub repo and follow the instructions in the README.md file.

Prerequisites

You must have the following:
  • An Atlas cluster running MongoDB
  • An AWS account
  • The AWS SAM CLI installed and configured on your machine.

Step by Step Configuration

  1. Deploy a free tier cluster using these instructions, selecting your preferred cloud provider and Region.
  2. Add your trusted connection IP address to the IP access list. This allows to connect to the cluster and access the data.
  3. Create a database trigger associated with the collection you just created. You can follow this instructions.

Verification

Add a customer review to the previously created collection. Check in Amazon CloudWatch the result.
 

Any opinions in this post are those of the individual author and may not reflect the opinions of AWS.

Comments