Javascript "Hello Web Bot"¶
This tutorial will guide you through the process of creating a simple Javascript web automation.
Prerequisites¶
- BotCity Account
- BotCity Studio SDK
- Node 16
Downloading the WebDriver¶
To be able to work with web automations, we need to use the corresponding WebDriver to communicate with browsers for automation.
In doing so, it requires that the WebDriver for the chosen browser to be installed and available preferrably
in your PATH
. If you can't add the necessary WebDriver to your PATH
you will be able to inform the driver path
via code in your bot.
Here is a list of supported browsers along with links for you to download the proper WebDriver:
Browser | WebDriver Download |
---|---|
Chrome | ChromeDriver |
Firefox | GeckoDriver |
Edge | MSDriverEdge |
IE | IEDriverServer |
Please follow the instructions on the WebDriver website for installation and setup.
Once the desired WebDriver for the Web Browser to be used is installed we can proceed to the next steps.
Orchestration of packages using browsers¶
It is possible to orchestrate any framework that uses browsers, examples:
Name | Link |
---|---|
Selenium | Selenium |
Playwright | Playwright |
Puppeteer | Puppeteer |
There are more than these, most can in fact be orchestrated by Botcity.
Creating Your First Project¶
BotCity offers a template project which can be customized via a tool called js-template-cli.
Installing js-template-cli¶
In order to use it we need first to install the js-template-cli javascript package by running the following command on your command-line terminal:
npm install @botcity/js-template-cli
After doing that you are ready to create your first Javascript automation using BotCity’s framework.
From Template to Project¶
The system will prompt you with a couple of answers in order to properly create your project.
- Once prompted is visual automation answer with n and press enter;
- Please choose which project template to use, select javascript.
- Once prompted installing package answer with Yes and press enter;
- Under bot id type
Hello Bot
and press enter; - Under project name type
Hello Bot
and press enter; - For project short description type
My first project with BotCity
and press enter.
Exploring the Project¶
Under your project folder HelloWebBot
you will have the following structure:
HelloWebBot
├── README.md <- Simple README file for your bot project.
├── bot.js <- Here is where you will develop your bot code.
└── package.json <- File describing the Javascript dependencies for your Bot.
Note
It may seem like a lot of files and folders but here are the most important ones:
- bot.js: Change this file and add here the code for your bot.
Great!
All this information is great but it is time to see some action.
Let’s test this shiny new Bot locally. 🦾🤖
Testing Your Project Locally¶
In order to test our project locally, let’s first install it so we can have all the Javascript dependencies ready.
Using the command-line tool, access the HelloWebBot
folder which we described above.
Installing¶
Install the Javascript package by running the following command on your command-line terminal:
npm install
Running the Bot¶
Our template project runs a very simple automation. It opens up your default web browser and loads BotCity’s website.
You can execute your HelloWebBot
with the following command:
🌟 Excellent 🌟
You are now ready to start creating automations using the BotCity’s Javascript Framework.
Conclusion¶
Under this tutorial you learned:
-
The dependencies required to develop automations using BotCity’s Javascript framework and how to get them installed.
-
How to create new Bot projects using js-template-cli and BotCity’s template.
-
How to install and run your new Bot project locally.
Have fun automating 🤖