activities
latest
false
UiPath logo, featuring letters U and I in white
Productivity Activities
Last updated Nov 15, 2024

Verify if new employment documents (I9 and ID) match

About

Summary: Extract I9 and ID documents arrived by email and verify if both documents have the same holder. The email is moved, categories are set, and reply or forward actions are performed based on checks.

Applications: Outlook Email, Document Understanding

Description: This examples explains how to create a workflow that verifies new employment documents (I9 and ID). When a new email arrives containing a specific subject with attachments, the robots get triggered to download the two attachments and verify if the two attachments are ID and I9 documents. After validation, it extracts the content from the two documents and verifies if they belong to the same person, by checking the first name and last name. Once the documents are checked, the email is moved to a specific folder (Valid Submissions / Invalid Submissions), categories are set, and the email is forwarded if valid, or a reply is sent back to the sender if it is invalid.

This example presents Microsoft 365 activities such as Email Received, Download Email Attachments, Move Email, and Document Understanding activities.

Workflow

  1. Open Studio Web and create a new project.
  2. For How to start the automation select Event based, then select the Microsoft 365 Email Received trigger activity.
  3. In the trigger activity:
    1. Set up your Microsoft OneDrive & SharePoint connection.

    2. Set the Email folder field. For example, Inbox.

    3. Set the Additional filters to be as specific as possible. For example, in this case, set the filter as: Subject contains New employment.
    4. Set the optional fields:
      • With attachments only - On.
      • Include attachments - True.
      • Mark as read - False.


  4. Add a Log Message activity to record the received email's subject. In the Text field, select the output variable of the trigger activity and drill down to identify its Subject property:


  5. Next, add two consecutive Download Email Attachments activities. At this step in the workflow, the attachments containing the required documents (I9 and ID) are downloaded. Configure the activities as follows:
    1. First, rename each activity, to easily identify them further in the workflow. For example: Download Email Attachments - containing I9, type PDF and Download Email Attachments - containing ID, type PDF.
    2. Set up your Microsoft Outlook 365 connection.
    3. For the Email field, select the output variable of the trigger activity.
    4. Set up the Advanced filter to determine what type of documents you want to download:




    5. Set Exclude inline attachments to False.
  6. Next, add an If activity to verifiy if the two attachments are indeed ID and I9 documents.
    1. Set the Condition to check if the output variables of the two Download Email Attachments activities equal 0 (i.e., no documents were identified using the set filters):




  7. Configure the Then branch of the activity, i.e., the activity to execute in case the condition is true. Add a Reply to Email activity. Its purpose is to notify senders that their documents were not submitted properly. See an example of how to configure this activity below:


  8. Right next to the Reply to Email activity (inside the Then branch), add a Throw exception activity and configure it as follows:


  9. Next, we'll use Document Understanding activities to extract the content from the two documents and verify they belong to the same holder by checking the first name and last name in each document.
  10. Add a Document Understanding Classify Document activity. Rename it to Classify I9 Attachment Document.
    1. For the Input field, select the output variable of the Download Email Attachments - containing I9, type PDF activity.


  11. Add a Log Message activity, to log the I9 document type. In the Message field, select the output variable of the Classify I9 Attachment Document activity and drill down to Document Data to find the DocumentType property.


  12. Next, add an If activity, to verifiy the I9 document classification. Configure the condition as follows:
    1. Select the output variable of the Classify I9 Attachment Document activity, then drill down to Document Data > Document Type > Name > Name.
    2. Set the condition: Name contains i9. In the Expression editor, the condition looks like this: _out_ClassifyDocument_1__ClassificationResults.DocumentType.Name.Contains("i9").


  13. For the Then branch, add an Extract Document Data activity. Configure the activity as follows:
    1. For the Extractor field, select I9 from the dropdown list.
    2. For Input file, select the output variable of the Download Email Attachments - containing I9, type PDF activity.


  14. For the Else branch, i.e., the activity to execute in case the condition is false, add:
    1. A Log Message activity, with the following message: The Email doesn't contain an I9 Form.
    2. A Throw exception.


  15. Next, add another Classify Document activity, to classify the ID documents. Rename it to Classify ID Attachment Document.
    1. For the Input field, select the output variable of the Download Email Attachments - containing ID, type PDF activity.


  16. Add a Log Message activity, to log the ID document type. In the Message field, select the output variable of the Classify ID Attachment Document activity and drill down to Document Data to find the DocumentType property.
  17. Next, add an If activity, to verifiy the ID document classification. Configure the condition as follows:
    1. Select the output variable of the Classify ID Attachment Document activity, then drill down to Document Data > Document Type > Name > Name.
    2. Set the condition: Name contains id_cards. In the Expression editor, the condition looks like this: _out_ClassifyDocument_2__ClassificationResults.DocumentType.Name.Contains("id_cards").


  18. For the Then branch, add an Extract Document Data activity. Configure the activity as follows:
    1. For the Extractor field, select ID Cards from the dropdown list.
    2. For Input file, select the output variable of the Download Email Attachments - containing ID, type PDF activity.


  19. For the Else branch, i.e., the activity to execute in case the condition is false, add:
    1. A Log Message activity, with the following message: The Email doesn't contain an ID.
    2. A Throw exception.


  20. Next, add a series of Log Message activities to record the First Name and Last Name on the I9 and ID documents.
    1. In the Message Field, write I9 First Name, then drill down to the Variables section > I9_Doc > Data > EmployeeFirstName.
    2. Repeat step 22a for I9 - Last Name, then for IDCard > FirstName and IDCard > LastName.


  21. Add an If activity, to verify if the first name and last name in each I9 and ID match. Set the condition as follows:
    • I9_Doc.Data.EmployeeFirstName.Value.ToLower.Trim contains IDCard.Data.FirstName.Value.ToLower.Trim
    • I9_Doc.Data.EmployeeLastName.Value.ToLower.Trim equals IDCard.Data.LastName.Value.ToLower.Trim


  22. For the Then branch, add:
    1. A Log Message activity to state that the I9 and ID match.
    2. A Move Email activity, configured as follows:
      1. Email to move - Select the output variable of the initial trigger Email Received activity.
      2. To email folder - For example, a Valid Submissions folder.


    3. A Set Email Categories activity, to assign a Valid Submission category to the moved email.
    4. A Forward Email activity, if you want to forward the moved email to someone.
  23. For the Else branch, add:
    1. A Log Message activity to state that the I9 and ID don't match.
    2. A Move Email activity, configured as follows:
      • Email to move - Select the output variable of the initial trigger Email Received activity.
      • To email folder - For example, an Invalid Submissions folder.
    3. A Set Email Categories activity, to assign an Invalid Submission category to the moved email.
    4. A Reply to Email activity, to remind the sender that their email was considered invalid because of the documents.
  24. You're done and ready to run your project!
  • About
  • Workflow

Was this page helpful?

Get The Help You Need
Learning RPA - Automation Courses
UiPath Community Forum
Uipath Logo White
Trust and Security
© 2005-2024 UiPath. All rights reserved.