Analyzing customer feedback for your product is recommended to enhance and fill the gaps for any business want to enhance their products and customer services
AWS provides several services that can used to achieve this, One of the services that can be used is Amazon Comprehend
Based on AWS documentation Amazon Comprehend "Amazon Comprehend uses natural language processing (NLP) to extract insights about the content of documents. It develops insights by recognizing the entities, key phrases, language, sentiments, and other common elements in a document. Use Amazon Comprehend to create new products based on understanding the structure of documents."
So, in this blog we will discuss how we are going to use Amazon Comprehend to analyze customer reviews
We will start with the functional & non-functional requirements then we will move to the core components and the setup of the solution
We made some assumptions that the application is already deployed on an EC2 instance and users will be able to write their review, the application is Inegrated with S3 and will generate a text file contains review
Functional Requirements
- Analyze text documents which will be generated by application
- Extract the reviews and categorize them either POSITIVE, NEGATIVE or MIXED based on sentiment score
Non-Functional requirements
- Solution should be reliable
HLD
Core Components
- EC2: It will host the application accessed by users.
- S3: will host the review files generated by application which contains user's reviews
- Lambda Function: It will be triggered by S3 event notification and will invoke Amazon Comprehend by using Detect_Sentiment API, it will also save the generated results to DynamoDB
- DynamoDB: will store the final results either the review is POSITIVE, NEGATIVE or MIXED
Solution Setup
1- We have created an S3 bucket with a directory uploads which will host the generated review files
The bucket is created with the default configuration and for event notification you can create type of events is (POST, PUT)
2- We have created a table on DynamoDB with the below configuration:
Table Name: CustomerFeedbackAnalysis
Partition Key: FeedbackID
We kept rest of configuration as default but for sure you will configure them based on your requirements
3- We created a Lambda function with defaults configuration except for the Timeout since it's only 3 seconds and IAM Role since it should have permissions for the below:
- AWSLambdaBasicExecutionRole (Basic Exection Role for Lambda)
- AmazonS3ReadOnlyAccess (to read files from S3)
- AmazonDynamoDBFullAccess (Write results to DynamoDB)
- ComprehendReadOnly (Invoke Comprehend using Detect_Sentiment API)
Sequence Diagram
The flow should be as below
The results
I generated some random reviews and uploaded them to the S3, the final results stored in DynamoDB table as below:
References
Analyze content with Amazon Comprehend and Amazon SageMaker notebooks
Amazon Comprehend
Top comments (0)