To execute an Intelligent RPA API trigger, authentication is required: “To access SAP Intelligent RPA APIs, you need to get a service key from the Service Instance in the SAP BTP (Business Technology Platform) Cockpit.” (see reference document)
If you have provisioned your SAP Intelligent RPA tenant via SAP Business ByDesign, the approach mentioned here is for you. Via the below mentioned Communication Scenario in SAP Business ByDesign, you can get the needed authorization token.
If you are using SAP Intelligent RPA that has not been provisioned via SAP Business ByDesign, this blog post is NOT for you. Please get your BTP service key via BTP.
Step-by-step guide to setup API triggered bots
In this demo we will show you how to trigger the “Business Document Extraction from Email” bot using an API trigger. First we will setup the required communication scenario & arrangement in SAP Business ByDesign. Afterwards, we will specify how to setup the API trigger in SAP Intelligent RPA and will showcase how to call the APIs to execute the bot.
Create communication scenarios under work center view Application and User Management - Communication Scenarios. This Communication Scenario will enable you to get the needed BTP token for authorization with Intelligent RPA.
Service Name: iRPAServiceInboundSI
Create a Communication Arrangement under work center view Application and User Management - Communication Arrangements
Now to go to WCV Application and User Management - Service Explorer, search with term "iRPA*", download the WSDL file and make a note of the URL.
If you have not done so yet: Register your Intelligent RPA tenant in your Desktop Agent, and set the Agent to “unattended” mode.
Open your Intelligent Robotics Process Automation Cloud Factory.
Go to your environment (or create a new one) and add a package that you want to trigger via an API. Here, we will be using the Business Document Extraction from Email bot as an example.
Add your Desktop Agent to your environment via the "Add Agent" button.
Create an API Key under your environments in the “API Keys” menu by clicking on “Add API Key”. Make a note of the API Key as it will be displayed only once.
Make a note of API Key as it will be displayed only once!
Add the API trigger by clicking on “Add Trigger” in the Overview menu (or by opening the “Triggers” menu and clicking on “Add Trigger” there).
Select the package you want to add the trigger for.
Select the API trigger option.
Give the trigger a name and click on the "Create" button.
Copy the payload and URL for later use.
We will now demonstrate the process to run the bots via an API trigger using Postman.
We are using two requests: the first one is to get the authorization token via the SAP Business ByDesign communication scenario (GET). This token is necessary to authorize against the second API call to start the bot. The second request is to start the bot run via the API trigger (POST).
First Request (GET) Below GET request URL is coming from the Service explorer created in step 3. Use the username and password created during the creation of the Communication Arrangement in step 2 to specify the Authorization "Basic Auth".
Specify the Content Type in headers: text/xml
Below we use the XML payload from Service explorer created in step 3 in the "Body". To get the XML payload, open the downloaded WSDL file using SoapUI.
Insert below script to set the authorization token at collection level.
var jsonObject = xml2Json(responseBody);
Second Request (POST)
Now, in the following POST request, enter the URL from step 9 and choose "Inherit auth from parent".
Enter the Intelligent Robotic Process Automation API Key from step 8, and authorization and content type as below in the headers.
Insert the payload extracted from step 9 under "Body" and provide the necessary input values.
Now run the collection.
Check the status of the request.
To check the bot’s execution, go to the Intelligent Robotic Process Automation Monitoring -> Jobs view, where you can find information about all bot runs. Here you can see that the bot had been executed via the API trigger.
You can also verify the bot run in the Desktop Agent, either under "About" as below or under "Job Processes".
This concludes the tutorial. If you have any questions, please reach out via the comment section.