> ## Documentation Index
> Fetch the complete documentation index at: https://docs.anyshift.io/llms.txt
> Use this file to discover all available pages before exploring further.

# Annie Automation

> Teach Annie how to act on her own: route Slack messages with structured rules, per-sender fallbacks, and a fixed default behavior.

## Overview

Annie Automation (URL: `/automation`, formerly `/instructions`) is where you teach Annie how to act on her own. When a message lands in Slack from a tracked source, Annie runs through your rules top-to-bottom and picks an action: a quick chat reply, a full Root-Cause Analysis (RCA), waiting for a human, or staying silent.

The page is divided into three scopes:

* **Message routing** (live today): the rules engine described in this doc.
* **Scheduled tasks** (coming soon): standups, weekly reports, on-call handoffs.
* **Custom skills** (coming soon): ad-hoc skills triggered by `@Annie, do X`.

## How a message flows through Annie

```
Message lands → Skip duplicates? → Match a rule? → Default behavior
```

1. **Message lands**: a tracked Slack identity posts in a tracked channel, or a teammate `@`-mentions Annie.
2. **Skip duplicates**: if the same alert fired recently (within the duplicate-detection window), Annie links to the existing investigation instead of starting a new one.
3. **Match a rule**: Annie evaluates rules top-to-bottom; the first matching rule wins.
4. **Default behavior**: if no rule matches, Annie reads the message and picks the right response based on context.

## Default behavior

Annie's default behavior is **fixed as "Annie decides"**: when no rule matches, Annie reads the message and chooses between a quick chat reply, a deeper investigation, or staying silent based on context. This is intentionally not configurable. To get a different action for specific cases, **add a rule below** the default behavior card.

## Rules

A rule tells Annie what to do for a specific message. Each rule is built from four steps:

> **WHEN** a Slack message matches **WHO**, **WHAT**, and **WHERE** below, Annie does what you set in **THEN**.

| Step    | Field                       | Description                                                 | Empty means          |
| ------- | --------------------------- | ----------------------------------------------------------- | -------------------- |
| ① WHO   | `source_subscription_ids`   | The Slack user or bot Annie should listen to. Multi-select. | Anyone.              |
| ② WHAT  | `trigger_condition`         | A keyword, phrase, or natural-language pattern.             | Any message content. |
| ③ WHERE | `slack_channel_mapping_ids` | The Slack channel(s) Annie should watch. Multi-select.      | Any channel.         |
| ④ THEN  | `action_type`               | What Annie should do when the message above arrives.        | Required.            |

Below the stepper, a **live preview chip** reads the values back as a sentence ("Annie will run a full investigation when PagerDuty posts severity:critical in #oncall") so you can sanity-check the rule before saving.

### Action types

| Action                            | What Annie does                                          | Best for                                    |
| --------------------------------- | -------------------------------------------------------- | ------------------------------------------- |
| **Annie decides**                 | Reads the message and picks chat, RCA, or silence.       | General-purpose rules.                      |
| **Run investigation (RCA)**       | Triggers a full RCA against your connected integrations. | Alerts that always need deep investigation. |
| **Reply with a short answer**     | Conversational reply, no RCA.                            | Validation questions, quick lookups.        |
| **Wait for human to trigger RCA** | Posts a "Start investigation" button in the thread.      | Low-priority alerts; human-in-the-loop.     |
| **Stay silent**                   | Annie ignores the message entirely.                      | Known noise, test alerts.                   |
| **Generate a custom report**      | Renders one of your saved report definitions.            | Pre-defined investigation playbooks.        |

### Templates

The rules section opens with three starter recipes you can click to pre-fill the editor:

* **Auto-investigate critical pages** — `severity:critical` → Run RCA.
* **Mute a noisy bot** — Stay silent. Pick the bot in WHO.
* **Manual RCA in a noisy channel** — Wait for human. Pick the channel in WHERE.

Templates only seed the action and trigger. You fill WHO and WHERE for your project before saving.

### Reordering rules

Each row has a drag handle on the left (grip icon) and ↑/↓ arrows on the right. Reordering matters: Annie evaluates top-to-bottom, first match wins.

### Duplicate

The copy icon on each row opens a new-rule editor pre-filled with that rule's WHO/WHAT/WHERE/THEN. Tweak and save. Useful for forking a rule for a near-identical case without retyping.

## Grouped views

The Rules section has a **3-way pivot** in the top-right (Sender / Channel / Flat).

* **Sender**: one card per subscribed Slack identity. Each card shows that sender's rules and a **per-group fallback dropdown** (see below). A multi-select rule scoped to several senders appears under each of them.
* **Channel**: one card per Slack channel mapping, same shape.
* **Flat**: the linear list, drag-sortable, ordered by `order_index`.

Default pivot is computed from the project's rule shape: clusters of rules sharing a sender → Sender; clusters sharing a channel → Channel; small or all-distinct → Flat. Your override is remembered per project, per user.

### Per-group fallback (the "Jean-Marc fix")

When you subscribe a bot to Annie, every message from that bot is processed automatically. Without the per-group fallback, any message from that bot that didn't match a rule would fall through to Annie's default behavior — sometimes that's the right call, often it's not.

The per-group fallback closes that loop. Each sender card has an **inline dropdown** at the bottom:

> Otherwise (no rule above matched), Annie will \[stay silent ▾]

Subscribed senders default to **stay silent**. Mention-only senders default to **Annie decides**. Channels default to **stay silent**. The dropdown writes through to `PUT /custom-instructions/{projectId}/group-fallbacks/{kind}/{scopeId}` immediately.

Behaviour at evaluation time, when no rule matches:

1. Per-sender override wins if set.
2. Per-channel override wins next.
3. For subscribed senders without an override row, Annie applies the implicit `silent` default (the retroactive fix).
4. Otherwise, Annie's global default behavior fires.

### "Anyone" and "Any channel" rules

Rules with WHO empty (Anyone) or WHERE empty (Any channel) live under a synthetic group at the bottom of each grouped view. Their fallback dropdown is hidden — they already match every message that doesn't get caught by a scoped group above.

## Slack identities

Below the rules, the Slack identities table lists every user and bot Annie can route on. Each row has a status pill:

* **Subscribed**: Annie processes every message from this identity automatically, following any matching rule and the sender-fallback when nothing matches. This is the right setting for alerting bots (PagerDuty, Datadog, Grafana, Amazon Q).
* **Mention-only**: Annie only processes messages from this identity when they tag `@Annie`. This is the default for human teammates so Annie doesn't reply to every sentence.

Click the pill to flip it; the rules that target the identity stay in place. Use **Add identity** to register a Slack user or bot that hasn't been seen yet — automation rules can target any identity, subscribed or not.

## Duplicate alert detection

A time window for suppressing repeated alerts. When enabled, Annie detects if the same alert was already processed recently and links to the existing investigation instead of starting a new one. Configurable per project from the same page.

## Examples

<AccordionGroup>
  <Accordion icon="cloud" title="AWS Health Events via Amazon Q">
    A common pattern for teams using Amazon Q to forward AWS Health Events to Slack:

    1. Subscribe Amazon Q from the Slack identities table.
    2. Switch the Rules pivot to **Sender** so Amazon Q has its own card.
    3. Add one rule inside the card: `WHO=Amazon Q · WHAT=AWS Health Event with RDS · THEN=Reply with a short answer` with instructions: "Validate whether the reported service had a real failure".
    4. Leave the per-group fallback at **Stay silent** (the default for subscribed bots).

    Annie validates RDS health events and stays silent on everything else from Amazon Q.
  </Accordion>

  <Accordion icon="database" title="Database Alert Investigation">
    `WHO=anyone · WHAT=Alert contains "RDS" or "database" or "postgres" · WHERE=any channel · THEN=Run Investigation`

    Investigation instructions:

    * Check recent schema migrations in the last 24h
    * Review connection pool metrics and active connections
    * Look for long-running queries (>30s)
    * Check for recent deployments that might have changed queries
  </Accordion>

  <Accordion icon="bell-slash" title="Skip Low-Priority PagerDuty Alerts">
    `WHO=PagerDuty · WHAT=PagerDuty priority not P1 or P2 · THEN=Wait for human to trigger RCA`

    Annie posts a "Start investigation" button instead of investigating automatically. Team members click to investigate when they have time.
  </Accordion>

  <Accordion icon="flask" title="Ignore Test Alerts">
    `WHO=anyone · WHAT=Alert tags contain "test" · THEN=Stay silent`

    Annie ignores test alerts entirely.
  </Accordion>

  <Accordion icon="robot" title="Multi-rule per bot via grouped view">
    For teams that have a single workflow bot forwarding multiple alert kinds:

    1. Subscribe the bot.
    2. Switch the Rules pivot to **Sender**.
    3. Inside the bot's card, add focused rules ordered top-to-bottom (each with `WHO=that bot`).
    4. Set the card's per-group fallback to **Stay silent** so anything that didn't match falls quiet instead of triggering Annie's default behavior.

    This is the structural fix that prevents "I added a P1 rule but Annie keeps RCA-ing every message from this bot".
  </Accordion>
</AccordionGroup>

## Get Started

<CardGroup cols={2}>
  <Card title="Create Account" icon="user-plus" href="https://app.anyshift.io/">
    Sign up for Anyshift
  </Card>

  <Card title="Request Demo" icon="phone" href="https://calendly.com/roxane-fischer/30-zoom-meeting?back=1">
    See Annie Automation in action
  </Card>
</CardGroup>
