SAP Build Apps integration with SAP AI Core services: Part 4 – Integration via Action

Estimated read time 8 min read

In this series of blogs, I will showcase how to integrate SAP AI Core services into SAP Build Apps to develop applications with AI capabilities.

Part 1: SAP Build Apps integration with SAP AI Core services – SetupPart 2: SAP Build Apps integration with SAP AI Core services – Integration via Javascript functionPart 3: SAP Build Apps integration with SAP AI Core services – Integration via REST APIPart 4: SAP Build Apps integration with SAP AI Core services – Integration via Action (current blog)

SAP Build Apps integration with SAP AI Core services – Integration via Action

Currently, the recommended solution for integrating SAP AI Core service into your SAP Build Apps application is to use the new feature Action Integration. In this way, a SAP Build Action project (https://help.sap.com/docs/build-process-automation/sap-build-process-automation/create-actions-project ) for SAP AI Core service will be created first, and then integrated into your SAP Build Apps application.

1. Create an action in Lobby. and select “Build from Scratch.” 

2. Add a custom action, select the operation as “POST,” and provide the value of the endpoint according to your deployment of the AI core service, which you have setup in Part 1: SAP Build Apps integration with SAP AI Core services – Setup

3. Add fields to Input Parameter and Body according the requirement of your SAP AI Core service instance

For examples:

sample JSON for input where you can get from https://help.sap.com/docs/sap-ai-core/sap-ai-core-service-guide/prompt-examples 

 

{
“messages”: [
{
“role”: “user”,
“content”: “Your task is to generate a short summary of …”
}
],
“max_tokens”: 100,
“temperature”: 0.0,
“frequency_penalty”: 0,
“presence_penalty”: 0,
“stop”: “null”
}

 

4. Test your SAP Build Action project

To test your SAP Build Action project, you need to add the BTP destination you created at Part 1: SAP Build Apps integration with SAP AI Core services – Setup to SAP Build Control Tower. Still remember we set

 

sap.applicationdevelopment.actions.enabled = true

 

in Part 1. This property makes the destination discoverable in the SAP Build Control Tower.

To understand more about how to manage destinations in Control Tower, please refer to https://help.sap.com/docs/build-process-automation/sap-build-process-automation/manage-destinations

After adding the BTP destination, you can select it in your Action project and test it.

Once the test is successful, you can open the API response body and click “Generate Output” to populate your Action Output structure automatically. For more details, please refer to https://help.sap.com/docs/build-process-automation/sap-build-process-automation/testing-actions Now, you have completed the creation of an SAP Build Action to consume the SAP AI Core service with just a copy and paste and a few mouse clicks.

5. Release and publish your action

6. Open your SAP Build Apps project, navigate to the Data tab, click “Add Integration,” then select the “SAP Build Library” tile, browse, select the action you just published, and enable it in your SAP Build Apps project.

7. Switch back to “UI Canvas” tab, click the UI component, where you can want to trigger the action, open “Logic Canvas”, drag and drop “Tigger Action” flow function to logic canvas and configure it

8. Please make sure to specify the correct BTP destination that you used when you created your action.

9. Configure the data binding for input and output of “Trigger Action” flow function

10. Preview and deploy your app on both web and mobile

To summarize what we have done, without writing a single line of code, just copy and paste, drag and drop, and a few mouse clicks, we created an SAP Build Action to consume SAP AI Core services, integrated it into SAP Build Apps, and developed an application with AI capabilities.

Compared to Part 2: SAP Build Apps integration with SAP AI Core services – Integration via Javascript function where you need to write JavaScript code, and  Part 3: SAP Build Apps integration with SAP AI Core services – Integration via REST API where you need to manually configure the resource schema for the REST API, the new solution with Action Integration offers a much better experience.

In future blogs, I will further discuss how to use Action Integration to enable more AI capabilities, such as RAG (Retrieval-augment generation), image analysis, anomaly detection, voice-to-text, etc. I will also write other blogs on how to use Action Integration to perform more complex data transactions, such as OData linking, deep inserts, etc. Stay tuned!

 

​ In this series of blogs, I will showcase how to integrate SAP AI Core services into SAP Build Apps to develop applications with AI capabilities.Part 1: SAP Build Apps integration with SAP AI Core services – SetupPart 2: SAP Build Apps integration with SAP AI Core services – Integration via Javascript functionPart 3: SAP Build Apps integration with SAP AI Core services – Integration via REST APIPart 4: SAP Build Apps integration with SAP AI Core services – Integration via Action (current blog)SAP Build Apps integration with SAP AI Core services – Integration via ActionCurrently, the recommended solution for integrating SAP AI Core service into your SAP Build Apps application is to use the new feature Action Integration. In this way, a SAP Build Action project (https://help.sap.com/docs/build-process-automation/sap-build-process-automation/create-actions-project ) for SAP AI Core service will be created first, and then integrated into your SAP Build Apps application.1. Create an action in Lobby. and select “Build from Scratch.” 2. Add a custom action, select the operation as “POST,” and provide the value of the endpoint according to your deployment of the AI core service, which you have setup in Part 1: SAP Build Apps integration with SAP AI Core services – Setup3. Add fields to Input Parameter and Body according the requirement of your SAP AI Core service instanceFor examples:sample JSON for input where you can get from https://help.sap.com/docs/sap-ai-core/sap-ai-core-service-guide/prompt-examples  {
“messages”: [
{
“role”: “user”,
“content”: “Your task is to generate a short summary of …”
}
],
“max_tokens”: 100,
“temperature”: 0.0,
“frequency_penalty”: 0,
“presence_penalty”: 0,
“stop”: “null”
} 4. Test your SAP Build Action projectTo test your SAP Build Action project, you need to add the BTP destination you created at Part 1: SAP Build Apps integration with SAP AI Core services – Setup to SAP Build Control Tower. Still remember we set sap.applicationdevelopment.actions.enabled = true in Part 1. This property makes the destination discoverable in the SAP Build Control Tower.To understand more about how to manage destinations in Control Tower, please refer to https://help.sap.com/docs/build-process-automation/sap-build-process-automation/manage-destinationsAfter adding the BTP destination, you can select it in your Action project and test it.Once the test is successful, you can open the API response body and click “Generate Output” to populate your Action Output structure automatically. For more details, please refer to https://help.sap.com/docs/build-process-automation/sap-build-process-automation/testing-actions Now, you have completed the creation of an SAP Build Action to consume the SAP AI Core service with just a copy and paste and a few mouse clicks.5. Release and publish your action6. Open your SAP Build Apps project, navigate to the Data tab, click “Add Integration,” then select the “SAP Build Library” tile, browse, select the action you just published, and enable it in your SAP Build Apps project.7. Switch back to “UI Canvas” tab, click the UI component, where you can want to trigger the action, open “Logic Canvas”, drag and drop “Tigger Action” flow function to logic canvas and configure it8. Please make sure to specify the correct BTP destination that you used when you created your action.9. Configure the data binding for input and output of “Trigger Action” flow function10. Preview and deploy your app on both web and mobileTo summarize what we have done, without writing a single line of code, just copy and paste, drag and drop, and a few mouse clicks, we created an SAP Build Action to consume SAP AI Core services, integrated it into SAP Build Apps, and developed an application with AI capabilities.Compared to Part 2: SAP Build Apps integration with SAP AI Core services – Integration via Javascript function where you need to write JavaScript code, and  Part 3: SAP Build Apps integration with SAP AI Core services – Integration via REST API where you need to manually configure the resource schema for the REST API, the new solution with Action Integration offers a much better experience.In future blogs, I will further discuss how to use Action Integration to enable more AI capabilities, such as RAG (Retrieval-augment generation), image analysis, anomaly detection, voice-to-text, etc. I will also write other blogs on how to use Action Integration to perform more complex data transactions, such as OData linking, deep inserts, etc. Stay tuned!   Read More Technology Blogs by SAP articles 

#SAP

#SAPTechnologyblog

You May Also Like

More From Author