AnyRobot
  • Overview
  • Core Concepts
  • Getting Started
  • Portal
    • Portal API
    • Admin
  • Runner
    • Runner API
    • Admin
  • Developing Robots
  • Troubleshooting
Powered by GitBook
On this page
  • Task-based scripts
  • Task-based example
  • Project-based scripts
  • Configuring project settings
  • Project-based example
  • Environment variables
  • Valid for any job
  • Additional variables for project-based jobs
  • Additional variables for file-based jobs
  • Overview

Developing Robots

PreviousAdminNextTroubleshooting

Last updated 2 years ago

Task-based scripts

Step-by-step instructions for how to create and run, "hello world" job!

We'll start by creating a test.rb file and then output a simple message there So after creating the file, paste the following code and save it

test.rb
#!/usr/bin/env ruby

puts "Hello, I'm AnyRobot! 😀"

With the file prepared this way, go to the portal and click create then workflow.

On this page, we need to enter a name such as test-workflow-rb, select the bot on which we want to perform this workflow, and in genre select file-based and upload the newly created test.rb file, the completed form should look roughly like this.

Once done, click Save and after going to the next page, click Save again and you should be taken to the newly created workflow page. From here you should be able to click the green play button which should run the uploaded script on the bot.

The test script is very short so you probably won't even notice when it has executed but you can go into AnyRobot Runner and check the activity monitor where you will notice that the script has executed.

Task-based example

Project-based scripts

To be announced...

Configuring project settings

This is a configuration file in which we can set universal tasks for all scripts from a given project.

anyrobot.yml
#Basics
anyrobot_version: 1 # Version of the configuration file.
project_language: ruby # Project language e.g. ruby, python, javascript, etc..
project_name: ProjectRPA # Project name.
project_platform: generic # Project platform, macos / windows / linux / generic
task_extension: rb # Extension of task files
tasks_folder: tasks # Folder with tasks, here the portal will look for a task

# When install (new repo on machine)
install_command: ruby install.rb # Install command on the machine
after_install: echo "Install done!" # Command after cloning (Runner executes this command)

# When update (there is new source code of project - update command is git pull)
before_update: echo "There will be update!" # What is to be executed on the bot before checking update (Runner executes this command)
after_update: echo "Updated!" # Command after the new version (Runner executes this command)

# When running a job
before_runner: echo "Runner will run!" # What we do before the runner (this command is executed by the Runner)
runner_command: bundle exec rake runner TASK=$1 # The command that fires the task, then Runner executes, e.g. bundle exec rake runner TASK=tasks/folder/demo.rb (the whole path is always used)
after_runner: echo "Runned task..." # Command after the runner

# When cleanup (cleanup conditions defined in Runner)
before_cleanup: echo "Cleanup done!" # What is to be performed on the bot before deletion (Runner executes this command)
cleanup_command: echo "Cleanup is doing now..." # Cleaning command
after_cleanup: echo "Doing cleanup..." # What is to be executed on the bot after deletion (Runner executes this command)

Project-based example

The last step is to create a new project in the portal, to do that you need to click create -> project and then enter there the name of the repository and the ssh link to that repository.

After completing these steps you should already be able to create a new workflow using the script from the project.

Environment variables

The important thing when creating robots is to know the available environment variables that can come in handy. Below is a list of available variables divided into 3 parts:

Valid for any job

  • ANYROBOT_PORTAL_URL - URL of portal which Runner uses.

  • ANYROBOT_WORKFLOW_ID - Internal (UUID) Workflow ID.

  • ANYROBOT_WORKFLOW_NAME - Name of the workflow (in orchestrator).

  • ANYROBOT_WORKFLOW_GENRE - Genre of workflow executed (valid list: “project”, “file”).

  • ANYROBOT_JOB_ID - Currently executed Job ID.

  • ANYROBOT_JOB_TRIGGER_GENRE - How Job was triggered (valid list: “manual”, “webhook”, “schedule”).

  • ANYROBOT_JOB_TRIGGER_ID - Id of job trigger (can be null if manual etc) - uuid.

  • ANYROBOT_BOT_ID - Bod id (uuid).

  • ANYROBOT_BOT_NAME - Bot name (used in orchestrator).

  • ANYROBOT_PAYLOAD_FILE - the path of the payload json file.

Additional variables for project-based jobs

  • ANYROBOT_PROJECT_ID - Id of the project.

  • ANYROBOT_PROJECT_NAME - Project name in orchestrator.

  • ANYROBOT_PROJECT_URL - Project (repo) name in orchestrator.

  • ANYROBOT_PROJECT_BRANCH - Project (branch) used by orchestrator/runner.

  • ANYROBOT_TASK_NAME - Task name used by orchestrator (example: “general/test.rb”).

Additional variables for file-based jobs

  • ANYROBOT_TASK_FILE - Path to the downloaded task file.

Overview

It can also be very helpful when creating new robots and scripts to read these documents:

  • Runner API

  • Portal API

Once you're familiar with them, you'll know the vast possibilities AnyRobot provides to help you with your automation.

I highly encourage you to check out the sample repository for a task-based solution. You can find them in this .

To check out an example of a project solution you need to fork .

Then you need to copy the portal's public key which is located in the panel under and after that, you need to add it as a deploy key in the settings of your forked repository.

You can check the more detailed documentation about creating a project .

git repository
this repository
admin
SSH-keys
here