Applying Amazon’s Textract in E-Commerce applications – A game changer

Priya Jinagar & Akshay Deshpande

Applying Amazons Textract in E Commerce applications – A game changer

Introduction

In E-commerce applications, one of the ways of placing the order is through email communication. Order is placed by sending email with a document attachment having details of order, mostly in PDF format. This requires manual processing of the PDF including reading and creation of the order. If we can reduce the manual efforts of reading the document and processing the data, it can increase the efficiency.

Using AWS services, we can extract the email attachments in raw format, save in S3 bucket and using lambda function programming we can further process it. To extract the data from the attached documents we can use AWS Textract service. This is ML based service to extract text, handwritings and data from the scanned documents. In Techpearl, we have applied Amazon’s Textract solution in E-Commerce applications and achieved impressive results.

Architecture/Flow

Integration steps in our business requirement case

  1. Configure a dedicated email server using Amazon WorkMail – Create dedicated email address to receive incoming emails from legacy systems or applications
  2. Configure Amazon SES to send a copy of incoming email in raw format to Amazon S3
  3. Create AWS Lambda function in python to extract email attachment from raw email message and using AWS Textract extract the data from the raw email and further process the response. In our case, using boto3 layer converting the response in key value pairs to form the json structure required for order creation on the application server. We can store the result in a different S3 bucket or in dynamoDB or mongoDB.
  4. Configure S3 event notifications to invoke AWS Lambda (when email in raw format is added to S3 bucket in step 2) and extract the email attachment and further process.

Using AWS services, we can extract the email attachments in raw format, save in S3 bucket and using lambda function programming we can further process it. To extract the data from the attached documents we can use AWS Textract service. This is ML based service to extract text, handwritings and data from the scanned documents. In Techpearl, we have applied Amazon’s Textract solution in E-Commerce applications and achieved impressive results.

Architecture Flow

AWS Textract API

AWS has mainly 3 API calls in it. Each API call has a different purpose of extracting data from documents. To access these API calls we need to create or update IAM user with AmazonTextractFullAccess and AmazonS3ReadOnlyAccess permissions. The API names are as mentioned below.

  1. Document Analysis
  2. Expense Analysis
  3. Analyze ID

1. Document Analysis

As the name indicates Document Analysis is used to analyze the document and get the response in the form of Key and Value pairs. It takes the file as input and analyzes the relation between the detected keys. After detecting the relation between the texts it creates Key and value pairs. For example Name:- John Robert, Date of birth:- 12/12/1986.

The Analysis document has 5 more actions in it as mentioned below.

  1. Text Extraction
  2. Form Extraction
  3. Table Extraction
  4. Query Extraction
  5. Signature Extraction

a. Text Extraction

Text Extraction is just normal raw data extracted from the document. It returns the list of words detected from the document. It divides the document into smaller blocks and for each block it is capable of detecting whether the block has a word or a line. If the block is a word then it returns the blockType as “word’ and if it is a line then it returns blockType as “line”.

b. Form Extraction

AWS is capable of analyzing the tables in documents. It divides the document into tables and analyzes the relation between the table header and table data. After analyzing the tables it creates Key and Value pairs whereas Key will be a table header and value will be the table data.

Ex:-

Name

Jesse Mckenzie

Result:-

{

“Name”: “Jesse Mckenzie”,

}

c. Table Extraction

AWS is capable of extracting Tables, Table cells and the items within the table cells. These table extracted data do not have specific information about table header and table data. But we can program it easily to define table header and table data. It can also be programmed to return the value in .txt, .csv or a Json.

d. Table Extraction

With the query extraction we can get specific information from the document. It also involves asking a simple english question to AWS. For example, let’s say that we have an order date mentioned in PDF. If we want to get this specific information we can simply ask a question or a set of questions to AWS like “what is the order date?”. AWS is going to process the question asked and try to find out a possible set of results for this.

Example: 

Name

Jesse Mckenzie

Question:- “What is the name of the candidate?”

Result:-

{

“Name”: “Jesse Mckenzie”,

}

e. Signature Extraction

Amazon textract can also locate the signature on documents. It is returned as geometry objects with bounding boxes that provide the location of a signature on the page, alongside the confidence that a signature is in that location.

Example: 

Name

Jesse Mckenzie

Question:- “What is the name of the candidate?”

Result:-

{

“Name”: “Jesse Mckenzie”,

}

2. Expense Analysis

Expense Analysis is used for analyzing the documents like Invoices, Receipts, Bills etc. Expense Analysis is further separated into SummeryFields and LineItemGroups. Most of the Invoices and Receipts contain information such as vendor name, receipt data, vendor address or total price. AnalyseExpense returns these details under SummeryField Other information like purchased product, product price, product quantity or total product price returns under LineItemGroups.

3. Analyze ID

Identity cards can be processed using Analyze Id. It takes scanned documents as input and returns the data in the form of key-value pairs by normalizing it.

Analyze ID AWS Textract API

Conclusion

Automation in day-to-day business processes helps in improving the business in many dimensions such as efficiency, accuracy, speed and productivity. Reading documents in PDF, images or papers format and manually processing data entry are time consuming and error prone. Using AWS Textract different APIs we can reduce the manual efforts on reading and extracting data and increase the efficiency, speed and productivity. In today’s market giving faster response to the customer and being quick in service is becoming important.

AWS Textract can help in full automation or semi automation of the business process in different sectors like finance, health and care, public sector. In Techpearl, we have applied Amazon’s Textract in E-Commerce applications and achieved significant productivity gains during the development lifecycle. The customer feedback has also been very satisfactory as we could turn-in new competitive features for them in quick time.

Read More Articles

Serverless application
AWS Serverless

Serverless Application

Serverless architecture is a software design pattern where applications’ hosting is outsourced to a third-party service provider, eliminating the developer’s need for server software and

 Contact Us Now

Talk to us to find out about our flexible engagement models.

Get In Touch With Us