{
  "slug": "customer-health-score-slack-alert",
  "title": "Customer health score Slack alert: template and code",
  "url": "https://www.courier.com/recipes/customer-health-score-slack-alert",
  "markdown": "https://www.courier.com/recipes/customer-health-score-slack-alert.md",
  "stage": "Retention",
  "purpose": "Tell your customer success team in Slack the day an account's health drops.",
  "summary": "A customer health score Slack alert tells your customer success team the day an account's health drops below 50. It posts in your Slack channel with the score, what changed, and a link to the account, then emails the account's CSM a day later. If the score recovers first, the email doesn't go out.",
  "channels": [
    "slack",
    "email"
  ],
  "shape": "journey",
  "shows": [
    "A Slack post with the token stored once on a tenant",
    "A condition on a number in your data",
    "An email to the CSM through a recipient override"
  ],
  "data": [
    {
      "name": "account_id",
      "type": "string",
      "example": "acct_8F2k",
      "note": "Builds the cancellation token and the account link"
    },
    {
      "name": "account_name",
      "type": "string",
      "example": "Northwind"
    },
    {
      "name": "health_score",
      "type": "number",
      "example": "42",
      "note": "Your start code alerts only when it's below 50"
    },
    {
      "name": "drivers",
      "type": "string",
      "example": "Logins down, 2 unresolved support tickets",
      "note": "What moved the score"
    },
    {
      "name": "csm_name",
      "type": "string",
      "example": "Sam"
    },
    {
      "name": "csm_email",
      "type": "email",
      "example": "sam@example.com",
      "note": "Where the follow-up goes"
    }
  ],
  "steps": [
    {
      "step": "1",
      "when": "When an account's health score drops below 50",
      "channels": "Slack",
      "templates": [
        "templates/health-alert-slack.json"
      ]
    },
    {
      "step": "2",
      "when": "1 day after the Slack post",
      "channels": "Email",
      "templates": [
        "templates/health-followup-email.json"
      ]
    }
  ],
  "files": {
    "journey": "journey.json",
    "templates": [
      "templates/health-alert-slack.json",
      "templates/health-followup-email.json"
    ],
    "setup": [
      "setup.ts",
      "setup-slack.ts"
    ],
    "start": [
      "start.ts",
      "start.py"
    ],
    "stop": [
      "stop.ts",
      "stop.py"
    ]
  },
  "docs": [
    "https://www.courier.com/docs/journeys/nodes/send",
    "https://www.courier.com/docs/integrations/direct-message/slack",
    "https://www.courier.com/docs/journeys/nodes/delay",
    "https://www.courier.com/docs/journeys/nodes/cancel",
    "https://www.courier.com/docs/journeys/invoke"
  ],
  "related_recipes": [
    "https://www.courier.com/recipes/stalled-trial-slack-alert",
    "https://www.courier.com/recipes/usage-limit-alert-email",
    "https://www.courier.com/recipes/win-back-email-sequence"
  ],
  "agent_prompt": "Add a customer health score alert to this app, sent through Courier: when an account's health score drops below 50, post in our customer success Slack channel right away and email the account's CSM a day later, unless the score recovers. Follow the steps at https://www.courier.com/recipes/customer-health-score-slack-alert.md and use the Courier skill for SDK details.\n\n1. Create the journey and its two templates in my Courier workspace by running setup.ts from that page with COURIER_API_KEY from our environment. Save the journey ID it prints as COURIER_HEALTH_JOURNEY_ID. Replace the placeholder account link (https://admin.acme.com/accounts/) in the templates with our admin URL.\n2. Run setup-slack.ts from the same page with COURIER_API_KEY, SLACK_BOT_TOKEN, and SLACK_ALERT_CHANNEL (our customer success channel's ID) from our environment. It creates the \"cs-alerts\" tenant that the Slack node in journey.json already names.\n3. Find the job or code that computes customer health scores and start the journey, as the account's primary contact, when an account's score drops. Pass the fields in the Data fields table from our own data, with health_score as a number. The start code skips scores of 50 or above.\n4. Find where the job sees a score recover above 50 and cancel the journey with the token health-<account_id>.\n5. Match this codebase's language, file layout, and error handling. Never hardcode the API key or the Slack token.\n6. When you're done, start one run for a test account with a score of 42 and show me the run's steps. The Slack post sends right away and the run then waits a day for the email, so cancel the test run once you've checked it.",
  "status": {
    "state": "passing",
    "last_tested": "2026-10-19"
  }
}
