# Template: approved partners to Slack

A Slack message for every approved partner, by display name, with the webhook's signature checked first.

A template for Make or n8n that posts a Slack message when a partner is
approved for one of your programs:

> New partner approved in Acme referrals: Jane

The message names the partner by their display name in the program and
nothing else. A partner's email is never in it, even when they chose to share
it with you.

## What it does

1. Bolt Claw sends `referral.partner.approved`, with the program's id and the
   partner's id and nothing more. The template checks the delivery's signature
   and time first.
2. It reads the program (`GET /v1/referrals/programs/{id}`) for its name, and
   the program's approved partners
   (`GET /v1/referrals/programs/{id}/partners?status=approved`) to find the
   partner by their id.
3. It posts the message. A name is sent as text: Slack's `<`, `>` and `&` are
   escaped, so a display name can never mention a channel or hide a link.

n8n reads up to ten pages of partners. Make reads the first page, the 100
approved partners who applied most recently; a partner who applied long ago
and was only now approved may not be on it, and the message then says to open
Bolt Claw to see who.

## Before you start

- A key with `referrals:read` only.
- A Slack connection in Make or n8n that can post to the channel.
- An endpoint in **Settings, Developers, Webhooks** for the event
  `referral.partner.approved`, added once you have the template's address. Copy
  its signing secret: it is shown once.

## In Make

1. Download `https://boltclaw.ai/referrals/templates/make/partner-approved-to-slack.json` and import it (**...** menu, **Import
   Blueprint**).
2. In the first module, **Add** a webhook. Under **Show advanced settings**, set
   **Get request headers** and **JSON pass-through** to **Yes**. Copy its
   address and add it as the endpoint in Bolt Claw.
3. **Expected signature**: replace `PASTE_THE_ENDPOINT_SIGNING_SECRET` with the
   signing secret. Keep the quotes.
4. **Read the program** and **List approved partners**: replace
   `bc_live_PASTE_YOUR_KEY` in the `Authorization` header.
5. **Post to Slack**: your Slack connection and the channel.
6. Switch the scenario on.

If a Bolt Claw call fails, that one message is skipped and the scenario stays
on: a missed message is not worth stopping for.

## In n8n

1. Download `https://boltclaw.ai/referrals/templates/n8n/partner-approved-to-slack.json` and import it (**Import from File**).
2. **Verify signature**: put the signing secret in an n8n Variable
   `BOLTCLAW_WEBHOOK_SECRET`, or between the quotes at the top of the node.
3. **Read the program** and **List approved partners**: a **Header Auth**
   credential, Name `Authorization`, Value `Bearer bc_live_...`.
4. **Post to Slack**: your Slack credential and the channel (`#partners` in the
   file).
5. Publish the workflow and add the **Bolt Claw webhook** node's production
   address as the endpoint.

## Test it

- **The signature.** Press **Test** on the endpoint in **Settings, Developers,
  Webhooks**. The test event passes the signature check and stops at the event
  check: the secret is right, and nothing is posted.
- **A message.** Approve a partner in a program (a second account of your own
  applying is enough), or approve one waiting on the **Partners** tab. Programs
  that approve everybody automatically send the event as soon as somebody
  joins.

<!-- https://boltclaw.ai/docs/referral-template-partner-slack as markdown. Generated from openapi.yaml; API version 1.22.0. -->
<!-- Every /docs page answers as markdown: add .md to its path, or send Accept: text/markdown. -->
