JavaScript
This section describes how to prepare and deploy a Javascript (node)
script in the orchestrator. For the publication to be successful, two mandatory files must be present:
main.js
: main script that will be executed.package.json
: project dependencies list.
Warning
Both files must be compressed into a single .zip
file before publication.
Script Example
Folder setup
Execute the command below to create a new folder in your preferred location:
mkdir test-project
cd test-project
Create virtual environment
Execute the command below to initialize a new Node.js project:
npm init -y
Note
The package.json
file should be generated at this moment
Dependencies installation
Add Puppeteer as a dependency:
npm install puppeteer
The package.json file will have this format
{
"name": "google-automation",
"version": "1.0.0",
"description": "Simple automation that opens Google and closes the browser",
"main": "main.js",
"scripts": {
"start": "node main.js"
},
"dependencies": {
"puppeteer": "^19.0.0"
},
"author": "",
"license": "ISC"
}
Example code
Now let’s create a simple automation that opens Google and closes the browser.
// main.js
const puppeteer = require('puppeteer');
async function automation() {
// Start the browser
const browser = await puppeteer.launch({ headless: false }); // headless: false opens the browser visually
const page = await browser.newPage();
// Access Google
await page.goto('https://www.google.com');
// Wait 3 seconds
await page.setDefaultTimeout(5000); // Wait 3 seconds to view the page
// Close the browser
await browser.close();
}
automation();
Running the script
Use the command below to execute the script.
node main.js
Note
If it worked as expected, compress the files and publish them.
Compress the generated files into a .zip
file
Publication
Follow the instructions in the Publish Bot section to publish your project in .zip
format.