Human Capital Management Blogs by SAP
Get insider info on SAP SuccessFactors HCM suite for core HR and payroll, time and attendance, talent management, employee experience management, and more in this SAP blog.
Showing results for 
Search instead for 
Did you mean: 
Product and Topic Expert
Product and Topic Expert

This blog post will give you an overview of how you can integrate SAP Commission with SAP Conversational AI using SAP Commission API end points.

Use case:

I've used a simple use case for this post. The use case is to retrieve the title for the position name(payee) that the user provides in the chatbot . We will be using the SAP Commission API endpoint for positions to get this info.


  1. SAP Business Technology Platform(BTP) Account

  2. SAP Cloud Foundry CLI

  3. SAP CAI account - Create account in

  4. SAP Commissions user with RestAPI Basic Authentication. I have used the sandbox tenant for this use case.

Solution Diagram:



The blog post will be divided into 3 sections:

  1. Creating a python app to make REST API calls

  2. Host app in SAP BTP

  3. Creating a bot in SAP CAI

Creating a python app to make API calls

Below is the python app that interacts between SAP CAI and SAP Commissions. Copy the below python code and save the file as in your desired local directory.
from flask import Flask, request, jsonify
import os
import json
import requests

app = Flask(__name__)
cf_port = os.getenv("PORT")
def hello():
return '<h1>SAP Conversational AI</h1><body>The Commissions GetTitle webhook for use in SAP Conversational AI chatbots</body>'

def bot():
#Edit the url, username and password before deploying to SAP BTP
url = "YourTenantUrl"
########## GET SLUG ##############
data = json.loads(request.get_data())
skill = data['conversation']['skill']
if skill == 'commissions-gettitle':
nlp = data['nlp']
intents = nlp['intents']
slug = intents[0]

########## GET TITLE ##############
if final_slug == 'gettitlename':
position_value = data['nlp']['entities']['position']
position = position_value[0]
base_url = url+"api/v2/positions?$filter=name eq "+final_position+" &select=name,title&expand=title"
r = requests.get(base_url , auth=(Username,Password))
pos_data = json.loads(r.text)
for x in pos_data['positions']:
y = (x['title'])

return jsonify(
'type': 'text',
'content': 'The title name is %s' % (TitleName)

if __name__ == '__main__':
if cf_port is None:'', port=5000, debug=True)
else:'', port=int(cf_port), debug=True)

Please note that you have to provide your SAP commission tenant's url and credentials(basic auth with rest api user) in the file before pushing this app to SAP BTP.

In order to deploy this app to SAP BTP you will need 4 other files along with the file.

  1. Procfile

  2. manifest.yaml

  3. requirements.txt

  4. runtime.txt

All of these files will have to be saved in the same directory as the file.

Save the below as Procfile
web: python

Save the below as manifest.yaml
- name: getTitle
random-route: true
memory: 128M
command: python


Save the below as requirements.txt


Save the below as runtime.txt

Once you're done you should be able to see all your files in the same folder, something like this as shown below. I've saved all my files under the directory CAI_Blog/Commission_GetTitle. Now that you have all the required files we can now push this to SAP BTP.



Host app in SAP BTP

Go to the directory/folder where you have saved the above files using your command line or code editor(like VS Code) and login to your CF using your email id and password.

cf login

Push the app to SAP BTP using the below command

cf push GetTitle


Once successfully hosted, you can login to your SAP BTP cockpit and check if the app is up and running. You should see something like this.


Once the app is deployed successfully you should get an Application route url, copy this. We will be using this when we create the bot in SAP CAI.



Create a bot in SAP CAI

The first step is to create a bot which will help the user interact with SAP Commissions. In case you are a first time user login to  and create your account. Once you've created your account perform the below steps

  • Create a new bot with the name GetTitle.


  • Click on Perform Actions

  • Under Select predefined skills for your bot, select Greetings. No additional skills are required for this use case


Select the following options and click create.



Next step is to train the bot with intents and entities.

First lets create a new intent with the name getTitleName

Click on this newly create @gettitlename intent. Save the below data as csv file and Import Expressions. These are basically different ways in which you are going to ask the bot for the title names for a position.
Get title for position;en
title for position;en
position title;en
title for position;en
position's title;en
what is the title for position;en
what is the title;en
get title;en
get me the title for position;en
title for;en


You should be able to see the imported intents once the import is successful.


Next step is to add the entities. Here we are going to train the bot to to recognize position names. We will be providing a list of position names which we want the bot to recognize.


We will be creating a restricted entity with the name 'position' for our use case



Once created you will see the custom entity #position. Click on it . Save the below data as csv and import the entities. Please note, these will have to be a valid list of position names in your tenant. Otherwise this bot will not work.


Once the entities and intents are setup its time to create a skill.

Go to the Build Tab and click on Add Skill. Name the skill as Commissions-GetTitle and click Add.



Click on the created skill Commissions-GetTitle and add triggers are shown below

Then set up the requirements as shown below.


We will then need to setup the action. Click on create new action group.

Add the below condition to trigger action.


Click on Connect External Service and select Call Webhook option.

Here we will be using the application route url which was generated in SAP BTP described in Host app in SAP BTP section. Select POST request and paste the copied application route endpoint. Do not forget to append /Title at the end of the URL, because this is the route we have defined in our python app.

Click on Save.




Finally click on the Train button which will train the bot . The color should turn green once the bot is trained with the latest configuration.


Voila, our bot is now ready. Lets test our bot. Click on the chat preview at the bottom right.


Ask the bot for the title name for any of the positions provided in the entities list and it will return the title name.


You can go a notch further and integrate with any of the chat platforms like Slack, Teams or Skype etc. You simply have to follow all the steps provided in the this page. Do give it a try, it is quite simple.



We were able to successfully build a simple chatbot using SAP's Conversational AI which can talk with SAP Commissions. We have used a very simple use case wherein we get the title for a position the user requests for.. However I'm sure the audience reading this, especially from SAP Commissions background have more complex requirements which I'm looking forward to hear .

Please drop in your comments, questions if any and also share your feedback.

Thanks for reading and happy learning.