# Slack

Each agent can have a Slack app of its own, so you can talk to the agent from Slack. In Discord, one bot serves every agent. In Slack, you connect each agent on its own. So one agent's app can be in one Slack workspace, and another agent's app can be in a different Slack workspace.

## Connecting an agent to Slack

1. Open the agent, then **Settings**, then **Access**.
2. Find the **Slack** card.
3. Press **Make the Slack app**. Slack opens its own page, with the app already described.
4. Choose your Slack workspace.
5. Press Next, then press Create.
6. In the new app, open **Basic Information** and find **App-Level Tokens**.
7. Press Generate.
8. Give the token any name, and add the scope `connections:write`.
9. Copy the token. It begins with `xapp-`.
10. Open **Install App**, and install the app to your Slack workspace.
11. Copy the **Bot User OAuth Token**. It begins with `xoxb-`.
12. Paste both tokens into the Slack card and press **Connect**. Catervas keeps the tokens encrypted on your computer.
13. Catervas shows a six-digit code. In Slack, open a direct message with the agent's bot and send it that code. The card notices the code by itself and shows who the agent now listens to.

## Who the agent listens to

The agent listens only to the person who sent the pairing code. Anyone else who writes to the bot gets no answer. When other people press approval buttons, nothing happens. To change who the agent listens to, disconnect and connect again.

## Talking to the agent in Slack

Write to the bot in your direct message with it. Your messages go into the same conversation that the dashboard shows. When the agent needs permission, the question arrives with buttons.

The bot also understands these commands. They begin with `!`, because Slack keeps `/` for itself.

| Command | What it does |
| --- | --- |
| `!status` | Says what the agent does now |
| `!start`, `!stop`, `!restart` | Start, stop or restart the agent |
| `!new` | Begins a new conversation |
| `!cancel` | Stops the reply that the agent writes now |
| `!help` | Lists these commands |

## Sending and getting files in Slack

You can attach files to a message in your direct message with the bot. These files reach the agent in the same way as files that you attach in the dashboard:

- Catervas accepts the same kinds of file.
- Each file can be up to 20 MB, and one message can carry up to 10 files.
- If Catervas refuses a file, you get the same short sentence in reply, which names the file.

When an agent in a workspace gives you a file, the bot posts it in the direct message as an ordinary file. The text of the post is the agent's line about the file.

A Slack app that you made before Catervas was able to carry files does not have two permissions that it needs for files. These permissions are to read files and to write files. Until somebody approves the app again, Catervas does not give the agent the files that you send in Slack. Also, the bot posts a message in place of each file that the agent gives you. The message says to download the file in Catervas.

The Slack card in the agent's settings tells you about this problem and how to fix it:

1. Open your app at [api.slack.com/apps](https://api.slack.com/apps).
2. Go to **OAuth & Permissions**.
3. Under **Bot Token Scopes**, add `files:read` and `files:write`.
4. Press **Reinstall to Workspace** in the banner at the top of the page.
5. Allow the reinstall.
6. Press **Check again** on the Slack card.

## What the Slack app can see

The Slack app can see only the direct messages that people send to its bot, and the files attached to them. It cannot read channels or anything else in your Slack workspace.

## Disconnecting

Press **Disconnect Slack…** on the card and confirm. Catervas closes the connection. It forgets both tokens and the person that the agent listened to. When you delete the agent, Catervas does the same.
