🔀Using Variables
Last updated
Last updated
Variables are for saving or updating data that you temporarily need during your TaskBot run.
Since Variables don't adhere to any appending or looping logic, it's a powerful, robust and flexible way to save or update any data that you temporarily need in order to advance in your workflow without having to worry about loop set-up.
To understand the differences between tables and variables, let's go over an example.
Imagine you want to send an automated DM to a list of profiles. However, you want to limit the number of profiles that you reach out to per day or per run. Let's say, you want your TaskBot to never send more than 30 DMs per run.
Step 1: Initial table set-up
Let's assume your list of profiles is stored in the table called "Profile links", as shown below. (See How to Add Tables).
Step 2: Initial TaskBot set-up
To start sending DMs, you would build a TaskBot that first opens the website where DMs can be sent, then loops through the rows in your table, inserts text into DM input and clicks on "Send" button.
The TaskBot set-up would look like this:
Here is the set-up of the Start Repeat building block (see Start Repeat).
Step 3: Creating a variable
Now, let's add the limit.
To ensure that TaskBot doesn't send more than 30 DMs, we need a counter which should increment by 1 each time TaskBot sends a DM. This is a great example where you need a variable. A table would not be an appropriate choice for this use case because we don't need 30 rows with a counter number (as in 1, 2, 3, 4, 5, etc.), instead we need a single value that dynamically increments during the TaskBot run.
First, we need to create a variable, as shown below.
Let's call the new variable "DM counter". You can leave the variable value empty or you can enter "0" (as the count should start with 0).
Step 4: Updating the counter during TaskBot run
Let's now add the logic to update the variable during the TaskBot run. To update "DM counter", use the building block Update Data.
This is the set-up of Update Data building block that adds 1 in every loop iteration (and every loop iteration sends a DM):
Step 5: Setting up a condition to check the counter
The last piece that is missing is a condition that checks if the counter is less than 30. This is how to add that:
Conditions are set using Start Condition and Set Condition building blocks (see Start Condition and Set Condition). Here is the set-up of the Set Condition: