Amazon Textract
Introduction
The Amazon Textract connector provides a way for you to enrich your Mendix app with the capability to extract text, handwriting and data from documents by implementing Amazon Textract.
Typical Use Cases
Amazon Textract helps improve your app by giving you the tools to extract data from documents in a structured manner. For example, you can use it to extract business data from handwritten documents, or patient data from intake forms.
Prerequisites
The Amazon Textract connector requires Mendix Studio Pro 9.18.0 or above.
To authenticate with Amazon Web Service (AWS), you must also install and configure the AWS authentication connector. From Amazon Textract Connector version 2.0.0 on, AWS Authentication 3.0.0 or newer is required. For more information about installing and configuring the AWS Authentication connector, see AWS Authentication.
Licensing and Cost
This connector is available as a free download from the Mendix Marketplace, but the AWS service to which is connects may incur a usage cost. For more information, refer to AWS documentation.
Depending on your use case, your deployment environment, and the type of app that you want to build, you may also need a license for your Mendix app. For more information, refer to Licensing Apps.
Installation
Follow the instructions in How to Use Marketplace Content to import the Amazon Textract connector into your app.
Configuration
After you install the connector, you can find it in the App Explorer, in the AmazonTextractConnector section. The connector provides a domain model and several activities that you can use to connect your app to Amazon Textract. Each activity can be implemented by using it in a microflow. To ensure that your app can connect to the AWS service, you must also configure AWS authentication for the connector.
Configuring AWS Authentication
In order to use the Amazon Textract service, you must authenticate with AWS. To do so, you must set up a configuration profile in your Mendix app. After you set up the configuration profile, the connector module handles the authentication internally.
As of version 3.0.0 of the AWS Authentication Connector, all the resources and logic required to set up authentication are centralized inside the AWS Authentication Connector module.
The AWS Authentication Connector supports both static credentials and temporary credentials. For more information and detailed instructions please refer to the AWS Authentication Connector documentation page.
Configuring a Microflow for an AWS Service
After setting up the authentication, to analyze a document, implement the AnalyzeDocument activity by doing the following steps:
-
In the Domain Model, right-click on the work area, and then click Add entity.
-
Enter a name for your entity, for example, Document, and then click OK.
-
Double-click the Document entity, select the generalization FileDocument, and then click OK.
-
In the Document entity, find the Access rules tab.
-
Create new access rules by doing the following steps:
- Click New.
- Select a user role, and then select the checkboxes Allow creating new objects and Allow deleting existing objects.
- Set the access rights for Name, DeleteAfterDownload and Contents to Read/write
- Set the remaining access rights to Read.
-
In the App Explorer, right-click on the name of your module, click Add page, and then select the Grid template.
-
Enter a name for your page, for example, Document_Overview, and then click OK.
-
In the Properties pane of Document_Overview, in the Navigation section, select Visible for for a user role (see the Properties section of Page Properties).
-
Configure your page by doing the following steps:
- Open the page.
- Double-click on the data grid.
- In the Data source tab, select the Document entity.
- Click OK.
- Confirm that you want to automatically fill the contents of the data grid.
-
Create a page where your users can enter data for the app by doing the following steps:
- Right-click the New button in the data grid.
- Click Generate page.
- Enter a name for your page, for example, Document_NewEdit.
- Click OK.
-
In the Properties pane of Document_NewEdit, in the Navigation section, select Visible for for a user role (see the Properties section of Page Properties).
-
In the App Explorer, right-click on the name of your module, and then click Add microflow.
-
Enter a name for your microflow, for example, ACT_AnalyzeDocument, and then click OK.
-
Add an input parameter of the Document entity to the ACT_AnalyzeDocument microflow.
-
In the properties pane of ACT_AnalyzeDocument, under Security, assign a user role to Allow roles.
-
In the App Explorer, in the AWSAuthentication section, find the GetStaticCredentials and GetTemporaryCredentials microflows.
-
Drag the one you would like to use to your microflow.
-
In the Toolbox pane, search for the Create object activity and drag it onto the microflow area.
-
Configure the Create object activity by doing the following steps:
- Double-click the activity.
- Select the AnalyzeDocumentRequest entity.
-
Add another Create object activity, and select the AnalyzeDocFeatureType entity.
-
Set its Value attribute to ENUM_FeatureType.FORMS and the AnalyzeDocFeatureType_AnalyzeDocumentRequest association to the AnalyzeDocumentRequest object created in step 2.
-
In the Toolbox pane, in the AmazonTextractConnector section, find the AnalyzeDocument activity.
-
Drag the AnalyzeDocument activity onto the work area of your microflow between the Create object activities and the microflow end event.
-
Configure the AnalyzeDocument activity by doing the following steps:
- Double-click the activity.
- Set the values for AWS_Region, AnalyzeDocumentRequest, and the FileDocument parameter.
- Click OK.
-
In the Toolbox pane, search for the AbstractDocumentAnalysisResponse_ProcessResults microflow and drag it onto the microflow area.
-
Position the AbstractDocumentAnalysisResponse_ProcessResults microflow between the AnalyzeDocument activity and the microflow end event.
-
Configure the AbstractDocumentAnalysisResponse_ProcessResults microflow by doing the following steps:
- Double-click the AbstractDocumentAnalysisResponse_ProcessResults microflow.
- Set the AnalyzeDocumentResponse parameter.
- Click OK.
-
In the Toolbox pane, find the List operation activity.
-
Drag the activity onto the microflow area between the AbstractDocumentAnalysisResponse_ProcessResults microflow and the end event.
-
Configure the List operation activity by doing the following steps:
- Double-click the activity.
- Select Head as the operation.
- Select the list that the AbstractDocumentAnalysisResponse_ProcessResults microflow returns.
-
Create a page with a data view of the Page entity, and configure the page to display the specialized
BlockItem
model. -
In the Toolbox pane, find the Show page activity.
-
Drag the activity onto the microflow area between the List operation* activity and the end event.
-
Configure the Show page activity by doing the following steps:
- Double-click the activity
- Select the page with a data view of the Page entity.
- Set the Page parameter
- Click OK.
-
On the Document_Overview page, right-click the Delete button and add an Action button.
-
Right-click the Action button, and select the ACT_AnalyzeDocument microflow as the on-click action.
Technical Reference
The module includes technical reference documentation for the available entities, enumerations, activities, and other items that you can use in your application. You can view the information about each object in context by using the Documentation pane in Studio Pro.
The Documentation pane displays the documentation for the currently selected element. To view it, perform the following steps:
-
In the View menu of Studio Pro, select Documentation.
-
Click on the element for which you want to view the documentation.