Skip to content
ProductKlef Team

Notifications Should Reach the Person Who Can Act

Photo by Kristina Tripkovic on Unsplash

A common issue in IT is notifying the right person. A lot of automated processes are configured to send notifications to a shared channel (e.g. a Slack channel). That can be helpful to distribute the workload across a team, but that team often just mutes the channel.

The trouble here isn't the volume. It's that most of these notifications aren't addressed to anyone in particular, so no one feels compelled to address them.

Your notifications need to be addressed to someone specific if you want actionable notifications.

Who Needs to Know

When a worker's accounts change, the people who care about it differ depending on what was changed:

  • A manager wants to know their new hire can sign in on day one, or that someone on their team is leaving.
  • IT wants a daily report of who joined and a ticket indicating what SOP they should follow.
  • A worker wants to know where to sign in.

A single channel serves none of these well. Each one needs a tailored message, to a personal inbox, at the moment it's relevant to them.

Notifications Belong to a Stage

In Klef, a notify block is used inside a worker lifecycle stage. And it's sent only when that stage applies. That coupling guarantees the message describes what's actually happening to the worker, or what that worker needs at that point in time.

policy "Engineering access" {
  category = "Engineering"
  applies  = segment.engineering

  stage pre_start {
    notify email {
      subject = "{{ worker.display_name }} is set up"
      body    = "Their accounts are ready. They can sign in on {{ worker.start_date }}."
      to      = [subject, manager(1)]
    }
  }

  stage active {
    notify slack {
      title       = "New engineers"
      aggregation = per_run
      text        = <<TEXT
        {% for worker in workers %}
        {{ worker.display_name }} joins as {{ worker.job.name }}.
        {% endfor %}
      TEXT
      webhook     = secret.engineering_channel
    }
  }

  stage terminated {
    notify http {
      title  = "Leaver"
      method = post
      uri    = "https://desk.example.com/api/tickets"
      body   = <<JSON
        { "summary": "Collect equipment from {{ worker.display_name }}" }
      JSON

      header "Authorization" = secret.desk_token
    }
  }
}

Here, we have three notifications being sent out through a worker's lifecycle:

  1. Before the worker starts their job, an email to their manager and themselves is sent letting them know their start date.
  2. Once the worker has started, an aggregate Slack message is sent to an engineering channel.
  3. After that worker is terminated, a ticket is sent telling IT to collect the worker's equipment.

Sent by Engineering access

Hana Cole is set upTo Hana Cole and Marcus Lee
Pre-start

Their accounts are ready. They can sign in on March 2.

New engineers#engineering
Active

Hana Cole joins as Platform Engineer.

Omar Haddad joins as Site Reliability Engineer.

Priya Raman joins as Data Engineer.

LeaverPOST desk.example.com/api/tickets
Terminated
{ "summary": "Collect equipment from Nia Bennett" }