# Post to Slack or send email

> Lets an agent post to a Slack channel through your own Slack bot, or send email through your Postmark account.

Building an agent goes in order: build the agent, connect your systems, add functions, scripts and widgets, test it, take it live, then put it in your product. Highlighted: Connect.

## Ask your coding agent

```
Let the invoice exceptions agent post each new supplier query to #finance-exceptions in Slack.
```

Skill: [mindset-slack-connection](https://docs.mindset.ai/skills/mindset-slack-connection/SKILL.md)

```
Let the invoice exceptions agent email the finance manager when it registers a supplier query, from exceptions@acme.com.
```

Skill: [mindset-postmark-email-connection](https://docs.mindset.ai/skills/mindset-postmark-email-connection/SKILL.md)

## What gets built

**Slack:** a Slack app in your own workspace, and a [connection](https://docs.mindset.ai/docs/connections-and-operations) with one write operation, `post_message`. The app asks for one scope, `chat:write`, so the bot posts only in channels it has been invited to and reads no messages at all.

**Email:** an HTTP API connection to Postmark that holds your Server API token, with `get_server`, a read that proves the token, and `send_email`, a write.

Both sends are writes, so they follow your org's [approval](https://docs.mindset.ai/docs/approve-what-an-agent-can-do) rules. If your org already has a Slack or Postmark connection, your coding agent offers to reuse it and asks for no keys.

## What you decide

- **Slack:** the bot's name and the channel. You create and install the app in Slack, since only you can, and some workspaces need an admin to approve a new app. Your coding agent tells you what to paste where, and does the Mindset side.
- **Email:** the sender address at your own domain, verified in Postmark under **Sender Signatures**. The secret is the server's **Server API token**, not the Account API token.
- **Buttons in a Slack message:** only when a script must wait for a person's answer, below.

## Approvals with buttons in Slack

A script's `$ask` step posts a message with buttons and waits for a click (see [Make it follow steps](https://docs.mindset.ai/docs/write-a-script) and [Security and approval](https://docs.mindset.ai/docs/security-model)). The same Slack app carries it, with two more things a Slack admin sets up:

1. **The right secret.** The connection holds the app's **App ID** and **Signing Secret**, from **Basic Information → App Credentials**, and its **Bot User OAuth Token** (it starts `xoxb-`), from **OAuth & Permissions** once the app is installed. Take the Signing Secret, not the Client Secret beside it.
2. **Interactivity.** On the connection's **Settings** tab, under **Let a person answer in Slack**, copy the Request URL. In the Slack app, switch **Interactivity** on, paste the URL and save. Slack checks the address on save, so it must be a deployed environment Slack can reach.

Then invite the bot to the channel with `/invite @Approvals`. Skipping that is the most common first failure. The card on **Settings** shows whether both secrets are captured: without the bot token nothing posts, and without the signing secret nobody's click comes back. A message with no buttons means `post_message` was registered without its `blocks` parameter.

> **Info:** Until Postmark approves a new account, it may send only to addresses at the sender's own domain.

## Done when

You saw a real test message from the bot in the channel you chose, or received a real test email from the verified sender, and the agent holds `post_message` or `send_email`. A published connection alone isn't done.

## In your repo

The Slack or Postmark connection is a file in `agents/connections/` like any other, with no token in it. A person enters the token on a capture page, once per environment. See [Keep your agents in your code](https://docs.mindset.ai/docs/keep-your-agents-in-your-code).

## In the Studio

Both are ordinary connections under **Connections**. Check that `post_message` or `send_email` is enabled on the connection's **Operations** tab, approve it there if it's waiting, then add it on the agent's **Resources** tab.

![A connection's Operations tab, where each operation is enabled and made available to agents.](https://docs.mindset.ai/images/docs/studio/connection-operations.png)
