5 Unique ways to trigger your UiPath Bots.

Ishmeet Bindra
5 min readSep 14, 2020

--

In college when I was doing my major in Electronics and Communications, I was introduced to the concepts of Polling and Interrupts. These concepts are also fairly common in Computer Science but I like to stick with their electronic definition -

Polling — It is a process of allowing a microcontroller (a device) to continuously check for a condition or a state of an external device (another microcontroller, database, etc). As soon as the state changes, our controller starts doing its job, and once the job is done it comes back to the checking or Polling stage.

Interrupts- It is a process of asking our microcontroller to wait till an external signal (an Interrupt) arrives. As soon as an Interrupt signal is detected, we start our processing.

When we are planning to create a bot that is only required when certain conditions are true, it is always better to follow the Interrupts path so that the bot does not run all the time and our machine is free for other tasks/processes as well.

In this article, we are going to focus on how to trigger the bot based on conditions. We are going to discuss how can we program in such a way that we can eliminate the need for polling and still achieve the task.

1. Triggering Bot via CMD

Following is the syntax of triggering bot with the help of CMD.

"Path_to_UiRobot.exe" execute -p Orchestrator_Process_Name

Above would help you triggering your bot with the help of the command-line which is a great thing as almost all programming languages and tools can interact with the command line in one form or another and if provided enough access, can trigger the same bot conditionally (example shown later).

Triggering BOT using UiRobot.exe

You can refer to UiPath Docs for more information on this.

2. Triggering Bot via Outlook

We can trigger a bot with Outlook with the help of a VBA script. The bot should be triggered upon the arrival of an email, so we are going to create a rule that would allow us to execute the script automatically as soon as a specific mail arrives.

To create a script in Outlook press Alt + F11 to load the VBA Editor. Create a module if there is none already existing and paste the following script in there.

VBA Script to trigger the Bot

If you are not able to load the developer mode then navigate to File -> Options -> Trust Center -> Trust Center Settings -> Macro Settings within outlook and select Enable all Macros there.

Create a rule to run the script every time a specific mail arrives. In case this option is missing for you then it can be activated like this -https://www.slipstick.com/outlook/rules/outlook-run-a-script-rules/

Setting up a rule in Outlook

Now every time a mail arrives with a specific subject, the bot will be triggered.

Bot Triggering when Email arrives

3. Triggering Bot via Python

Triggering the bot via python script follows the same logic of triggering bot via CMD. We invoke the same CMD command via python but here we get the advantage of creating an advanced script that could track if a job is running already or not and we can also add a retriggering/scheduling mechanism in the same script.

Code to Trigger the bot.
Triggering bot via python.

In the above example, we are first checking if the bot is already running a job or not. If the bot is already running then we don’t execute another job. We wait for the existing job to be completed and then start a new one.

4. Creating an Application to run the bot.

Using the pyinstaller module we can convert the above program into an executable that can be shared for easier execution. Following is the syntax of converting a python file into an executable file.

pyinstaller --onefile script_name.py
Generating Executable file using Pyinstaller

Once the command is completed, the executable is placed in the ‘dist’ folder.

5. Scheduling bot to run on startup.

Windows has a very powerful task scheduler that can be utilized for scheduling and running the bot. We can program it to trigger a bot as soon as our machine boots up. There is a great forum article I found which is available here. It discusses everything related to task scheduling step by step but here is the gist of it -

a. Create a batch file with the command that we discussed in the earlier portion of this article.

Batch File

b. Open Task Scheduler and provide the path of this file in the action tab and set the trigger as any one of the following. From here select the ‘At Startup’ option.

Available triggers in Task Scheduler.

c. Save it and Done!.

These are just a few ways of triggering a bot without defining explicit conditions for the same in Orchestrator. If you have some unique way of triggering the bot, post that in the comments!

🤖

--

--

Ishmeet Bindra
Ishmeet Bindra

Written by Ishmeet Bindra

Developer with keen interest in everything tech!

Responses (1)