ML integration with Blue Prism

AhmedTM

New Member
I have a ML algorithm (python language coded), basically a binary classifier that I would like to integrate in my WF decision making, mixing up the RPA processes of back and front office but with a more sophisticated decision step to split my workflow into other two branches (or pages) afterwards.
Is it possible to merge external ML algorithm into a BluePrism workflow? How?
Looking forward to your response, thank you.
Regards,
Ahmed.
 

mdhazlee

New Member
Hi @AhmedTM ,

I've read within BP portal we can expose the objects or process as a web-service which your code can call externally. So the decision making can be made within your code and based on the binary outcome, it could choose between 2 objects/ process that are exposed separately as 2 web services. Alternatively, BP also has a webservice-REST object that can consume take in data from a REST webservice (your python code?) and continue from there. I've never really tried this, but would be interested to know how you do it.
 
I have a ML algorithm (python language coded), basically a binary classifier that I would like to integrate in my WF decision making, mixing up the RPA processes of back and front office but with a more sophisticated decision step to split my workflow into other two branches (or pages) afterwards.
Is it possible to merge external ML algorithm into a BluePrism workflow? How?
Looking forward to your response, thank you.
Regards,
Ahmed.
As mdhazlee says, I expect you would have to expose your algorithm as a web service that Blue Prism consumes in a business object. Section 4 of the Blue Prism Web Services guide available on the portal goes into this.

Please update us with your progress, I would be keen to see how it goes.
 

sina.hassani

New Member
For those of you who should stumble on to this thread, i found this link relevant.

The text says:

How can web services be called in BluePrism?



Tolani Jaiye-Tikolo
, Robotic Process Automation (RPA) Developer - Blue Prism
Answered Jul 23, 2018 · Author has 116 answers and 412.2k answer views



Apologies for the late reply and by the way, Suresh already gave a good answer. To reiterate, Blue Prism provides supports for SOAP, WSDL web-based services. Blue Prism object sand processes can be exposed as web services with the intention to
  • Enable third-party invoke them to add work items to the queue, which will be worked by another process or using existing infrastructure such as scheduling
  • Get/Retrieve data from systems which Blue Prism already automates. For example, mainframe systems
  • Trigger processing of work items e.g sending data & also retrieve outputs
Blue Prism objects or processes exposed can only be consumed if certain criteria are met. Some of these criteria are listed as follows
  1. The Web Service XSD Data Type match the supported Blue Prism Data Type e.g date, datetime, flag and etc. Complex Data Types will only be supported if they contain supported Blue Prism Data Type and they will automatically be read as Data Table/Collection in the Object/Process Studio
  2. The WSDL file is well formed and valid
  3. The character encoding of the web service should solely be UTF-8
  4. The third party has a connection to the runtime resources. For instance, they are on the same network and the third party has relevant privilege to access/trigger the exposed process/object. In a case, where the third party application is outside the network, a certificate based encryption is advised to be configured on BP server or a proxy to enforce security
After all the relevant conditions have been met and the object/process published, the Blue Prism exposed will be accessible via the following URL
  1. http://[machine name]:[port]/ws/
Third-Party Web Service can also be consumed in Blue Prism and for this to happen, you must have a general understanding of how this web service works. This means that, you need to have a valid WSDL file and also know the methods/functions that are available to you so as to know how to invoke it.
It is very paramount to consider using the GUI automation before proceeding to the web service route. Although, there are cases where the web service solution is a sticker option i.e going through the back door on a slow GUI may be more effective and result in a faster turnaround but security, cost of build, validation/verification should be weighed against the GUI automation. The solution design should ensure the platforms underpinning the systems are not over-burdened during stress times and thus, causing a denial of service to other customers. Care must be taken to ensure, the solution is efficient and resources are not idle . Blue Prism provides a number of recommendations for defining a Web Service solution in the Document > Web Services section on the portal.
It’s worthy to note that, native supports for creating RESTful web services are not provided by Blue Prism and a code stage may need to be utilised to achieve this. Although, a few VBOs have been supplied as examples to assist developers with relevant experience e.g HTTP, JSON , REST and Oauth.

I hope this helps.
 

MadhuG001

Member
I have a ML algorithm (python language coded), basically a binary classifier that I would like to integrate in my WF decision making, mixing up the RPA processes of back and front office but with a more sophisticated decision step to split my workflow into other two branches (or pages) afterwards.
Is it possible to merge external ML algorithm into a BluePrism workflow? How?
Looking forward to your response, thank you.
Regards,
Ahmed.
Hi Ahmed,
How to run a python code in BP.
As in BP code stage we have only 3 languages(C#,J# & VB.Net)
Please advise
 

Sachin_Kharmale

Active Member
Hello Guys ,

If you want to invoke or use machine learning algorithm in blue prism the you can use two approach.

1. Expose Python program as a web service.
You can expose your python program as a web service.
we can create web service in python with the help of
Django Framework which is available in python and very easy to use.
after creating web service call it from blue prism as steps mentioned in blue prism web services Guide.



2. If your program present on local machine then Invoke python Script in Blue Prism.
If your machine learning program present on your local system then you can eaisly call it from blue prism.
use Code stage in object studio to invoke pyton Script Refer bellow screen shot to invoke python script from blue prism and then you can
get your required output.


Object Studio Flow on Page
View attachment 1575963082217.png

Code Stage Code to Invoke Python Code.
View attachment 1575963169630.png

I hope it will help you..!
 

MadhuG001

Member
Hello Guys ,

If you want to invoke or use machine learning algorithm in blue prism the you can use two approach.

1. Expose Python program as a web service.
You can expose your python program as a web service.
we can create web service in python with the help of
Django Framework which is available in python and very easy to use.
after creating web service call it from blue prism as steps mentioned in blue prism web services Guide.



2. If your program present on local machine then Invoke python Script in Blue Prism.
If your machine learning program present on your local system then you can eaisly call it from blue prism.
use Code stage in object studio to invoke pyton Script Refer bellow screen shot to invoke python script from blue prism and then you can
get your required output.


Object Studio Flow on Page
View attachment 4915


Code Stage Code to Invoke Python Code.
View attachment 4916

I hope it will help you..!
Nice explanation Sachin.
Could you please demonstrate a small example, how to use python(.py files) in Blue Prism

Thanks
 

Sachin_Kharmale

Active Member
Hi Madhu,

Refer Following Steps to use .py file in blue prism.


1. Create simple python prog like print "hello Good morning All...!" as a output and save prog on your local drive.
Python:
print("Hello Good Morning All..!")
2. Design Flow in object Studio like bellow take on code stage and provide python executable file path and Script that we have written file path as input.
View attachment 1576045090523.png

3. write bellow C# code in Blue Prism code stage.
C#:
String result="sa";
string ErrorMsg="";
bool isError=true;
try{
ProcessStartInfo start = new ProcessStartInfo();
 start.FileName = Python_Executable_File_Path;//cmd is full path to python.exe
 start.Arguments = Script_Path;
 
 start.UseShellExecute = false;
 start.RedirectStandardOutput = true;
 using(Process process = Process.Start(start))
 {
     using(StreamReader reader = process.StandardOutput)
     {
          result = reader.ReadToEnd();
        
     }
 }
  } catch (Exception exp) {
    ErrorMsg=exp.Message;
    isError=false;
}
Exception=ErrorMsg;
Success=isError;
            
ScriptOutput=result;
View attachment 1576045128918.png
4. Now execute the flow it will call python code from blue prism and get the output in blue prism data item.
View attachment 1576045185888.png
I hope it will help you..!


 

MadhuG001

Member
Hi Madhu,

Refer Following Steps to use .py file in blue prism.

1. Create simple python prog like print "hello Good morning All...!" as a output and save prog on your local drive.
Python:
print("Hello Good Morning All..!")
2. Design Flow in object Studio like bellow take on code stage and provide python executable file path and Script that we have written file path as input.
View attachment 4949
3. write bellow C# code in Blue Prism code stage.

C#:
String result="sa";
string ErrorMsg="";
bool isError=true;
try{
ProcessStartInfo start = new ProcessStartInfo();
start.FileName = Python_Executable_File_Path;//cmd is full path to python.exe
start.Arguments = Script_Path;

start.UseShellExecute = false;
start.RedirectStandardOutput = true;
using(Process process = Process.Start(start))
{
     using(StreamReader reader = process.StandardOutput)
     {
          result = reader.ReadToEnd();
    
     }
}
  } catch (Exception exp) {
    ErrorMsg=exp.Message;
    isError=false;
}
Exception=ErrorMsg;
Success=isError;
        
ScriptOutput=result;
View attachment 4950
4. Now execute the flow it will call python code from blue prism and get the output in blue prism data item.
View attachment 4951
I hope it will help you..!
Thanks Sachin for such a clear explanation.
I am actually getting some errors in Code Stage. So is there any "EXTERNAL REFERENCES" or "NAMESPACE IMPORTS" need to use under "CODE OPTION" in the "INITIALISE " page ?

Please find below screenshots.
In Code Stage, I have added only one more step using System.Diagnostics;

Thanks again.
 

Attachments

  • Main Page.PNG
    22.4 KB · Views: 155
  • Input.PNG
    9 KB · Views: 140
  • Output.PNG
    8.3 KB · Views: 123
  • Code Stage.PNG
    28 KB · Views: 131
  • Errors.PNG
    17.4 KB · Views: 109
Last edited:

MadhuG001

Member
Hey Madhu,

Remove using System.Dignostics; namespace from your code stage and put it in your initialization stage like bellow .
View attachment 4971

I hope it will help you,,!
Hi Sachin,
Sorry to bother you again.
I have removed System.Dignostics from the code stage & put it under Initialize page, but it's still reflecting two error.
Please find the attachment.


Thanks
 

Attachments

  • Error.PNG
    10.1 KB · Views: 94

Sachin_Kharmale

Active Member
Hey Madhu,

For first Error can not implicit type convert bool to string.
Declare Success as Flag may be you have declared success as Text data item.


For Second error include System.IO or System.IO.StreamReader in you init


I hope it will help you.

 

MadhuG001

Member
Hey Madhu,

For first Error can not implicit type convert bool to string.
Declare Success as Flag may be you have declared success as Text data item.



For Second error include System.IO or System.IO.StreamReader in you init

I hope it will help you.
Thank you so much Sachin for rectifying.
One error got removed.
For the second error I have included System.IO into Initialize page, but it's still reflecting the attached error.

Please check & advise.
 

Attachments

  • Error In Initialise.PNG
    10 KB · Views: 68
  • Initialise Page.PNG
    13.6 KB · Views: 63

MadhuG001

Member
Hey madhu,

You have followed correct steps just remove System.IO Namespace from External References section and put in Namespaces Import Section.
Refer bellow screen shot to import namespaces.
View attachment 4978

I hope it will help you..!
Thank you so much Sachin. It's working fine now.
Is there any option to keep that console window stable, because it immediate disappears after reflecting result.
 

Sachin_Kharmale

Active Member
Yes madhu we can stable output window with the help of
process.WaitForExit(); method try it may be it will work for you.
otherwise we are getting the output of the script in blue prism data item.


I hope it will help you ..!
 

Sourabh Rai

New Member
Can't we just call a python script using start process action from Utility environment by providing the application and argument name as input to this action ?

fDrG9pMyStGGkSmnEPLo_temp.png


Thanks,
Sourabh
 

sambrao

New Member
Hi Sachin

Thanks a lot for your steps that how to integrate the python in blue prism code stage. i need some help. could you please help on that.
After executing the action i could see only the print function in the blue prism output data item. i can not see any file creation which is actually created by python script.



Below is the sample python code.

print('started')
import pandas as pd
print('Inprogress')
df = pd.DataFrame({'name': ['Raphael', 'Donatello'],
'mask': ['red', 'purple'],
'weapon': ['sai', 'bo staff']})
df.to_csv(r'C:\Users\914174\output.csv',index=False)
print('completed')


Finally i could identify no statement is working after import pansads statement. Can you pls help on that.
 
Top