Create Contact/Lead from the business card using Einstein OCR API

ANALYTICS & DISCOVERY, Salesforce

Hey Everyone,

Welcome back πŸ™‚ , In this blog post, we are going to learn how to read the details from the Business Card or Visiting card and then create either lead/contact or any custom object record.

To read the business card we need to send the task body parameters with contact as a value.

Before we get started, if you have not gone through with the earlier blog post as those are related to this blog post.

  1. JWT Authentication
  2. Extract text from an image using Einstein OCR API

Let’s start with the development. Fist let’s check how the UI will look like.

Create a Lightning Web Component

So, for the User Interface, we are going to use the lightning web component. Create a Lightning Web Component and you can name it anything. Here is the code for the same

In the above component, we are using FileReader to read the file content as base64 format. You can read more about FileReader here

Modify Our Existing Apex Class “EinsteinOCRService

In our existing class, we have added a new method which is readBusinessCardBase64 which accepts 2 parameters sampleBusinessCard in base64 format and objectName the name of the object where you wanted to insert the record.

Find the complete code here

Remember, we discuss the new body parameter value. Let’s make the change in another existing class “EinsteinAPIService“. Here is the updated code.

Let’s check out the demo

Thanks for reading πŸ™‚ πŸ˜‰

#SFDCPanther #AskPanther

Resources: –

  1. https://metamind.readme.io/docs/detect-text-in-business-cards
  2. JWT Authentication
  3. Extract text from an image using Einstein OCR API
  4. Full Code