Automating Creation of Purchase Order Process with MS Teams


Introduction

SAP Intelligent Robotics Process Automation automates the enterprise business processes. Cloud Studio is used to design the end-to-end workflows and the packages can be generated into the cloud factory in SAP BTP. On-premise agent is responsible for execution of these packages and act as digital assistant ( attended automation) or as a digital worker (unattended automation).This blog explains step-by-step process on how to automate the creation of purchase order using Manage Purchase Orders FIORI Application in SAP S/4 HANA Cloud, triggering the automation in the SAP Chatbot using SAP Conversational AI, and then integrating with Microsoft Teams

Prerequisites

Installation steps for the Desktop agent  

https://developers.sap.com/tutorials/spa-setup-desktop-agent.html

Please note the minimum version of the Desktop Agent supported by SAP Process automation is 2.0.20.

  1. Use SAP UI5 Recorder to Automate Creation of Purchase Order in SAP S/4 HANA Cloud: The steps are described below

https://developers.sap.com/group.intelligent-rpa-automation-hana-cloud.html

Generate Package- Once the automation project is created, the package can be generated by clicking the “Generate Package” in the Overview tab

Release Package-  Navigate to the package tab of the Automation factory

Create an API Trigger – 

API trigger opens a dedicated endpoint which allows the execution of the automation by the external application

In the API trigger information pop-up, click Copy and paste it in a notepad (API URL). Click Close. The newly generated trigger is visible in your Environment.

Generating new API KeyTo generate a new API key, click Add API Key

Click Copy and make sure to note down the key

Creating Service Key in SAP BTP Trial

Name the Service key and click Create

View the Service key and copy the clientidclientsecret and URL

  1. 2.  Chatbot Integration

SAP Conversation AI configuration-  Creation of chatbot  in Conversational AI account

Create the Intent based chatbot by clicking the new New Bot. Select the predefined skills like greetings, weather etc.

    Forking the Intent- Train the intent by using the expressions.

Add skill-  In the build tab, click on add skill

Go to the skill and click on trigger to add the forked intent created above

Click on the action type and create new action group and then Click Connect External Service and then click CONSUME API SERVICE.

API Service Configuration

  • POST URL– paste the API trigger URL  ( API URL in API trigger information above)
  • Client ID– paste from the Creating Service Key in SAP BTP Trial section above
  • Client Secret– paste from the Creating Service Key in SAP BTP Trial section above
  • Authorization URL-paste from the Creating Service Key in SAP BTP Trial section above appended with suffix /oauth/token (https://<yourtenant>.authentication.us10.hana.ondemand.com/oauth/token)

Go to the Headers tab and click New Fields and add below

irpa-api-key = key copied from Generating new API Key

In the body tab, add below

{
“invocationContext”: {
“conversationId”: “{{conversation_id}}”
},
“input”: {}
}

Generating Token- Generate design time APIs token in SAP CAI to be able to authenticate the APIs successfully

Copy the Developer token and save it

Note down Auth URLClient ID and Client Secret from the generated token

The Developer token and Design time APIs token information will be used in the next step to create Notifiers

Create Notifiers- Three Notifiers for notifying StartSuccess and Failure status while sending message to chatbot in CAI

  • Start– Notify the start of automation
  • Success– Notify the completion of automation
  • Failure– Notify if automation fails with error details

These triggers are created in the environment tab of the Automation factory

The same way start and failure triggers can be created

  • Token– Developer token
  • Auth URL– Design time APIs token Auth URL- copied above
  • Client ID–   Design time APIs token Client ID– copied above
  • Client Secret–  Design time APIs token Client secret– copied above

Reference blog-Integrate the chatbot with the SAP Intelligent RPA

       3. MS Teams Integration

Click the connect tab in SAP CAI and click on MS Teams third party channels and copy the Messaging endpoints which will be used later in MS Azure resource ( MS Azure Portal)

Log into Microsoft Azure and create a new Azure Bot resource

post creation, click on the resource and then configuration

Add copied values in SAP CAI

Messaging endpoint  is coped as mentioned above

Copy the Microsoft App ID and Secret key Value

Go back to the Azure Portal and click on channels and MS teams and then publish

Click on Open in Teams  to complete the MS team integration with SAP CAI chatbot

4. Demo 

To Wrap, the Purchase order creation process is automated using the attended bot and triggered from the MS Teams. The automation can be extended by reading the data from from an excel, pdf or email etc. for the creation of the purchase order.

Please click on the links for more information on SAP Intelligent Robotics Process Automation content : SAP Community | Q&A | Blogs

Please share your feedback or thoughts in the comment section below

Thanks