For setup you can follow this article or our video guide below:
Prerequisites:
- Python 3.7 or newer. You can get it from https://installpython3.com/.
- BotStudio. You can get it from
- https://botcity.atlassian.net/wiki/spaces/CBG/pages/1609138246/BotStudio.
Step 1 – Verifying prerequisites
Let’s begin by making sure Python is properly installed on your computer. To do that, open the command-line interface and type “python –version”, then “python -m pip –version”.
Step 2 – Use CookieCutter to start a new project
CookieCutter is a Python command-line utility that allows you to create a project from a project template. To install it, run the command “python -m pip install –upgrade cookiecutter” on your command line interface.
Then, use this command to start a project from the BotCity Python template: “python -m cookiecutter https://github.com/botcity-dev/bot-python-template”.
You’ll be prompted for the following information:
project_type: Pick “Web” if your automation only involves websites. Otherwise, or if unsure, pick “Desktop”.
bot_id: This will be the name of your Python module. If you’re using the BotMaestro integration, then it must match the bot label configured on BotMaestro.
project_name: This is the name of the project. You can pick any name you would like.
project_short_description: This is a short description of the bot.
Step 3- Project Structure
The root folder of your project receives the name defined in the project_name above. It contains a Python module with the source code files named after the bot_id variable. Also, the Resource Folder is inside the same folder as the source code.
Project Folder (firstBot)
MANIFEST.in: This file defines additional content for the package such as images.
README.md: Simple README file for your bot project.
VERSION: This file defines the Bot package version.
firstBot: Main module for your Bot package.
build.bat: Batch script to generate the package
build.sh: Shell script to generate the package
requirements.txt: File describing the python dependencies for your Bot.
setup.py: Setup file for the package.
version: File stating the current bot version
Main Module of the Package (firstBot)
__init__.py: This is usually a blank file
__main__.py: Entrypoint for the module. You don’t need to bother with this file.
bot.py: Module for your bot code. Here is where you will develop your bot.
resources: Folder containing resources useful for the Bot.
Step 4 – Run the template bot
Let’s perform a quick test to make sure your bot is running correctly. First let’s install the bot package and its dependencies with “python -m pip install -e .”. This command must be executed with the dot at the end if your command-line is positioned in your project folder. Otherwise, you must provide a path to it.
After that, we can proceed to test the bot. Open your command-line interface and insert “python -m bot_id” (replace bot_id with the ID you chose on step 2):
The bot should open the botcity.dev page on your default browser. Alternatively, you could run the bot inside your favorite IDE.
Step 5 – BotStudio Setup
Open the BotStudio and log in using your account.
Then, go to File -> New Project:
And fill the Dialog box with the following information:
Project Name: You may choose any name you prefer.
Project Folder: The root folder of your project.
Source Code: The folder containing the code files you want to edit.
Resources Folder: The Resources Folder, which is usually inside your
Then hit the create button.
Step 6 – Using BotStudio
To make a quick demonstration of how BotStudio works, we’ll begin by selecting the bot.py file in the BotStudio, and clicking at the line we want it to insert code into.
In this example, we’ll use google.com to redirect us to BotCity’s youtube channel using the “I’m Feeling Lucky” button. So let’s do some code clean up first. It’s not a complex modification, so we can do it within BotStudio itself.
This is an overview of the process of generating a click using BotStudio:
1.In the Code tab, click where you want to insert the code.
2. In your application, hit the Print Screen button on your keyboard or F9 if you are using MacOS.
3. Now, you’ll perform 4 clicks:
a. Click at the target area to zoom.
b. Click at the upper left corner of the target area.
c. Click at the lower right corner of the target area.
d. Click at the upper left corner of the target area one more time.
4. Name your new selection and set the Action menu to “click”.
5. Hit the Submit button.
BotStudio will generate both the image and the code for you. The results should be similar to the picture below.
There is one last thing to do, which is to paste our search string (botcity youtube channel) before clicking find. We may also clean up the code a little bit.
By adding the paste method after the find, we ensure it will wait for the page to be loaded.
Step 7 – Final Test
By repeating Step 4, you should obtain the following result:
Youtube