Skip to content

Javascript "Hello Bot"

This tutorial will guide you through the process of creating a simple Javascript automation.

Prerequisites

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 y 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 HelloBot you will have the following structure:

HelloBot
├── README.md        <- Simple README file for your bot project.
├── bot.js       <- Here is where you will develop your bot code.
├── resources    <- Folder containing resources useful for the Bot.
└── 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.
  • resources: Add into this folder files to be used with your bot such as images, spreadsheets and etc.

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 HelloBot 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 HelloBot with the following command:

node bot.js

🌟 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 🤖

Next Steps

Now it is time to load your project with BotCity Studio and start creating your automations with Computer Vision and all the productivity offered by our tool.