BeginnerLesson 1 of 306 min read

What Automation Is: Triggers, Conditions and Actions

Learn the three building blocks of every automation by running a tiny rule engine on seven sample emails, and see why the unmatched ones matter.

In this lesson you will

  • Name a trigger, a condition and an action
  • Read a simple rule engine line by line
  • Spot rules that overlap or match nothing
  • Choose a sensible first task to automate

About 20 minutes

Ravi types the same reply forty times a week

Ravi runs a small print shop. Every morning his inbox holds the same kinds of message: someone wants a price for flyers, someone asks where an order is, a supplier sends an invoice, and now and then a stranger offers a prize. Ravi opens each one, decides what it is, moves it to a folder and often types a near-identical reply. None of it is hard, and all of it eats the first hour of his day. This is exactly the kind of work automation is for. In this lesson you will see what automation really is, using a tiny model you can read line by line, so that later, when you use a no-code tool, you know what is happening under the buttons.

Triggers and actions

Every automation, however fancy, is built from two ideas. A trigger is the event that starts it: an email arrives, a form is filled in, a clock reaches nine o’clock. An action is what the automation then does: add a label, copy a row into a sheet, send a message. Between them sits a condition, a test that decides whether the action should run for this particular event. Put together they read like a sentence: when an email arrives, if the subject mentions an invoice, then label it billing.

That sentence is called a rule. A set of rules, checked in order, is a rule engine. Do not let the grand name worry you: it is a loop that asks each rule in turn, ‘does this one apply?’

A rule engine you can read

The program below holds seven made-up emails and four rules for Ravi’s shop. For each email it asks every rule whether it applies and collects the names of the rules that said yes. If at least one rule applies, the first one wins and the email is counted under that rule. The lambda lines are just tiny tests, each returning yes or no for one email. The numbers at the end are labelled made up, because the time saved depends entirely on your own inbox.

# MADE-UP inbox for Ravi's print shop: (id, subject, first line)
emails = [
    ("e1", "Quote for 200 flyers", "Hi, how much for 200 flyers?"),
    ("e2", "Invoice 118 overdue", "Please see the invoice attached"),
    ("e3", "Where is my order?", "I ordered cards last week"),
    ("e4", "You won a prize", "Click here to claim"),
    ("e5", "Banner size", "Need a price for a banner"),
    ("e6", "Thanks", "The cards look great"),
    ("e7", "Quote and invoice copy", "Can I have a quote and the invoice copy?"),
]
# each rule: (name, test on the email, action text)
rules = [
    ("sales", lambda e: "quote" in e[1].lower() or "price" in e[2].lower(), "label sales, tell Ravi"),
    ("billing", lambda e: "invoice" in e[1].lower(), "label billing, add to the money list"),
    ("support", lambda e: "order" in e[1].lower(), "label support, send the order check"),
    ("junk", lambda e: "prize" in e[1].lower() or "click here" in e[2].lower(), "move to junk"),
]
done, unmatched, multi = {}, [], 0
for e in emails:
    hits = [r[0] for r in rules if r[1](e)]
    if len(hits) > 1:
        multi += 1
    if hits:
        done[hits[0]] = done.get(hits[0], 0) + 1
    else:
        unmatched.append(e[0])
for name, count in sorted(done.items()):
    print(f"rule {name}: {count}")
print("unmatched:", unmatched)
print("sorted by rules:", sum(done.values()), "of", len(emails))
print("matched more than one rule:", multi, "(first rule wins)")
per_day, seconds = 20, 30
print("minutes a month saved (made up):", per_day * 22 * seconds // 60)
rule billing: 1
rule junk: 1
rule sales: 3
rule support: 1
unmatched: ['e6']
sorted by rules: 6 of 7
matched more than one rule: 1 (first rule wins)
minutes a month saved (made up): 220

Six of the seven emails were handled: 3 went to sales, 1 to billing, 1 to support and 1 to junk, which gives 6 of 7. One email, e6, matched nothing. It was a customer saying thank you, and no rule knew what to do with it. That is normal and healthy: an automation should have a plan for the things it does not understand, and in later lessons that plan will be ‘ask a person’. Look also at the line about 1 email matching more than one rule. Email e7 asked for a quote and an invoice copy, so both the sales rule and the billing rule applied. Because the first rule wins, it went to sales, and the billing question may be missed. Automations do exactly what you wrote, not what you meant, so overlaps like this are worth hunting for.

What the time saving really looks like

The last line shows a sample sum. If the shop gets 20 emails a day, there are 22 working days in a month and each email costs 30 seconds to sort by hand, the saving is 220 minutes a month, a little over three and a half hours. Those numbers are invented. The method is what matters: count how often the task happens, time it once, and multiply. Be honest about what is left over, too. Building and checking the automation takes time, and someone must still look after it when it breaks, so the true saving is smaller than the headline figure.

What makes a good first automation

  • It happens often, so small savings add up.
  • It follows clear rules that you could write on a card.
  • A mistake is cheap to fix, such as a wrong label.
  • The inputs look much the same each time.
  • You can check the result quickly with your own eyes.

Notice what is missing from that list: anything that needs taste, empathy or a hard judgement. Those jobs stay with people. Sorting an inbox is a perfect start. Deciding whether to refund an angry customer is not.

Common mistake: automating the outgoing step first

Switching on an automation that sends messages to customers before you have watched it label a week of mail. Start by only labelling and drafting, and let a person press send until you trust the results.

Made-up sample data

The emails, rules and time figures are made up for teaching. The code is a teaching model of a rule engine, not a particular product, and real tools differ in how they are set up. You do not need to write code to use automation tools.

Write down three emails or messages you handle every week. For each, finish the sentence: when this arrives, if it contains this, then I do that. You have just drafted your first three rules.

Practice for this lesson

Check what you learned

Five quick questions. Pick an answer and you will see straight away whether it is right and why.

What is a trigger?

  1. The last step of a workflow
  2. The event that starts an automation
  3. A password
  4. A kind of report

Triggers are events such as an email arriving or a form being filled in.

What does a condition do?

  1. Stores the data
  2. Sends the email
  3. Deletes the rule
  4. Decides whether an action should run for this event

The condition is the test between trigger and action.

Why did email e7 go to sales and not billing?

  1. Two rules matched and the first rule wins
  2. Billing was switched off
  3. The email was junk
  4. It had no subject

The program counted each email under the first rule that applied.

What should an automation do with an email no rule understands?

  1. Delete it
  2. Guess a label
  3. Hand it to a person
  4. Reply to it

A plan for unknown cases, usually a human, keeps mistakes small.

Which task suits a first automation best?

  1. Deciding a refund for an angry customer
  2. Choosing a new logo
  3. Negotiating a contract
  4. Sorting incoming mail by clear rules

It is frequent, rule-based and cheap to correct.

Summary

  • A trigger starts an automation, a condition decides, an action does the work.
  • A rule engine asks each rule in order whether it applies.
  • Overlapping rules and unmatched cases need a plan.
  • Start with frequent, clear, low-risk tasks.

Next lesson

Lesson 2 shows how to map a whole process on paper before you automate any of it.

Questions

Do I need to code to automate things?

No. Most automation tools let you build with forms and buttons. The code in these lessons is a see-through model so that you understand what the buttons do.

Is a rule engine the same as artificial intelligence?

No. A rule engine follows rules you wrote and nothing else. AI steps, which come later in this course, can handle fuzzier cases but need extra care.

Are the time savings real?

They are made-up sample figures. Measure your own task before you decide whether automating it is worth the effort.

Progress is saved in this browser.