Technical Articles
Using SAP Intelligent RPA API triggers with SAP Business ByDesign
SAP Intelligent RPA supports three types of triggers to start a bot run:
- Scheduled
- Attended
- API
In this blog, we will showcase how you can execute an SAP Intelligent RPA API trigger when using SAP Intelligent RPA with SAP Business ByDesign.
Big thanks to Kapil Anand for creating the technical background to this guide!
SAP Intelligent RPA Reference Document
Background Information
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).
Give the trigger a name and click on the “Create” button. - We will now demonstrate the process to run the bots via an API trigger using Postman.
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”.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.
var jsonObject = xml2Json(responseBody); pm.collectionVariables.set("AuthorizationToken", jsonObject['soap-env:Envelope']['soap-env:Body']['n0:IRPAServiceCredentialsMessageResponseType']['AuthorizationToken']);
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.