# Slack

Source: https://pinprompt.veren-technology.com/docs/reference/slack

Posts items that need someone to a Slack channel as they happen, plus a daily digest. It uses a Slack **incoming webhook** (one channel per webhook), so there is no Slack app to install and nothing in Slack can read pinprompt. [Microsoft Teams](https://pinprompt.veren-technology.com/docs/reference/teams.md) does the same in a Teams channel.

## Set it up

You need the **owner** role on the project.

1. In Slack: **Apps → Incoming WebHooks** (or create an app at https://api.slack.com/apps → *Incoming Webhooks* → *Add New Webhook to Workspace*) and pick the channel. Copy the URL (`https://hooks.slack.com/services/T…/B…/…`). It is a secret: anyone with it can post to the channel.
2. In pinprompt: **Project → Settings → Integrations → Slack → Connect Slack**. Paste the URL, optionally a channel label for the card (`#halden-qa`), choose what posts right away and when the digest runs.
3. pinprompt posts a test message on connect. **Send test message** and **Send digest now** are on the card at any time.

The URL is encrypted with `PINPROMPT_SECRET_KEY` and never shown again; **Edit → Replace webhook URL** to move channels. In production only `https://hooks.slack.com/…` (and `hooks.slack-gov.com`) URLs are accepted.

## Right away

| Choice | Posted when |
|---|---|
| New item in triage | an item is created in Needs triage |
| Needs a person | an item moves to With people |
| Ready to check | an item moves to To check (a fix is on a preview) |
| Failed a check | a reporter fails the check (with their note) |

Each message is Block Kit: the item key linked to pinprompt, the title, and a context line with the project, page path, kind, priority and who did it. Everything from pinprompt is escaped, so a title can't `@channel` or fake a link. Never sent: screenshots, specs, code paths, emails or costs.

### Bulk changes

A bulk change in the inbox (two or more items at once) posts **one message**, not one per item: for each choice above that it triggers, the headline, how many items, who did it and what ("Needs a person · 14 items · Mia Hart moved to With people"), then up to 10 linked item keys and "and 4 more". Undoing it posts one **Undone** message listing the items that went back, and only if the change itself posted something. A bulk change none of your choices cover (a priority change, say) posts nothing, and neither does its undo.

The message is sent once the whole change is written (from its `project.bulk_action` summary event); the item events of the change are recorded as skipped on the card. If a change is cut off before its summary is written (the server stopped half-way), a housekeeping job writes the summary 5 minutes later, so the message still goes out, reading "changed N items".

## Daily digest

Once a day at the hour you pick, in the time zone you pick (default 09:00 UTC; daylight saving is handled), for the 24 hours before that hour:

- **New**: items created (the newest five are listed with links)
- **Closed**: items done or won't fix (with how many were fixed)
- **Waiting on people**: what is in triage, has a question, is to check or is with people right now
- **First-try fixes, 7 days**: the same first-try rate as the Metrics page (verified done, first agent run passed, never failed a check or reopened)

A day with nothing new, closed or waiting posts nothing.

It is posted **once per day**: the `job_state` row `slack-digest:<integration id>` records the last digest time, and a run claims the day with a compare-and-set on it, so two servers never both post. A failed post is tried again 15 minutes later, for up to 6 hours after the digest hour. A Slack integration connected after today's hour starts tomorrow. **Send digest now** posts the last 24 hours without changing the schedule.

The job (`slack-digest`) runs every minute inside the web server with the other jobs (`PINPROMPT_JOBS=0` turns them all off).

## Failures

Immediate posts go through the integration runner: a `5xx`, `429` or timeout is retried with backoff (six attempts in about 15 minutes); `400`, `403`, `404` and `410` mean the webhook was removed, the channel archived or the payload refused, and are not retried. The card shows Slack's reason (`no_service`, `channel_is_archived`, …) and every attempt with its status code and latency.

## Tests

Tests never call Slack: the URL points at a local receiver (`packages/core/test/outbound-mock.ts`). See `packages/core/test/slack.test.ts`.
