The SAP Community is literally flooding now with AI and Generative AI-related blogs.
Organizations started to adopt ChatGPT for several generative or automation tasks.
-
Content – Suggestions, Rectification, Generation
-
Code – Suggestions, Rectification, Generation
-
JSON~XML Conversions and API Integrations
-
Data analysis with ChatGPT
& more….
Why I started to write this blog today, is the Idea of Generative AI is getting changed, and the business is trying to explore the new capabilities of ChatGPT and ChatGPT-powered tools.
To perform the dynamic OCR extraction from PDF and Automate the Business Process, you definitely need the below tools:
If we want to place all these things into one place, it will look like below –
The Idea of AI-enabled OCR was to help the business extract the information using OCR and contextualize the extracted attributes to the Business means. This happens with Cognitive AI. Which is an AI/ML-based Business entity recognition model, which identifies the coordinates from the Business Document with the field name attributes.
Drawbacks –
- It generates a new contextualization on its own, as it has a rigid way of JSON generation.
- Also, the mapping to the context is very painful – as it takes lots of time to map an output JSON, and also if the production JSON is missing some parameters we as a human need to train the Business document template to get the required outcome.
- Not vastly trained to give predictive dynamic columns
- Can not be used for a document that does not have a template
Now, what happened in GenAI is contextualization to the Business entity is going to happen very smoothly and intelligently and is dynamically generated. This is a basic diagram to understand the idea behind this approach:
Benefit –
- Purely dynamic generations of the item, address entity recognitions, and JSON conversion capabilities
- Flexible and can be integrated with each type of required JSON format. Less time to train and deploy.
- Any type of PDF can be extracted with proper contextualization to the LLM Models
Drawbacks –
- Security of LLM Model prompts
- Not rigid of static outputs. The LLM models generally produce dynamic outputs. Which can be stabilized up to a certain point, not as a whole can be done.
Only we need the API keys here.
- To retrieve the ChatGPT API key, go to the URL – https://platform.openai.com/account/api-keys
- To retrieve the Chat-PDF API Key, go to the URL – Chat-PDF. Then go to your Account Button at the left bottom and expand the Developers section. Developer’s guide is available here.
🔀 Upload a PDF File from the left pane –
🔀 Let’s ask Some Basic Questions now –
🔀 Now Ask a Question to generate JSON data for you from the PDF extraction –
Now, I will try to predict the questions running through your mind and answer them..
⏩ What I am getting in this Blog?
An automated Tool for Customer Purchase orders to Sales order creation.
If your GMAIL receives a Vendor Invoice / Customer PO, this automation tool can process the PDF attachment and extract information from it to POST an event in SAP S4 HANA and revert to the Vendor / Customer Email.
⏩ This type of solution is already present, Boss? Then Why again?
It is there… But we will use Generative AI now.
⏩ What is the Business Value you have?
⏩ What is new you are doing here?
⏩ What is the benefit?
⏩ Why we will adopt and invest in this?
The main reason is that it will reduce your effort in Vendor Invoice or Customer PO PDF Mapping.
It can also adapt to all of your PDF onboarding and dynamic JSON and Mapping Generations. Auto adaptations to your environments.
⏩ How is that possible, Boss?
OKAY… Here is how…
Create an Automation Flow…
The all-in-one platform by SAP which is having all niche capabilities and is the tool for automating your SAP and other Automation Processes.
Sample JSON script for HTTP GET will look like this –
const url="https://ngrok-propagate.cfapps.us10-001.hana.ondemand.com/check_unread_email";
const headers = {
};
const options = {
'method': 'GET',
'url': url,
'headers': headers,
'responseType':'json',
'resolveBodyOnly':true
};
return options;
Step 2 – NodeNinjas Pick up Node-RED, Similar to Shield of Captain America ⍟⍟
Install the below Plugins for Node-RED.
/check_unread_email
a. Read the email from your inbox
b. Categorize the Email and check for Customer PO
c. Save the POST the attachment to ChatPDF
d. Respond back with the sender’s Email ID and sourceID
/get_pdf_data
a. Create a Chat Query to extract the information from PDF.
b. Prompt Used – “Fill the below json, with values from the document. Also wrap json code output in <code></code>, without json beautifying – >”
c. Also pass the Json expected output structure in the Content.
d. Now extract the json with magical function –
var mystring = msg.payload.content.toString();
var fromvalue = mystring.split("<code>");
var tovalue = fromvalue[1].split("</code>");
msg.payload = tovalue[0];
return msg;
/delete_pdf_file
a. Delete the PDF file from ChatPDF
/dummy_sales_order
a. Map your S/4 HANA API intelligently
b. Trigger your S4 HANA Sales Order API.
c. Return the Sales Order number as a return parameter
/send_email
a. Set up the Context to ChatGPT.- “Create an email body without any variables and within 100 Words.”
b. Prompt ChatGPT to create an Email Body. Clearly mention and set the expectations. It’s your Personal assistant. It will work for you…
msg.payload = 'We have Created Sales Order number: '
+ so
+ 'Starting with Hi Team, '
+ 'Ending with: ' + 'Regards, sabarnapass@gmail.com'
+ 'If delay happens from our side. We will inform you'
msg.topic="Your Reference Sales Order:" + so;
return msg;
Step 3 – SAPBTPDeployX Pick up Ngrok, NodeJS, BAS, CF-CLI, similar to the Infinity Gauntlet🫰 of IRON Man🦾🤖
Ngrok –
Install and fire Ngrok
ngrok http 1880
BAS + NodeJS = ngrok-propagate
a. Install npm libraries
{
"name": "ngrok-propagate",
"version": "1.0.0",
"description": "",
"main": "index.js",
"scripts": {
"test": "echo \"Error: no test specified\" && exit 1",
"start": "node index.js"
},
"author": "",
"license": "ISC",
"dependencies": {
"axios": "^1.5.0",
"express": "^4.18.2"
}
}
b. Create an express server using NodeJS
c. Do not forget your .yaml file.
Now 🥁🥁🥁🥁……
CF PUSH – a wonderful document by DJ Adams
And SNAP…..
Now your system somewhat looks like –
I understand it’s not the exact same one, what you have thought.
But if you go through the blog till now, I am sure you have everything in your hand to integrate ChatPDF and ChatGPT to your S4 HANA Suite.
⏩ This solution is GOOD, but it has problems…
Yes, using ChatGPT presents a number of challenges that organizations and individuals are discovering:
- Inconsistency in output of LLM- Data generated
- Contextual tuning time
- Security of sensitive data
⏩ What’s Next? What I can learn more?
- Keep your eye on SAP AI Business Services to see how they are re-imagining Business Automation.
- Also, similar Generative AI-based tools are being developed by SAP, I guess. Keep any on the blog, Document Information Extraction Premium Edition by Tomasz Janasz.
- Yes, you can create custom application using pytesseract and ChatGPT to perform kinda similar type of work.
- There is a chance that you get the Customer PO, Vendor Invoices in different language. You can try to integrate Document Translation Service as well if required.
- I got a chance to speak about SAP AI Business Service in one of the SAP Community Kolkata – Event. Here is the full code base if you want to scroll through.
As you can see, all these AI tools are kind of Avengers.
I still remember that day when a TensorFlow Deep Learning model was trying to Play Mario and was learning from its own play score.
Although, the barriers will be there to adopt something new. Critical-Thinkers, Designers will be coming up a plan with have to draw the line of Data Sensitive and Security Aspects.
Do you know What’s there in SAM Altman’s Bag pack? Have a peek here –
The Generative AIs of this generation have started to generate a new Generation of Business Processes.
The Time is Here, the Time is Now…
Be the first to comment