Technical Articles
Let’s call iRPA 2.0 bot from CAI chatbot to update SuccessFactors
In my last blog post Calling SuccessFactors OData APIs via iRPA 2.0 I wrote about how we can create an automation which is calling a SuccessFactors API for performing upsert operations. The automation however also needs to be invoked. For this I worked on developing a chatbot which would call the API based trigger of the automation. I read many blogs on parts of the topic. I intend with this blog to encourage the community members to get some hands on with these wonderful LCNC tools.
In this blog you will learn the following:
- Deploying your SAP iRPA automation from cloud factory
- Creating API based trigger for the automation
- Create an extremely simple chatbot in CAI
- Calling the created API trigger from a CAI based chatbot
- Creating notifiers in iRPA to notify/update our conversation in the chatbot
So let’s start 🙂
Deploying your SAP iRPA automation from Cloud Factory
To deploy the automation in the cloud factory we need to generate a package within our project. The generated package will be available for deployment into the cloud factory environment.
Package generation in the cloud factory
Package deployment
Creating API based trigger for the automation
API Trigger creation
Now we will configure our API trigger
API Trigger config
API key
Create an extremely simple chatbot in CAI
We create a chatbot now in CAI which will invoke our API trigger.
Create an action bot
Next we will create a skill that responds to the intent
Create Skill
Add chatbot skill trigger as our Intent
Add a few memory variables
Calling the created API trigger from a CAI based chatbot
We need to use oAuth2 for Authorization to call the iRPA API trigger. We will get the client credentials from the SAP BTP subaccount, using the service key for iRPA service instance.
For the payload we again need to refer our API trigger in iRPA and add the following to the body
You can refer the following json:
{
"invocationContext": {"conversationId":"{{conversation_id}}"
},
"input": {
"password": "{{memory.pp}}",
"username": "{{memory.us}}",
"role":"{{memory.role}}"
}
}
In my last blog post Calling SuccessFactors OData APIs via iRPA 2.0 I only had 2 input parameters. Please note that here I have an additional input parameter in my automation called role which allows me to pass the role name from the chatbot itself.
If you need to use oAuth 2.0 authentication in your project please refer my blog: Using OAuth 2.O to securely call SuccessFactors OData APIs from iRPA 2.0
I adapted the activity for Web Service call with the script below.
var i = 0;
var temp ="";
var cookieField ="";
if(cookie!=""){
for(i=0;i<cookie.length-1;i++)
{
temp = cookie[i].split(";");
cookieField = cookieField + temp[0] + "; ";
}
temp = cookie[i].split(";");
cookieField = cookieField + temp[0];
}
var data = {
"__metadata": {
"uri": "RBPRole",
"type": "SFOData.RBPRole"
},
"roleDesc": "Created from Irpa;",
"roleName": role
};
var payload = {
resolveBodyOnly : true,
method: 'POST',
url: 'https://apisalesdemo4.successfactors.com/odata/v2/upsert',
headers: {
'Authorization': 'Basic '+ cred,
'Cookie' : cookieField,
'Content-Type': 'application/json',
'x-csrf-token' : csrf_token
},
ignoreClientCertificate: true,
body: JSON.stringify(data)
};
return payload;
With this configuration in place you should be able to call the API trigger from the chatbot web client already. You will be able to see the run of the job in the cloud factory monitoring. Also the creation of role in SAP SuccessFactors instance.
We still need feedback information about the job status in our chatbot. This brings us to our last topic of this blog.
Creating notifiers in iRPA to notify/update our conversation in the chatbot
Et voila!
You are done.
Have fun getting your version of bots working 🙂
Happy learning!
Hi Divya,
Thanks for posting!
Is it possible to use Basic Authentication to call the API from RPA?
Regards
Ash
Hello Ash,
Thanks for your comment. I am using Basic Authentication in this post. Please note the user and password being sent through in the request to call the RPA Endpoint.
Regards,
Divya
Hi Divya,
Just confirming, Screenshot showing:
I have tried replacing this with Basic Authentication and get the error below:
"error": "Error while processing request. Server response with an error {\n \"status\" : 401,\n \"message\" : \"Full authentication is required to access this resource\"\n}
Any advice?
Thanks!
Ash
Hello Ash,
I presumed you asked for SuccessFactors API call. My bad.
To my knowledge RPA API can only be called using OAuth2.
Regards,
Divya