Automation Workshop can easily automate everyday tasks which we can not readily imagine. How about turning text files into automatic email reminders? With Automation Workshop it takes only a few steps to bring life into your data.
For example, a legacy database automatically exports user subscription information on a weekly basis. The user subscription data is exported in the
C:\Input\Files folder to a text file, whose name starts with dump followed by the export date. Each line of the exported file contains a person's name, email address and remaining subscription days, separated by tab character.
We will email subscription reminders to the users whose membership expiration date is due within a month. This tutorial explains in detail how to setup these steps.
We will set up the File & Folder Watcher trigger to monitor a folder where the file with user subscription data is exported, in anticipation for a weekly dump file.
- A For each loop which will process one line of the exported file at a time.
- The Split text Action to retrieve tab-separated elements (user name, e-mail, and remaining days on subscription) from every line.
- The If conditional to check the remaining days for each user and, if less than 30, proceed with Send email Action to send a reminder about subscription.
First, let's setup a File & Folder Watcher trigger to monitor
C:\Input\Files folder for new files whose name begins with dump. Set folder path, and type
dump*.txt in Include mask field, so that no other files will trigger this Task · Learn file mask usage
Task & Actions
After the File & Folder Watcher trigger is set to monitor for files with subscription data, let's setup the Actions for the Task.
Notice the indent for the Split Text and If actions relative to the For Each action. That means that in every step of For Each loop, i.e., every time the For Each action retrieves a line from text file, indented Actions are performed as well. For Each loop will run as many steps as necessary to process every line in text file.
Likewise, the indentation of Send Email action (relative to If action) indicates that it is subordinate to condition specified in If action, rather than performed independently. Only when the condition in If action is met (i.e., the number of remaining subscription days for a particular user is less than 30), the email reminder will be sent.
Now, let's use For Each loop to process file contents line by line. Set the For Each action to separate File content (using Variable Wizard & Read from file variable) into lines by using Line break separator.
In For Each options specify to ignore empty lines and lines starting with
# character (in this example, the header row).
Split & tokenize values
Now let's configure Split text Action to get the current item (in our case—the line) in every step of For Each loop (using Variable Wizard & For each variable). Set the tab separator character that delimits data columns in the text file.
To design clearer Task, let's assign custom token names to each element, so that the first text element in the line is denoted user, the second—email address and the third—remaining subscription days. These custom names will now be available in Variable Wizard (otherwise, the Variable Wizard will return generic names like Token 1, Token 2 and so on).
From now on the new variables will be available via Variable Wizard & Split text variables. User variable is assigned to the text in first column, Email to the second column, and Days to the third column.
When the lines are separated into tokens, we will check each entry for remaining days of subscription. Let's compare if the Days variable is less than 30.
Finally, let's add subordinate Send email Action which will notify user of subscription expiration. Note how custom variables are elegantly merged in the email's TO, Subject, and Email text fields.
The tutorial shows how to turn simple text file report into automatic e-mail reminders. The Task monitors for reports, processes them line by line while separating text strings into structured elements of data, analyses the remaining subscription and sends a reminder email, if need one.
If you have any questions, please do not hesitate to contact our support team.