# Slack recipes

> Get a Slack message when someone texts you, your Mac goes offline or a webhook stops.

Three recipes for Slack. Each names its trigger and the BlueBot step, lists the fields to map and says how to test it with your own number before anyone else gets a text.

## How Slack connects

- **[Built in](https://usebluebot.com/docs/concepts/how-it-works)**: It works inside BlueBot with nothing else to set up.
- **[Zapier](https://usebluebot.com/docs/zapier)**: BlueBot’s Zapier app has a Send Text action and instant triggers for incoming texts and every change of state.

## Post new replies to a channel

| Part             | What it is                                            |
| ---------------- | ----------------------------------------------------- |
| Trigger          | Someone texts you                                     |
| Action           | BlueBot’s webhook starts it, and Slack takes the text |
| Connects through | [Built in](https://usebluebot.com/docs/concepts/how-it-works)               |

### Steps

1. Create an incoming webhook for the channel in Slack and copy its URL.
2. Paste the URL into BlueBot’s Slack notifications and turn on alerts for new replies.
3. Each new reply then shows up in that channel.

### Map the fields

| From BlueBot    | Into Slack                                                                                                                                         |
| --------------- | -------------------------------------------------------------------------------------------------------------------------------------------------- |
| **From**        | The phone number to find the person by in Slack. It’s in E.164 (`+15555550123`); search by the last 10 digits if Slack stores numbers another way. |
| **Text**        | The words, for a note, a row or a message. Null when the person sent only a picture.                                                               |
| **Received At** | When it came in, in UTC.                                                                                                                           |
| **Files**       | Pictures and voice memos. Each `url` works for an hour, so copy a file you want to keep.                                                           |
| **Chat ID**     | Set when the text came in a group chat; null for a one-to-one text.                                                                                |

### Test it

Text your BlueBot number from another phone and check that the step ran. BlueBot copies texts from people you’ve texted through it, unless you set **Which chats to copy** to **Everything**.

## Know when your Mac goes offline

| Part             | What it is                              |
| ---------------- | --------------------------------------- |
| Trigger          | Your Mac stops checking in              |
| Action           | Slack acts on what BlueBot reports      |
| Connects through | [Built in](https://usebluebot.com/docs/concepts/how-it-works) |

### Steps

1. Use the same Slack webhook and turn on the alerts for the Mac going offline and for a paused webhook.
2. If your Mac stops checking in, the channel hears about it, and texts wait until the Mac is back.

### Map the fields

| From BlueBot       | Into Slack                                                                                |
| ------------------ | ----------------------------------------------------------------------------------------- |
| **State**          | `sent`, `delivered`, `read`, `failed` or `expired`, for a field or a filter.              |
| **Metadata**       | The `record_id` you sent with the text, to find the record it was for.                    |
| **Failure Reason** | Why a failed text didn’t go: `not_on_imessage`, `messages_refused` or `file_unavailable`. |
| **To**             | Who the text was for.                                                                     |

### Test it

Send one text to your own number, then look for the event. To try the step without sending anything, `POST /v1/webhooks/{id}/test` sends an example of any event type to your webhook.

## Text the on-call person from a channel

| Part             | What it is                                              |
| ---------------- | ------------------------------------------------------- |
| Trigger          | Slack’s New Message Posted to Channel trigger in Zapier |
| Action           | BlueBot’s **Send Text** action                          |
| Connects through | [Zapier](https://usebluebot.com/docs/zapier)                                  |

### Steps

1. Start a Zap with Slack’s New Message Posted to Channel trigger on your urgent channel.
2. Add BlueBot’s Send Text action with the on-call person’s number in To.
3. Map the message and who posted it into Text.

### Map the fields

| BlueBot field               | Map it to                                                                                                                                  |
| --------------------------- | ------------------------------------------------------------------------------------------------------------------------------------------ |
| To                          | The person’s mobile number from Slack. US numbers can leave off the +1.                                                                    |
| Text                        | Urgent from {{user_name}} in Slack: {{message}}                                                                                        |
| `{{user_name}}` in the text | Slack’s user name field.                                                                                                                   |
| `{{message}}` in the text   | Slack’s message field.                                                                                                                     |
| Metadata                    | `source` set to `slack`, and `record_id` set to the record’s id, so the status and reply webhooks for this text can find the record again. |
| Service                     | Auto, the default: iMessage when the person uses it, otherwise SMS through your iPhone.                                                    |

### Test it

Put your own number in **To** and press **Test step**. A text arrives on your phone from your own number, and Zapier shows the message BlueBot returned with `state: "queued"`. Then map Slack’s field back into **To** and turn the Zap on.

## Before you turn it on

- Text only people who asked to hear from you. Anyone who replies STOP goes on your stop list, and BlueBot cancels texts to them. [Stop words](https://usebluebot.com/docs/concepts/stop-words)
- A text that can’t go yet waits with a hold rather than failing: quiet hours, your Mac away, a daily limit. [Holds](https://usebluebot.com/docs/concepts/holds)
- [Slack with BlueBot](https://usebluebot.com/integrations/slack) on the integrations page says what else the two do together.
