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

on

|

views

and

comments

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

Amit Singh
Amit Singhhttps://www.pantherschools.com/
Amit Singh aka @sfdcpanther/pantherschools, a Salesforce Technical Architect, Consultant with over 8+ years of experience in Salesforce technology. 21x Certified. Blogger, Speaker, and Instructor. DevSecOps Champion
Share this

Leave a review

Excellent

SUBSCRIBE-US

Book a 1:1 Call

Must-read

How to Utilize Salesforce CLI sf (v2)

The Salesforce CLI is not just a tool; it’s the cornerstone of development on the Salesforce Platform. It’s your go-to for building, testing, deploying, and more. As one of the most important development tools in our ecosystem

Save the day of a Developer with Apex Log Analyzer

Table of Contents What is Apex Log Analyzer? Apex Log Analyzer, a tool designed with Salesforce developers in mind, is here to simplify and accelerate your...

Salesforce PodCast

Introduction Hey Everyone, Welcome to my podcast, the first-ever podcast in India for Salesforce professionals. Achievement We are happy to announce that we have been selected as Top...

Recent articles

More like this

13 COMMENTS

  1. Hi Amith,
    I am getting “variable does not exist: attributes at line 18” error in the EinsteinOCRService class. In the below method.
    AuraResponseWrapper readBusinessCardBase64(String sampleBusinessCard, String objectName)

  2. can we detect and create records if the image/pdf has both unstructured text and tables as well like in invoices or bills or bank statements for which the attribute tag names created from the json response cannot be matched as it predicts ‘OTHER’ for every text detected.

  3. Hi Amit,

    Can we have this setup automated for getting the PDF’s in bulk from Snowflake and doing the OCR to create new Records ?

LEAVE A REPLY

Please enter your comment!
Please enter your name here

5/5

Stuck in coding limbo?

Our courses unlock your tech potential