How to combine Artificial intelligence, Optical Character Recognition and Robotic Process Automation to create an automated business case.
The human resources department of a company accepts a big number of resumes from candidates about different job offers. Then an employee from the HR department must classify the resumes for each candidate and each job offer. Additionally, he must extract the most important information of each candidate from their resumes in order to use their data later during the interview procedure.
This procedure can be facilitated by using the enhancement mechanisms inside BTP platform of Robotic Process Automation and Business Entity Recognition. We will first create a process of automations inside RPA and then will create, train and use a custom machine learning model in Business Entity Recognition service to process the unstructured text and extract the required fields.
The automated solution
This business case must break down in a more analytical way in order to understand even better the subtasks that should be developed. The proposed solution consists of 7 steps:
- Open Outlook application and search for emails within specific subject (e.g job offer code).
- Save all attachments – resumes in a specified folder based on job offer code
- Perform Optical Character Recognition (OCR) for each document
- Save a list of texts of all processed documents in excel file.
- Use Business Entity Recognition and train an AI model specific for HR data
- Call the created BER model and import the excel file
- Receive response from the model and extract specified fields and their percentage of confidence.
The setup of BTP
Image 1. Subscription to SAP intelligent Robotic Process Automation in BTP Cockpit
Image 2. Instance of Business Entity Recognition in BTP
Tutorials for setup of BTP, Robotic Process Automation and Business Entity Recognition
Analytical view and description of steps
First, we must create a project in RPA and inside this project we must create two automations. The first automation will be called “outlook automation” and the second automation will be called “process documents”. We need these automations to run one after another and in order to run sequentially we must include them in a process object. The process will look like image 3.
Image 3. Process containing the created automations
First Automation “Outlook Automation”
The automation consists of the following sub-steps.
- Open outlook Instance
- Search Inbox emails with specific code (job offer) in subject
- Get the total number of emails
- Loop over the list of emails
- Check if there are any and save the attachments
- Release the outlook instance
Image 4. Read Inbox folder, search for emails and save attachments
Second Automation “Process Documents”
In the next step we must read all attachments of the previous step that have been saved in the folder and we must perform Optical Character Recognition (OCR) for each document. As an outcome of this step, we must save the recognized result for every document in specified excel file.
Image 5. Read folder ‘s attachments and perform Optical Character Recognition
The results from the two automations
Image 6 display the result of the first automation which is the attachments inside the specified folder and image 7 shows the auto generated excel file which contains a list of recognized texts from the attachments inside the afore mentioned folder. Image 8 shows the contents of the excel file.
Image 6. The result of the outlook automation
Image 7. The result of process document automation
Image 8. The contents of excel file.
Create an AI model of Business Entity Recognition
At this moment we run one process with two automations and as result we have an excel file with the required extracted information. The next step is to create an AI model of the Business Entity Recognition, to train the model with specified fields that we want to recognize and in the end to call our model by passing the generated excel file of the previous step.
I would like to mention that it would be much better if we had created a UI5 application that it would just accept an excel file and used the AI model. Instead, I used the functionality of Postman program to call the Business Entity Recognition APIs in order to “bypass” the need of a UI5 program.
In the documentation of Business Entity Recognition there is a collection of JSON files that help during the creation of the AI model. You can find it in the following url:
There are some specific steps that should be made in order someone to train a BER model.
- Create a dataset
- Confirm the creation of dataset (Optional)
- Upload training documents to dataset (one file per call).
- Confirm the uploading of the documents (Optional)
- Create a training model by passing the previous dataset
- Wait until training is finished by checking the status of the training job
- Deployment of the model when the training finishes
- Call the AI model and get the response.
- Check extracted fields and their percentage of confidence.
Let’s have a look of all these steps…
- We must add a description for our dataset and call the relevant API for dataset creation. In our case the dataset is called “SAP BER HR dataset”.
Image 9. Create a dataset (e.g “SAP BER HR dataset”)
- We take the datasetID number from the previous response and we put it in the end of the dataset URL. Now, we can confirm that we created a dataset as it shows in image 10.
Image 10. Confirmation of created dataset
- The JSON files that I used in my project during the training phase are part of another project in GitHub. This is very helpful project and I highly recommend to check in case you want to learn more. You can find it in the following url: https://github.com/SAP-samples/teched2020-INT161
The training files are the following:
Image 11. Upload training documents in the dataset.
Image 12. Upload 2 files
- I noticed that when I uploaded both files together the API responded with only one documentID as it shows in image 13. Therefore, I had to upload the second file again. Image 14 shows the confirmation of the uploaded training files to the dataset – the documentCount is now 2.
Image 13. Result after uploading the document
Image 14. Confirm the training documents have been uploaded successfully
- Create a training model by importing a description for the model’s name and the datasetID from the previous step
Image 15. Create a training model ( “Curriculum Vitae BER model” ) by passing the dataset
Image 16. Response after performing the training (status PENDING).
- Before we move to the next step we have to wait until training is finished. By calling the relevant API of training we can check the status of the training job as it appears in image 17 and image 18.
Image 17. Check status of training job
Image 18. Response – Status RUNNING
As soon as our training model is finished (status SUCCEEDED), we will be informed about the end of the training and also the entities that our model can recognize inside a document. In this case the entities are: mobile, title, firstname, lastname, address, zip, city, country, email.
Image 19. Final Response – Status SUCCEEDED
- In order to be able to use the business entity recognition model we have to deploy it. If we don’t do this step, the BER will not recognize our model and the API will say that this training model is unknown.
Image 20. Deploy the training model when finish
When the deployment of the model started, we received a response that the status is STARTED.
Image 21. Response after deployment (status STARTED)
- After the successful deployment, we can test manually our custom model. We got a text from the extracted resumes in excel file and we import it to the API(image 22). The outcome was successful and we received a response with the recognized entities in the text and their percentage of confidence (image23).
Image 22. Manual test of the model
Image 23. Response of our AI model
Another way that we could run this model in a more automated way is by creating a Collection inside Postman, add the API url that we want and just run by importing the excel file(transform to csv). In the first API we must add the following script in order to receive the response and save the inference job id in a variable for the subsequent API call.
Image 24. Script inside first API call
Image 25. Collection of POST and GET calls
As a conclusion, we could say that this document uses the power of Robotic Process Automation and Business Entity Recognition Service inside BTP platform in order to create automations and build custom machine learning models. With Intelligent Robotic Process Automation a business can automate repetitive manual process which takes a lot of time to be performed and basically redirect resources toward high-value activities and processes. On the other hand the Business Entity Recognition can handle a higher number of documents more efficiently and faster and increase the quality and compliance of documents handling processes. Combining these two together can have a major impact on processing manual and repetitive work on businesses.
If you found this blog post helpful please share, like or comment (AI & Automation Tutorial Challenge 2022).