+
+

Lab 1: Process an Invoice with MuleSoft IDP

Overview

We will now dive into the practical application of IDP by processing an invoice. This lab will guide you through the steps of configuring a document action of IDP to accurately extract key data points from an invoice, such as invoice number, date, total amount, etc.

Before we begin download the Learners Repository here

Step 1: Create a New Document Action

  1. Log into Anypoint Platform. In the Anypoint Home menu, under the Automation section, click on the Get Started button to access the Intelligent Document Processing tool.

    module g  idp access
  2. Now the MuleSoft IDP Home page is opened. Let’s do a short review about the menu options. The menu is on the left side, which has three different options:

    • Home:This is the access to review the latest document actions created and create new ones.

    • Document Actions: A document action is a multi-step process that uses multiple AI engines to scan a document, filter out fields, and return a structured response as a JSON object. Each document action defines the types of documents it expects as input, the fields to extract, and the fields to filter out from the response. It can be hidden fields, mark fields as required, configure the minimum confidence score accepted for each field to extract, and configure Prompts to enhance and refine the data-extraction process by asking questions using natural language.

    • Review Tasks: Document actions return a JSON response that contains the extracted fields and their detected values. Each of these values has a confidence score that determines the accuracy of the value during the extraction. A document is queued for review if at least one non-hidden field shows a confidence score lower than the configured threshold or At least one non-hidden field marked as required is missing or could not be extracted. After a reviewer verifies and approves the result, the execution status changes to SUCCEEDED.

      module g  idp menu
  3. Let’s go to create a new IDP Document Action. Click on Create New button.

    module g  idp createnew
  4. At this point a window will open where you can configure the new Document Action. There are different types to be selected:

    • Invoice: This is an out-of-the-box template that helps extract information from different types of invoices. It includes pre-built extraction for various fields and line items from the invoices.

    • Purchase Order: This is an out-of-the-box template that helps extract information from different purchase orders. It includes pre-built extraction for various fields and line items from the purchase orders.

    • Generic: This is the type where generic document templates can be configured, allowing prompts to be set up to extract the needed information using natural language and AI.

    module g  create doc act modal
  5. Select the document type, and for our purposes choose the Invoice.

    module g  doc types inv
  6. In the middle bar you can check what type of data will be extracted by default from the IDP, based on the document type.

    module g  invoice fields
  7. Next enter name and description as follows:

    • Name: <Your Initials> - NTO Invoice

    • Description: <Your full name> - NTO Invoice

      module g  new doc act inv fields
  8. Click the button Create.

    module g  create doc act confirm btn

Step 2: Process the NTO Invoice

This view helps to configure, review, and test the new Document Action before publishing it later.

There are three main areas:

module g  idp conf
  • Menu: This area contains the main menu mentioned in Step 1. You can collapse it by clicking on the arrow.

    module g  idp menu arrow
  • File Selector: This area allows you to select multiple files for testing.

  • Configurator: This area contains two different sections:

    module g  idp conf options
    • Reviewers: It allows the addition of one or more reviewers to a document action to verify and correct the documents queued for review due to low confidence scores or missing required fields.

    • Outputs: Depending on the document action type, it can show up to three main tabs:

      • Fields: These are the fields extracted out of the box by the Invoice and Purchase Order templates.

      • Tables: This is the data related to the line items extracted by the Invoice and Purchase Order templates.

      • Prompts: This is the section where prompts can be defined using natural language to extract additional data apart from what is extracted by the Invoice or Purchase Order templates. For Generic Types, this is the only tab shown.

Let’s start to configure the Invoice Document Action.

  1. Click on the button Select Files, to upload the document to process. Open the Automation Workshop Invoice.png file you’ve been provided with. It can also process multiple files at once.

    Note: The Automation Workshop Invoice.png file is available at path Learners_Repository\Student Files. The Learners_Repository zip can be downloaded from here.

    module g  select files screen
  2. Look on Fields section, and examine the data the IDP will extract by default. Click on TAX field, for example:

    module g  idp fields tab

    Let’s review what is shown. There are four important elements to mention:

    • Visibility: defines if this field shows in the output JSON result. The eye icon is used to set or toggle visibility for the field i.e. hide/show. Click the eye icon to hide this field.

    • Label: defines the name of the field extracted.

    • Required: this option sends the document to review if the field is missing or can’t be extracted.

    • Threshold: the minimum required confidence score accepted for this field. If the returned Confidence value is below the threshold, the document is queued for human review.

  3. Let’s run it. Click on the Run button and examine the data extracted.

    module g  run btn
  4. Click on the scan icon next to the Tax item. This will show where on the document the information has been found. Review the accuracy of the extraction in the Confidence Threshold field and the value extracted.

    module g  idp scan
  5. Now move to the Tables(1) tab and review the content extracted by the Invoice template. Click the Scan icon again and review the line item content extracted in the table below the invoice.

    module g  idp table

Step 3: Add Reviewers

Before being able to publish your document action you need to specify a reviewer for it. Add one or more reviewers to a document action to verify and correct the documents queued for review due to low confidence score values or missing required fields.

Following you see the section where review tasks will be presented to the reviewers.

module g  review tasks page

You can add single Anypoint Platform users or teams as reviewers.

  1. From the document action page click on the Add button next to Reviewers

    module g  add reviewers btn
  2. In the search bar look for your username Automation Workshop, click it, and then click the Add button.

    module g  idp reviewers save
  3. Click the Save button.

    module g  save btn

Step 4: Publish your Document Action to Exchange

Now we can publish our document action making it discoverable in RPA and available in Anypoint Exchange as an API that you can call.

  1. Click on the Publish button.

    module g  idp publish
  2. Click on the Save and Publish button.

    module g  idp publish save
  3. Click on the `View published action in Exchange`link

    module g  idp exchange click
  4. Check the IDP Document Action published in Exchange.

    Expand the API specification in the left-side menu and click the POST method.

    module g  idp exchange

Step 5: Test your Document Action using API Console in Exchange

In this step it can be tested the Document Action using API Console in Exchange. Anypoint Exchange is a curated catalog of reusable assets. APIs, API groups, API spec fragments, custom assets, examples, GraphQL APIs, integration assets such as connectors, policies, RPA assets, rulesets, and templates are some of the types that are supported in Exchange.

IDP configurations are asynchronous processes. As soon as the IDP Document Action is published, the POST and GET methods will be accessible to launch and get the response.

  1. In the new IDP API published in Exchange, you can see two sections:

    module g  idp exchange section
    • Menu (left navigation bar): It is the menu of the all content of the new API published like different methods available to invoke it.

    • Asset Detail Pane: It shows the details related to the asset.

    Now, navigate from the left navigation bar and select the POST method. Review the details about this method.

  2. Go to the Mocking Service section (grey right column) and provide next details:

    module g  idp mock
    • Select Server: Select the https call from the drop down list.

      module g  idp server
    • File Name: type file (not the name of the file on your desktop) and click on the Choose File button. Before attaching the file to extract the data you need to rename it as follows.

      <Your Initials> - NTO’s Invoice.png.

      module g  idp file
    • Client id: include the client_id provided by the instructor.

    • Client secret: include the client_secret provided by the instructor.

      Note. Client ID and Secret are part of a Connected App in Anypoint but for the workshop purpose wont be required to be setup and the instructor will provide them.

      module g  idp auth
  3. Now click on Request Access Token button in the bottom part and copy&save the token.

    module g  idp requesttoken
  4. Go to the header section and add a new header by clicking on the Add button. Select in the drop down list Authorization option and as value insert Bearer <token saved in the previous step>. Don’t forget the space between Bearer and the <token saved>.

    module g  idp header
  5. Click on Send button.

    module g  idp send
  6. The result should be something like this:

    module g  idp result
  7. As mentioned at the beginning of this step, IDP Document Actions are asynchronous; therefore, a GET call must be made to obtain the data result in JSON format. So, now let’s go to launch the method GET for obtain the result.

    Before clicking on the method GET from the left menu, save the id got from the previous call in the result.

    module g  idp id result
  8. Click on the GET method from the menu and review the content has been published.

    module g  idp get
  9. In the URI parameters section, paste the id copied from the previous result in the executionId URI parameter.

    module g  idp vat executionid
  10. Go to the header section and add a new header by clicking on the Add button. Select in the drop down list Authorization option and as value insert Bearer <token saved in the previous step>. Don’t forget the space between Bearer and the <token saved>.

    module g  idp header
  11. Click on Send button.

    module g  idp send
  12. The result should be something like this:

    module g  idp get result

    Review the results. Have a look to Status result. It’s MANUAL_VALIDATION_REQUIRED. This indicates that some of the fields extracted have an accuracy lower than the established Confidence Threshold and require manual validation.

Step 6: Reviewers Task actions (optional)

After processing a document Action, MuleSoft IDP queues it for review if:

  • At least one field marked as visible shows a confidence score lower than the configured threshold.

  • At least one field marked as visible and required is missing or could not be extracted.

In this case, a user must review the document to verify the values for the conflicting fields. After the review is finished, the status of the extraction changes to SUCCEEDED.

Let’s follow the next steps to proceed with the review task actions:

  1. In the MuleSoft IDP menu, select the Review tasks option.

    module g  idp review
  2. The list of the files pending to review will be listed. Select your file and check the data is shown to be reviewed.

    module g  idp review data
  3. Review the data pending validation for extraction. To see the format that will be sent after submitting the changes, enable Show JSON.

    module g  idp show JSON

    You can see the JSON format and download it if it’s needed, clicking on Download JSON :

    module g  idp JSON
  4. After reviewing the extracted data and making the necessary changes, click on the Submit and Done button.

    module g  idp submitDone

    If you want to check the final status of the IDP Document Action after reviewing the data, perform the same steps as in the previous step by launching the GET method.

Submit your feedback!
Share your thoughts to help us build the best workshop experience for you!
Take our latest survey!