Technology Blog Posts by SAP
Learn how to extend and personalize SAP applications. Follow the SAP technology blog for insights into SAP BTP, ABAP, SAP Analytics Cloud, SAP HANA, and more.
cancel
Showing results for 
Search instead for 
Did you mean: 
fvettore64
Product and Topic Expert
Product and Topic Expert
912

Artificial intelligence (AI) has rapidly become a crucial part of daily life, transforming how we interact with technology. From smart assistants to tailored recommendations, AI enhances convenience and personalization. Recognizing its potential, businesses are increasingly exploring AI integration to boost efficiency, creativity, and customer satisfaction. As companies aim to stay competitive, incorporating AI into traditional processes is becoming essential.

The aim of this article is to provide a practical guide for integrating AI services into traditional workflow processes, demonstrating how businesses can harness the power of AI to optimize operations and enhance decision-making. We will focus on two key technological components:

  • SAP Build Process Automation and
  • SAP Generative AI Hub.

SAP Build Process Automation offers a robust platform for automating and streamlining business processes, helping organizations to reduce manual tasks and increase efficiency. By utilizing this tool, businesses can create workflows that are not only faster but also adaptable to evolving needs.

Meanwhile, SAP Generative AI Hub provides access to cutting-edge AI capabilities that can be seamlessly integrated into these automated processes. This hub enables organizations to leverage AI-driven insights and functionalities, facilitating smarter decision-making and opening doors to innovative solutions.

Together, these tools create a powerful ecosystem where traditional workflows can be enriched with AI functionalities, driving transformative outcomes. In this article, we will explore step-by-step how to integrate these technologies into existing business processes, ensuring that businesses can capitalize on AI's full potential to lead in an increasingly competitive landscape.

A practical use case for integrating AI with SAP Build Process Automation involves managing overdue credits. Traditionally, drafting formal letters for debt settlement is time-consuming. By embedding SAP Generative AI Hub, businesses can automate the creation of personalized and accurate letters, enhancing efficiency and consistency. This AI-driven integration streamlines communication, boosting the likelihood of timely debt recovery and optimizing workflow, thus supporting proactive financial management.

The use case setup involved creating a SAP AI Core environment and using SAP AI Launchpad for deploying GPT-4o and the Orchestration service from the Generative AI Hub. The official documentation (https://help.sap.com/docs/sap-ai-core/sap-ai-core-service-guide/generative-ai-hub-in-sap-ai-core-7db...) provides detailed instructions for completing the setup of the environment.

The solution's implementation starts with the creation of an optimized prompt to generate debt settlement letters using SAP Generative AI Hub. This prompt incorporates three key details: the client's name, the debt amount, and the language for the letter. By structuring these inputs effectively, the AI system can produce personalized, professional letters tailored to each debtor's case, enhancing efficiency and cross-linguistic communication in debt management.

For setting up the interaction workflow with the selected Large Language Model (LLM) using the Orchestration service, focus on these two key components:

  • Templating: This feature allows you to define and customize templates for interaction with the LLM. For your use case, you'll create templates that incorporate the three variables—client name, debt amount, and language preference. This ensures that the model processes the data correctly to generate the desired outputs.
  • Model Configuration: This involves setting up and configuring the specific LLM model you will use, such as GPT-4o. This includes selecting the model version, adjusting parameters for optimal performance, and managing model behavior to suit your specific requirements.

Templating ensures the information flows correctly into the system, while Model Configuration ensures the selected model operates efficiently and effectively to meet your needs.

Screenshot 2025-04-18 alle 10.00.55.png

To ensure the generated letter consistently meets specifications, we can employ the Few-Shot Prompting technique. This involves including one or more examples in the prompt to guide the LLM in understanding the desired response format. 

Screenshot 2025-04-18 alle 10.08.38.png

After creating the prompt, we can start testing it, running the Orchestration workflow and providing some sets of input variables. In particular, we can check the ability to generate the letter in multiple languages.

Screenshot 2025-04-18 alle 10.11.55.png

Once the workflow has achieved the desired level of accuracy, we can proceed to expose it as a REST API. This allows external applications and services to interact with your workflow seamlessly. By exposing our workflow as an API, we enable integration with other systems, facilitate automation, and enhance accessibility for users needing to generate debt settlement letters programmatically, thereby streamlining the entire process.

At this point, it's important to copy the JSON description of the Orchestration workflow, because it will be used to invoke the API:

Screenshot 2025-04-18 alle 11.27.38.png

To expose our workflow as a REST API, we first need to identify the endpoint where the service will be made available. This can be done by accessing the AI Launchpad and navigating to the deployment section of the Orchestration service. There, we will find details regarding the endpoint configuration.

Screenshot 2025-04-18 alle 10.18.39.png

The API authentication requirements should be defined by the SAP Business Technology Platform subaccount administrator. For testing the API from an external location, we need to provide the Authentication Url, the Client ID and the Client Secret. When using the API from a BTP subaccount, we just need to define from the BTP Cockpit a Destination and then the application running in that subaccount will be able to use the API without providing the credentials.

To test the REST API, we can use Bruno, an application available on multiple platforms that facilitates the generation of REST calls and the visualization of results. Bruno is a useful tool for debugging and validating our API, as it allows us to:

  • Create and send various types of HTTP requests to your API endpoint.
  • View and analyze the responses, including headers and body content.
  • Identify and troubleshoot any error messages or issues in the API communication.

Using Bruno, we can ensure that our API is functioning correctly and delivering the expected outcomes before integrating it into live environments.

To configure Bruno for testing your REST API, we need to create a Collection and set up an Environment with a series of variables. Here's how we can do it:

1. Create a Collection:

  • Open Bruno and navigate to the option for creating a new Collection.
  • Name our Collection appropriately based on the API we're testing.
  • Inside this Collection, we can organize different API requests related to our workflow.

2. Set up an Environment:

  • Create a new Environment within Bruno where we can define variables that are used in our requests.
  • Include essential variables such as:
    • `deploymentUrl`: The endpoint URL of your API.
    • `Auth_Url`: The URL for the Authentication.
    • `Client_ID` and `Secret` for the Authentication
    • `Content-Type`: the type of the content of the request

Screenshot 2025-04-18 alle 10.56.29.png

3. Configure Requests:

  • Use these variables in your requests by referencing them in the URL, headers, or body.
  • This approach allows us to easily switch configurations if needed and run tests under different conditions.

In our case, we need to configure a POST requests that sends a message to the Orchestration workflow endpoint. The header of the request should contain the Content Type and the Resource Group where the Orchestration workflow is running in the AI Core service:

Screenshot 2025-04-18 alle 11.15.47.png

The body of the request should contain the description of the worklow process, in JSON format. Also in this case it is possible to define variables containing the Customer name, the Amount and Language of the letter, for easily testing multiple combinations.

Screenshot 2025-04-18 alle 11.20.34.png   

After assigning some values to the variables, we can run the request:

Screenshot 2025-04-18 alle 11.24.49.png

Now it's important to carefully browse the response, to identify in the JSON structure the property where the content of the letter is provided:

module_result.llm.choices[0].message.content

The last step of our activity consists in the integration of the text generation functionality of our API into the SAP Build Process Automation process that manages the unpaid debt collection. Here an Automation, named NotificationCreate, has been implemented that attaches to the context of the workflow the PDF file of the generated letter. 

Screenshot 2025-04-18 alle 11.43.51.png

If you're interested in learning how to automatically attach a generated document into a SAP Build Process Automation workflow, you can read my previous blog article: SAP Build Process Automation: using workflow attachments with robotic automations 

The NotificationCreate automation includes another automation (GenerateLetter) that manages the API call:

Screenshot 2025-04-18 alle 11.55.19.png

This automation receives as input parameters the three variables we defined at the beginning of our implementation: the name of the customer, the amount of the debt and the language of the letter and it includes few simple steps:

Create Output Variable: an empty variable (letterText) is defined for collecting the final result.

Create Content: the prompt is generated and saved in a text variable, named content. In creation of the prompt, we're embedding the three variables we received as input parameters.

Custom Script: a script that prepares the options to be used when invoking the API. The invocation of the API should use the same configuration we tested before with Bruno:

let jsonText = JSON.stringify( { 
   orchestration_config: { 
    module_configurations: {
      llm_module_config: {
        model_name: "gpt-4o",
        model_params: {},
        model_version: "2024-08-06"
      },
      templating_module_config: {
        template: [ 
          {
            role: "user", 
            content: content
          } 
        ],
        defaults: {} 
      } 
        }
      }
} );


let options = {
    url: '/completion' ,
    method: 'POST',
    responseType: 'json',
    resolveBodyOnly: true ,
    body: jsonText,
    headers: {
            'Content-Type': 'application/json',
            'AI-Resource-Group': 'default'
    }		
};

return options;

Then we enter in a Try/Catch branch, that allow us to capture and debug the API related errors.

Call Web Service with Destination: executes to API call, using the options created by the Custom Script. Please notice that the endpoint of the API call here is provided as a BTP Destination. The security is managed by the BTP and the programmer does not need to deal with the authorization credentials, because they are centrally managed by the administrators.

Set Variable Value: the response from the API call is parsed and the text of the generated letter is extracted and saved into the letterText variable. This variable will be used as final ouput of the automation.

Screenshot 2025-04-18 alle 12.12.55.png

Now the implementation of the integration with the Orchestration service is complete. The text of the letter has been generated by the AI service and it can be used to create a PDF document ready to be sent to the customer.

In this article, we've explored the integration of Generative AI services into traditional workflows using an API-centric approach. This method not only enhances process automation but also opens up possibilities for business innovation by extending existing systems with the powerful capabilities of Generative AI.

By exposing  REST APIs, we've demonstrated how Generative AI services, such as automatic text generation, can be directly integrated into business workflows. This approach allows leveraging AI's power and flexibility without completely redesigning existing systems.

Moreover, API integration is highly versatile, applicable to a wide range of applications beyond traditional automation processes. Whether CRM, ERP, or other enterprise software, APIs facilitate easy access to advanced AI functionalities, promoting adaptation and scalability of IT solutions.

APIs act as bridges between Generative AI innovation and established solutions, ensuring a seamless transition and boosting digital transformation. The examples and approaches discussed in this blog equip developers and IT professionals with practical guidance to expand automation boundaries, aiming for greater efficiency, insights, and added value in their organizations.

And that’s all for today! Now you can continue to follow the SAP AI Core Topic page: https://pages.community.sap.com/topics/ai-core-artificial-intelligence, read other posts on the SAP Community Blogs: https://community.sap.com/t5/all-sap-community-blogs/ct-p/all-blogs or become a Certified SAP Generative AI Developer: https://learning.sap.com/certifications/https-ondemand-questionmark-eu-delivery-open-php-session-044....