Skip to content

frenchautomationorg/french-automation-robot

Repository files navigation

French Automation Robot

RPA Open Source French Automation

Overview

French Automation is an Open Source RPA / RDA software suite based on :

  • Newmips NodeJS development Studio : https://www.newmips.com/
  • A web-based application called Orchestrator that manages Business activities and dispatches automated tasks between connected Robots
  • An ElectronJS Robot that executes tasks on user desktop or remotely

More details can be found on the official website : https://www.frenchautomation.com/


Screenshot


Installation

Please refer to installation instructions and prerequisites on our Website : https://www.frenchautomation.com/default/robot

Clone repository :

git clone git@github.com:frenchautomationorg/french-automation-robot.git

Install modules and run application logged as "root" :

sudo npm install -g electron --unsafe-perm=true --allow-root
sudo npm i
sudo npm i electron-rebuild --save
sudo ./node_modules/.bin/electron-rebuild


Once installed, simply execute:
electron .

Usage

French Automation depends on a newmips application, follow the tutorial to know the prerequisites and how to initialize a configured application : https://www.frenchautomation.com/default/tutorial
We're going to see how it works and how to build a program file for your newmips Task.

Fetch Task

Once the robot is started and running, it will query the API every 5 secondes and check for pending tasks assigned to this robot :

GET '[HOST]/api/task?fk_id_robot_robot=[ROBOT_ID]&fk_id_status_state=[PENDING_ID]&include=r_state&limit=1'

[HOST], [ROBOT_ID] and [PENDING_ID] are defined using configuration page.

It will download and unzip the task's program files.

Task configuration

Task's zip file is expected to have a config.json file for the Task to run.

{
  "steps": [
      ....
    ],
    "onError": ...
}

config.json must be placed at zip's root directory

program.zip/
 - config.json
 - sessionScripts/
   - login.js
   - logout.js
 - fetchData.js

steps

JSON configuration must provide a steps array containing each steps of this Task. The order of the array will define order of execution.


Each of the following step properties are optionnal and will be executed in the following order if found :
  • startWith
  • Providing a startWith object will start the execution of the step by loading the provided url :
    {
      "url": "https://target-website/login",
        "method": "GET"
    }
    
  • snippet
  • A path to a javascript file to execute on the currently loaded page. Root dir is the unzipped Task's program file
    Depending on the step's `type` value, it is executed as javascript on the frontend or nodejs on backend
    "snippet": "script/fill_and_submit_login_form.js"
    

  • download
  • Triggers a download

    {
      "url": "https://target-website/download",
      "method": "get",
      "name": "stepfile.pdf"
    }
    
  • endWith
  • Providing a endWith object will wait for the provided url to end the ongoing step :
    {
      "url": "https://target-website/logout",
      "method": "POST"
    }
    

Steps require the property `type` to define the type of script it will execute. Two types are possible, 'action' and 'sequence'.
Step type 'action'

An 'action' step is a frontend script. It expects a javascript file that will be executed on the currently loaded page.
The script is expected to return a promise. This promise result will be added to the step sessionData object
Example :

  (_ => {
    return new Promise((resolve, reject) => {
      setTimeout(function() {
        resolve({inputValue: $("#data").text()});
      })
    })
  })().then(results => results);
Step type 'sequence'

A 'sequence' step is a nodejs script. Its snippet property will be executed as a nodejs module and must export a function execute(utils).

The parameter utils sent to execute(utils) contains :

{
  "window": {} // The electron `BrowserWindow` object in use
  "robotId": int // Running robot ID
  "taskId": int // Current Task id
  "env": {} // The Task's `f_data_flow` field, filled through Media Task and parsed to JSON
  "sessionData": {} // Object filled through script steps
  "api": { // Functions to use API connection
      "call": function(options) // Send a request, options should match `requestjs` requirements
      "upload": function(options) // Same as `call()` but using `options.stream` property to stream a file
      "map": function(options) // Map values according to configuration entities in orchestrator
    }
  "waitDownloads": async function() // Return a promise that resolve when all downloads are done
}

Step optional properties
timeout A timeout in milliseconds that will trigger step failure
delay A delay in milliseconds that will delay step execution
name The step name. Only used for config.json and logs readability

onError

config.json can provide onError property that will be executed if the task encounter an error. It can be useful to reset changes, logout or whatever is needed before finishing the task.

onError can be defined in 3 ways :

  • An index of a step from the steps array
  • A step object
  • An array of step objects

Contribute

We encourage you to contribute to French Automation software suite.

  • Check out the latest master to make sure the feature hasn't been implemented or the bug hasn't been fixed yet
  • Check out the issue tracker to make sure someone already hasn't requested it and/or contributed it
  • Fork the project
  • Start a feature/bugfix branch
  • Commit and push until you are happy with your contribution
  • Make sure to add tests for it. This is important so we don't break it in a future version unintentionally.
  • Please try not to mess with the branches, versions, or history. If you want to have your own version, or is otherwise necessary, that is fine, but please isolate to its own commit so we can cherry-pick around it.

See also


Licenses

French Automation is released under the GNU General Public License version 3 license.