Technology Blogs 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: 
former_member746375
Participant
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 kapil04 for creating the technical background to this guide!

 

SAP Intelligent RPA Reference Document

https://help.sap.com/docs/IRPA/c836fab4182e45548b6c6c6d0d0a9146/347ba172a8e64f1c8544f46026446a86.htm...

 

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.

  1. 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



  2. Create a Communication Arrangement under work center view Application and User Management - Communication Arrangements

  3. 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.



  4. If you have not done so yet: Register your Intelligent RPA tenant in your Desktop Agent, and set the Agent to “unattended” mode.




  5. Open your Intelligent Robotics Process Automation Cloud Factory.

  6. 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.


  7. Add your Desktop Agent to your environment via the "Add Agent" button.

  8. 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!




  9. 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.





  10. 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);
    pm.collectionVariables.set("AuthorizationToken", jsonObject['soap-env:Envelope']['soap-env:Body']['n0:IRPAServiceCredentialsMessageResponseType']['AuthorizationToken']);


    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.


  11. 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.