Share

[[{“value”:”

 

Introduction

In my previous blog post, I covered [what is SAP AI Core] and its core capabilities for enterprise AI. Now, the next logical step is to integrate an LLM model from SAP AI Core into your SAP Build Process Automation (BPA) projects.

The goal of this blog is to show you how to call SAP AI Core’s LLM endpoints from within BPA, enabling you to use foundation models for intelligent text processing, data extraction, and semantic understanding within your automation workflows.

Real time Use Case: Email Content to JSON Extraction

Consider a common business scenario: You receive unstructured email content and need to extract key information (sender, invoice number, amount, approval status, etc.) and convert it into structured JSON for backend API calls.

The challenge is that email content varies widely. Templates differ, content formats change, and manually parsing every variation is not scalable.

Solution: Use an LLM to understand the email content semantically and extract the required fields into a consistent JSON structure. SAP AI Core makes this possible without maintaining rigid parsing rules.

Prerequisites

Before you can integrate SAP AI Core into BPA, ensure you have:

  • SAP AI Core Access
    An active SAP AI Core subscription with at least one foundation model deployed and running.
  • Destination Configuration
    A destination configured in SAP BPA pointing to your SAP AI Core instance. Refer to the [SAP Help documentation] for details on setting up destinations.
  • SAP Build Process Automation Access
    An active BPA subscription with permissions to create and edit automations.
Step 1: Prepare Your Prompt

Before calling the LLM, craft a clear prompt that describes the task. The prompt should:

– Define the input (e.g., “You will receive an email content”)
– Specify the output format (e.g., “Return a JSON object with fields: sender, subject, invoice_number, amount, approval_status”)
– Provide examples if needed

For detailed guidance on prompt engineering and best practices, refer to the [Prompt Management in SAP AI Core] blog post.

Example prompt:

Extract the following information from the email content and return it as JSON:

  • sender: email address of the sender
  • subject: email subject
  • invoice_number: invoice number if present
  • amount: invoice or order amount if present
  • approval_status: approved, pending, or rejected

Email content: {emailContent}

Return only valid JSON, no additional text.

Step 2: Call SAP AI Core from BPA

In your BPA automation, use the Rest Call Web Service activity to invoke the SAP AI Core LLM endpoint. Here is the request payload structure:

const data = {
“messages”: [{
“content”:PromptQuery,
“role”: “user”
}],
“temperature”: 1

};

return {
method: ‘POST’,

url: “inference/deployments/<url-content>/chat/completions?api-version=latest”,
responseType: ‘json’,
resolveBodyOnly: false,
rejectUnauthorized: false,
headers: {
‘Content-Type’: ‘application/json’,
‘AI-Resource-Group’ : ‘default’
},
body: JSON.stringify(data)
};

Understanding the Request Structure

Messages Array
The messages array contains the conversation. Each message has:

  • role: user for user input, assistant  for model responses
  • content: The actual prompt or user query

Temperature
The temperature  parameter controls the randomness of responses:

  • 0: Deterministic (best for structured extraction)
  • 1: Balanced (default)
    – Higher values: More creative responses

For email-to-JSON extraction, a lower temperature (0.3–0.5) is recommended for consistency.

Deployment URL
Replace <deployment-url> with the actual URL obtained when you deployed your foundation model in SAP AI Core.

AI-Resource-Group
This header specifies which resource group the request should use (default is `”default”`).

Step 3: Process the Response

The response from SAP AI Core will contain the model’s output. Extract the JSON from the response:

Example BPA step to process the response

let extractedData = response.choices[0].message.content;
let jsonData = JSON.parse(extractedData);

Now use jsonData.sender, jsonData.invoice_number, etc.

Real-World Example Flow

1. Email arrives → stored in a variable
2. Construct a prompt with the email content
3. Call SAP AI Core using Rest Call Web Service
4. Extract the JSON response
5. Validate the JSON structure
6. Use extracted fields to create a backend API payload
7. Call the backend system to process the data

Conclusion

Integrating SAP AI Core into your BPA processes unlocks powerful capabilities for handling unstructured data. Whether you are extracting information from emails, summarizing documents, classifying content, or performing semantic analysis, LLMs can simplify and automate complex logic that would otherwise require rigid rules or manual processing.

 

 
Integrating SAP AI Core into BPA gave our team a fundamentally different way to handle unstructured input. Instead of writing fragile parsing logic, we now  describe *what we want* in plain language via a prompt, and the LLM reliably delivers structured JSON in return.

If you have requirements to connect BPA with LLMs, this approach will significantly reduce development complexity and improve automation flexibility.

“}]] 

  Read More Technology Blog Posts by Members articles 

#abap

By ali

Leave a Reply