# Board alerts in Slack

> Announce new, renamed, trashed and shared boards in Slack with webhooks.

Source: https://mockflow.com/developers/examples/api/board-alerts

A marketing lead wants to know when the team starts a new campaign board, without checking MockFlow all day. This example listens for MockFlow's webhooks: each new board in the marketing space is announced in Slack and added as a row in the content tracker, and renames, trashed boards and new people are announced too.

[**Download the code**](/developers/assets/examples/mockflow-board-alerts.zip) (Node.js 18 or later, no packages)

## What it does

- Registers a webhook for `board.*` and `member.added`.
- Receives each event, checks its signature, and ignores an event id it has already handled.
- Posts a line to Slack for each event, and adds every new board to `tracker.csv` (your tracker's API in a real setup).
- Keeps only one space's events when `SPACE_ID` is set.

## How it works

1. [Create the webhook](/developers/reference/webhooks/create-webhook) with `POST /webhooks`, your https address and the events. The answer carries the signing secret, once; the example saves it to `.env`.
2. MockFlow POSTs each event to your address with a `MockFlow-Signature` header. [Check the signature](/developers/concepts/webhooks#check-the-signature) against the raw body.
3. Answer `200` at once, then do the work. A failure is retried, so the same event can arrive again: its `id` stays the same.
4. [Send a test](/developers/reference/webhooks/test-webhook) with `POST /webhooks/{webhookId}/test` to check the whole path.

Webhooks cover boards being created, renamed, locked, moved, trashed and restored, and people gaining or losing access. They do not fire for each edit to the items on a board.

## Run the example

Create an API key in the [developer console](/developers/console/) with the scopes `user:read` and `boards:read`. Set `PUBLIC_URL` to the https address your receiver will have, for example from `ngrok http 3000`, then:

```bash
cp .env.example .env        # paste your key and PUBLIC_URL into .env
node setup.js               # registers the webhook, saves its secret
node receiver.js            # in a second terminal: node setup.js test
```

## The key code

```javascript
const raw = await readBody(req);
if (!verifySignature(raw, req.headers['mockflow-signature'], SECRET)) return res.writeHead(401).end();
res.writeHead(200).end();

const event = JSON.parse(raw);
if (seen.has(event.id)) return;
seen.add(event.id);

if (event.type === 'board.created') {
  await notifySlack(`${event.actor?.email || 'Someone'} started a new board: ${event.data.title} ${event.data.url}`);
}
```

## Adapt it

- **Project trackers:** create a task in Asana or Monday for every new client board.
- **Compliance:** log every share to your audit system with `member.added` and `member.removed`.
- **Automation tools:** Zapier and Make can subscribe the same way; see [Building a Zapier integration](/developers/concepts/webhooks#building-a-zapier-integration).

## What you need

An API key with `user:read` and `boards:read` to manage webhooks. Every plan.
