aisingapore / TagUI

Free RPA tool by AI Singapore
Apache License 2.0
5.63k stars 583 forks source link

Using TagUI inside JS code for NodeJS - use child_process or build integration #951

Closed ghost closed 3 years ago

ghost commented 3 years ago

I have been following https://github.com/tebelorg/RPA-Python this repo for a while and there are wrapper functions for using the tool inside python code. But in here (it's clearly mentioned it's a CLI tool) is there any predefined way to access tagui functionality within my JavaScript code.

kensoh commented 3 years ago

Hi @asishRye what you said is correct. RPA for Python is a wrapper for TagUI that lets Python users use TagUI RPA features.

However, I'm afraid that there isn't a NodeJS package equivalent that lets JavaScript users use TagUI like a NPM package.

Can you tell me more in what situation are you writing code in JavaScript, is it part of a NodeJS app or some other situation?

ghost commented 3 years ago

Hi @kensoh, thanks for clearing that. Yes I am writing code in JavaScript, it is part of NodeJS and Electron framework. I really feel the need for a JS wrapper, granted it's a CLI tool. Maybe you can help me to create one?

kensoh commented 3 years ago

I see.. If you need real-time step by step control, then you need a wrapper. There is no plans to create a NodeJS wrapper now for TagUI, but you can try to write a port for NodeJS version from this RPA for Python 1-file package - https://github.com/tebelorg/RPA-Python/blob/master/tagui.py

However, in most cases, you don't need real-time step by step control. What you can do is generate a .tag file programmatically from NodeJS program. Then you run that .tag file from NodeJS using child_process and retrieve the output back.

https://stackoverflow.com/questions/12941083/execute-and-get-the-output-of-a-shell-command-in-node-js

In fact, one user from India generated a TagUI file from NodeJS program and calls it to automatically fill up his timesheet. But I can't find the example now, last time GitHub will show repos that are using this repo but it seems that this feature is no longer available.

However, if you mean running as a web app and automating actions on the user local computer, then this isn't directly doable because a web app cannot have access to the local computer programs and run them. If it is a packaged app to be run locally then it is possible to packaged TagUI together and unzip and run.

kensoh commented 3 years ago

Adding on, can you tell us more about the app you are creating? So we can see what is the best way for TagUI to fit in.

kensoh commented 3 years ago

I forgot to add. If fine-tune step by step control is needed, you might be able to find success quickly by using something like below for NodeJS which can run Python, and then use RPA for Python.

https://github.com/extrabacon/python-shell

ghost commented 3 years ago

Hi Kensoh, we are trying to develop an open source GUI based RPA tool on top of TagUI. Running TagUI flow file as child process was the first thin that came to my mind thanks for reinforcing that. The python link you have provided seems useful. Will try that too. I also want to write a wrapper function for TagUI.js. If I may ask is the TagUI Python = TagUI.js + wrapper function?. Thanks again for the help.

kensoh commented 3 years ago

Oh I see.. Depending on the scope of what you are building, using child process may be enough.

Only when you need fine control for eg debugging or stepping through code line by line, then you need a direct connection to control TagUI in its live mode. See below for the architecture for RPA for Python. It works by running TagUI in live mode and then sending data and receiving data back in live mode -

https://github.com/tebelorg/RPA-Python#about--credits

This is the Python wrapper file. There is no such thing as a wrapper function. I wrote many many functions to wrap TagUI steps into Python functions. So if you are building something more, need to map all TagUI steps into JavaScript functions in NodeJS. By copying below code to do something similar in NodeJS you can do it very quickly -

https://github.com/tebelorg/RPA-Python/blob/master/tagui.py

PS - it shows 1.6k lines, but after moving empty lines and comments should be only lower range of 1k+ lines of code.