---
title: "Invite on-call from alert group label | Grafana Cloud documentation"
description: "When someone adds a team label to an alert group, invite that team's current on-call engineer to the alert group."
---

> For a curated documentation index, see [llms.txt](/llms.txt). For the complete documentation index, see [llms-full.txt](/llms-full.txt).

# Invite on-call from alert group label

> Note
> 
> Grafana Workflows is currently in [public preview](https://grafana.com/docs/release-life-cycle/). Grafana Labs offers limited support, and breaking changes might occur prior to the feature being made generally available.

When someone adds a team label to an alert group, invite that team’s current on-call engineer to the alert group.

This Grafana Workflows blueprint is in the **Alerts** category of the Blueprints library.

## Before you begin

To use this blueprint, you need:

- Grafana IRM set up on your stack.

## Steps

Steps run in order from first to last. A step inside a switch branch runs only when Workflows chooses that branch.

Expand table

| Step                        | ID                 | Type                             | Description                                                                                                               |
|-----------------------------|--------------------|----------------------------------|---------------------------------------------------------------------------------------------------------------------------|
| Find the team’s on-call     | `get-team-on-call` | `irm.team-current-oncall`        | Looks up who is on call for the IRM team named by the label value. No changes needed.                                     |
| Invite the on-call engineer | `invite-on-call`   | `irm.invite-user-to-alert-group` | Invites the team’s first on-call user to the alert group. Critical alert groups are sent as important. No changes needed. |

For the inputs and outputs of each step type, refer to [Step and trigger types reference](https://grafana.com/docs/grafana-cloud/platform/workflows/reference/step-trigger-types).

Before you turn on the workflow, customize any steps that need input from you, such as a channel ID or a schedule name. Each step’s description says what to set.

## Workflow definition

Save this definition as a YAML file to create the workflow with gcx, the Workflows API, or Terraform, or give it to a coding agent as an example. Replace *FOLDER\_UID* with the UID of the folder for the workflow. Blueprints start disabled, so finish customizing the steps before you set `enabled` to `true`. For details, refer to [Manage workflows as code](https://grafana.com/docs/grafana-cloud/platform/workflows/as-code).

YAML ![Copy code to clipboard](https://grafana.com/media/images/icons/icon-copy-small-2.svg) Copy

```yaml
apiVersion: workflows.ext.grafana.app/v1alpha1
kind: Definition
metadata:
  name: invite-on-call-from-alert-group-label
  annotations:
    grafana.app/folder: <FOLDER_UID>
spec:
  name: Invite on-call from alert group label
  enabled: false
  startWhen:
    matchingRules:
      - eventNameRegex: 'grafana_irm_app\.alertgroup\.updated'
        filter: "inputs.data.eventKind == 'label_added' && inputs.data.label.key.name == 'team' && resources.alertgroup.event.state != 'resolved'"
    schedules: []
  steps:
    - id: get-team-on-call
      type: irm.team-current-oncall
      name: Find the team's on-call
      description: Looks up who is on call for the IRM team named by the label value. No changes needed.
      inputs:
        teamIdentifier: '${inputs.data.label.value.name}'
        identifierType: 'name'
    - id: invite-on-call
      type: irm.invite-user-to-alert-group
      name: Invite the on-call engineer
      description: Invites the team's first on-call user to the alert group. Critical alert groups are sent as important. No changes needed.
      inputs:
        userID: "${steps['get-team-on-call'].outputs.users[0].email}"
        alertGroupID: '${inputs.data.alertGroupID}'
        important: "${resources.alertgroup.event.labels.exists(l, l.key.name == 'severity' && l.value.name.matches('(?i)^critical$'))}"
```

## How it works

This section explains when the workflow runs and how its steps work together.

### When it runs

This blueprint starts on the `grafana_irm_app.alertgroup.updated` event.

Its trigger filter starts a run only when this CEL expression is true:

text ![Copy code to clipboard](https://grafana.com/media/images/icons/icon-copy-small-2.svg) Copy

```text
inputs.data.eventKind == 'label_added' && inputs.data.label.key.name == 'team' && resources.alertgroup.event.state != 'resolved'
```

### How the steps fit together

These notes cover how the steps connect and which Workflows behaviors the blueprint relies on.

- The alert group counterpart of Invite on-call from incident label.
- Triggers on `eventKind` `label_added`, which IRM sends when someone adds a label to an alert group in the UI or API (not for labels set when the alert arrives).
- The event carries the added label as `inputs.data.label`, shaped {key: {name}, value: {name}}.
- The trigger filter keeps only labels with the key team on alert groups that are not resolved.
- The label value is used as the IRM team name, so label values must match IRM team names exactly.
- `irm.page-team` can only attach a page to an incident, so this workflow looks up the team’s current on-call with `irm.team-current-oncall` and invites the first on-call user with `irm.invite-user-to-alert-group`.
- If nobody is on call, the invite step fails and the run shows as failed.
- The important flag is true when the alert group has a `severity=critical` label.
- Customize the label key in the trigger filter.

## Next steps

- [Blueprints](https://grafana.com/docs/grafana-cloud/platform/workflows/reference/blueprints)
- [Start from a blueprint](https://grafana.com/docs/grafana-cloud/platform/workflows/build/use-blueprints)
- [Manage workflows as code](https://grafana.com/docs/grafana-cloud/platform/workflows/as-code)
- [Step and trigger types reference](https://grafana.com/docs/grafana-cloud/platform/workflows/reference/step-trigger-types)
