# Post App Store news to a Slack channel

> Make a Slack incoming webhook, save its address in your Team's Passwords, and have an Agent post App Store news to the channel, when you ask or on a Schedule.

Source: https://air.build/docs/connect/post-app-store-news-to-slack/

An Agent can post a message to a Slack channel for you: a build is ready for testers, a version was approved, how the week's ratings went. It posts through a Slack incoming webhook, an address Slack makes for one channel. You make the webhook in Slack, save its address in your Team's Passwords, and ask.

> [!NOTE]
> AirBuild has no screen for posting to Slack. You ask an Agent in the Project's chat, and it uses `asc notify slack`, which its help describes as "Send a message to Slack via incoming webhook." (see notify in [asc: automation](https://air.build/docs/cli/asc-automation/#notify)). The command only posts: it can't read the channel or answer messages there.

## Make the webhook in Slack

In Slack, you create a Slack app for your Slack workspace, turn on its incoming webhooks, add a webhook for the channel you want, and copy the webhook's address. Slack walks through it in [Sending messages using incoming webhooks](https://docs.slack.dev/messaging/sending-messages-using-incoming-webhooks/).

The address starts with `https://hooks.slack.com/` (or `https://hooks.slack-gov.com/` for Slack's government workspaces). Slack's page says it contains a secret and asks you not to share it.

Each webhook posts to the channel it was made for. For another channel, make another webhook.

## Save the address in Passwords

The Agent reads the address from your Team's **Passwords** with [password-book](https://air.build/docs/cli/password-book/) and passes it straight to `asc notify slack`, so it doesn't sit in the chat. There are two ways to save it:

- When the Agent asks, it posts a card for a login to save, with a box for the address. Paste the address and tap **Submit**. The value goes to the Team's Passwords, not into the chat. See [Save logins for Agents](https://air.build/docs/agents/save-logins-for-agents/#save-a-login-when-an-agent-asks).
- To save it yourself before you ask, open **Settings**, then your Team, then **Passwords**, and tap **Add Password**. Type a **Title**, such as "Slack releases webhook", paste the address into **Password**, and tap **Save**. Then tell the Agent the title. See [Save logins for Agents](https://air.build/docs/agents/save-logins-for-agents/#add-a-login-yourself).

> [!WARNING]
> The Passwords screen says: "Everyone on the Team and all of its Agents can see these. A value filled into a preview stays there as plain text. Save test accounts only, not personal accounts or production keys." Make the webhook for a channel your whole Team may post to. If the address gets out, remove the webhook in Slack and make a new one.

## Post a message

Ask in the Project's chat, for example:

```text
Post in Slack with the webhook saved as "Slack releases webhook": version 1.2 of Notes is approved and ready for release.
```

1. The Agent reads the address from Passwords.
2. It posts with `asc notify slack`, with your words as the message.
3. When Slack takes it, the command prints "Message sent to Slack successfully", and the Agent tells you in the chat. Look in the channel.

The Agent can check App Store Connect first and put what it finds in the post. For where a release stands, it has `asc status`, a release dashboard for one app (see [asc: review and release](https://air.build/docs/cli/asc-release/#status)).

## What a post can have

| What | `asc notify slack` |
| --- | --- |
| Text | `--message`. Every post has it. When the post has a layout, this is the text Slack falls back on. |
| Fields such as the app, version and build | `--payload-json` or `--payload-file`, with `--pretext` for a line above them, and `--success false` to mark them as a failure. |
| A layout made with Slack's Block Kit | `--blocks-json` or `--blocks-file`. |
| A reply in a thread | `--thread-ts`, the timestamp of the message to reply to. A webhook answers a post only with "ok", so the Agent can't get it from its own posts: it comes from Slack. |
| Another channel | `--channel`. Slack may ignore it for incoming webhooks, so make a webhook for each channel instead. |

## Post news as it happens

Agents don't hear about new builds or approvals on their own: AirBuild sends those to people as notifications. So to tie posts to what happens on the App Store, make them part of the work you ask for:

```text
Upload the new build to TestFlight, and post in Slack with the "Slack releases webhook" when it's ready for testers.
```

Or give the Agent a Schedule, so it checks and posts on a timetable without being asked:

```text
Every weekday at 9, check where Notes stands in App Store Connect and post a short update in Slack with the "Slack releases webhook". Don't post if nothing changed.
```

You can add the Schedule yourself on the Agent's **Schedules**, or ask the Agent to add it, as above. See [Schedule work for an Agent](https://air.build/docs/agents/schedule-agent-work/).

## If something goes wrong

**The Agent says --webhook is required.**

The message is "--webhook is required or set ASC_SLACK_WEBHOOK env var": the Agent had no address. Check that the title you gave matches the login in **Passwords** exactly, or save the address there first.

**The Agent says the webhook must be a valid Slack webhook URL.**

The saved address isn't a Slack incoming webhook. The command takes only an `https://` address on `hooks.slack.com` or `hooks.slack-gov.com`, with nothing after a `?` or `#`. Copy the webhook's address from Slack again and save it in **Passwords**.

**The Agent says Slack gave an unexpected response.**

The message is "notify slack: unexpected response" with a number, and usually Slack's reason. Slack's page lists the reasons: for example `no_service` means the webhook is turned off, removed or invalid, and `channel_is_archived` means the channel was archived. See [Sending messages using incoming webhooks](https://docs.slack.dev/messaging/sending-messages-using-incoming-webhooks/).

**The post went to the wrong channel.**

An incoming webhook posts to the channel it was made for, and Slack may ignore `--channel`. Make a webhook for the channel you want and save its address under another title.

**Can I paste the address in the chat instead?**

You can, but the message stays in the chat, where everyone in it can read it. You can recall it, but Agents that already read it have seen it: see [Reply, react, edit or take back a message](https://air.build/docs/projects/reply-react-and-edit/#take-back-a-message). If you pasted it, remove the webhook in Slack and make a new one. Saving it in **Passwords** keeps it out of the chat.

**Can the Agent read the channel or reply to people in Slack?**

No. `asc notify slack` only posts to the webhook's channel.
