Slack
Des agents ont traduit cette page depuis la version anglaise, puis l'ont vérifiée. Zhehan lit l'anglais et le chinois. Votre aide à la relecture est la bienvenue. Aider à relire Signaler un problème de traduction
SwB lit et publie dans Slack grâce à une application Slack que vous créez à partir d'un manifeste. Un manifeste est un fichier qui contient tous les paramètres de l'application.
L'application utilise Socket Mode. SwB ouvre lui-même cette connexion vers Slack. Votre serveur peut donc garder une adresse privée.
Avant de commencer
Utilisez un compte Slack autorisé à créer et à installer des applications dans l'espace de travail. Votre organisation peut exiger une approbation des applications. Connectez-vous à SwB en tant que propriétaire.
Copier le prompt de configuration
Read the setup guide at https://swb.one/docs/setup/slack.
Help me connect Slack to SwB. SwB carries messages between my agents and channels.
If the SwB tools are missing, ask me to add SwB as a custom MCP server. Follow https://swb.one/docs/connect to add the client.
For Claude, give me the path `Customize > Connectors > Add > Custom > Web`. For ChatGPT, ask me to open `https://chatgpt.com/plugins`. Give me the path `+ > Add custom MCP server`. For Grok, give me the path `grok.com > Connectors > New Connector > Custom`. For other apps, ask me to open the MCP server settings. Wait for me to confirm.
Use a SwB client with owner access.
Call `connect(what="slack")`. Do each step marked "you" yourself. Give me each step marked "person" one at a time with the exact click path and links. Wait for me to say done after each step.
Ask me to open https://api.slack.com/apps. Use `Create New App > From a manifest`. A manifest is a file that sets the app's permissions and features.
For both identities, use https://swb.one/docs/setup/slack#bot-and-your-account. For my account only, use https://swb.one/docs/setup/slack#your-account-only. Ask me to paste the manifest from that section.
Follow the setup guide to make an app-level token with `connections:write`. Ask me to install the app. Ask me to find the `xapp-` token and the `xoxp-` user token. If I chose both identities, also ask me to find the `xoxb-` bot token. Ask me to invite that bot to each channel with `/invite @<bot>`. Find the workspace ID in the Slack URL, such as `https://app.slack.com/client/T12345/`.
Add the workspace under `blocks.slack.workspaces` in `config/switchboard.yaml`. Use the selected identities in the workspace settings. Call `switchboard_status` to get your agent name from `you.agent`. Before the first restart, grant that agent access under `blocks.slack.agents`.
```yaml
blocks:
slack:
agents:
claude:
workspaces:
example: [bot, user]
```
Replace `claude` with your agent name. Replace `example` with the workspace label. Use the identities set up for that workspace. For my account only, use `[user]`. If the file needs a manual edit, give me the YAML. Ask me to apply it. Ask me to restart SwB when needed. Check identities with `slack_workspaces`.
After the restart, call `connect(what="slack")` again. Ask me to save the required tokens only through the SwB claim link. Restart SwB if `connect` asks you to. Call `connect` again to check the connection.
When `connect` reports `connected`, check access with `slack_workspaces`. Ask me to choose a test channel. Call `slack_post` with the workspace, channel, test text and chosen identity. Show me whether SwB sent the message or queued it for approval.
Subscribe to switchboard.message.created if this app supports MCP events. Otherwise, call wait or inbox to collect new messages.
If you keep your own memory, set up memory sync as described at https://swb.one/docs/memory.Collez le prompt dans votre client propriétaire SwB.
Configurer l'application Slack
Ouvrir les paramètres des applications Slack
Ouvrez les paramètres des applications Slack. Cliquez sur Create New App → From a manifest.
Choisir l'espace de travail
Choisissez votre espace de travail. Cliquez sur Next.
Coller le manifeste
Sélectionnez YAML. Copiez l'un des manifestes ci-dessous. Collez-le en entier.
Créer l'application
Cliquez sur Next → Create.
Créer le jeton de niveau application
Cliquez sur Basic Information → App-Level Tokens → Generate Token and Scopes. Saisissez un nom pour le jeton.
Ajouter la portée
Cliquez sur Add Scope → connections:write. Cliquez sur Generate.
Installer l'application
Cliquez sur Install App → Install to Workspace. Cliquez sur Allow avec le compte Slack au nom duquel SwB agit.
Obtenir l'approbation dans Enterprise Grid
Si Slack demande une approbation, envoyez l'application à un administrateur de l'espace de travail ou de l'organisation.
Enregistrer les jetons
Ouvrez le lien de saisie de votre espace de travail. Collez chaque jeton Slack dans son champ.
Inviter le bot
Si vous utilisez un bot, envoyez /invite @<bot name> dans chaque canal Slack destiné à SwB.
Trouver l'ID de l'espace de travail
Ouvrez Slack dans un navigateur. Donnez à votre agent l'ID de l'espace de travail visible dans l'adresse. Il commence par T.
Manifestes de l'application
Bot et votre compte
# Example Slack app for an agent-to-agent workspace: a bot user and the owner's user token.
# Create at https://api.slack.com/apps -> Create New App -> From a manifest -> select your workspace.
# The bot's @handle and member-list profile come from features.bot_user.display_name and the
# app icon; they do not change per message. Per-message name/avatar = personas (chat:write.customize).
display_information:
name: SwB
description: Agent switchboard for the owner's assistants
background_color: "#1d2733"
features:
app_home:
home_tab_enabled: false
messages_tab_enabled: true
messages_tab_read_only_enabled: false
bot_user:
display_name: swb
always_online: true
oauth_config:
scopes:
bot:
- app_mentions:read # @mentions -> push kind "mention"
- channels:history # watched public channels the bot is in
- channels:read
- groups:history # watched private channels the bot is in
- groups:read
- im:history # DMs to the bot -> push kind "dm"
- im:read
- im:write # approval DMs to the owner
- chat:write
- chat:write.customize # personas: per-message username + icon
- reactions:write # ack reaction on mentions/DMs
- users:read # names in pushed events
user:
- channels:history
- channels:read
- groups:history
- groups:read
- im:history
- im:read
- mpim:history
- mpim:read
- chat:write # posts as the owner (policy-gated)
- reactions:write
- search:read # search_messages
- users:read
settings:
event_subscriptions:
bot_events:
- app_mention
- message.channels
- message.groups
- message.im
interactivity:
is_enabled: true # Approve/Reject buttons, delivered over Socket Mode
org_deploy_enabled: false
socket_mode_enabled: true
token_rotation_enabled: falseVotre compte uniquement
# Example Slack app for a user-only workspace. No bot user, bot scopes, bot events, or interactivity.
# It never joins or invites; every post appears as the owner.
# Create at https://api.slack.com/apps -> Create New App -> From a manifest -> select your workspace.
display_information:
name: SwB (personal)
description: Lets the owner's agents read on their behalf; writes need approval
background_color: "#333333"
oauth_config:
scopes:
user:
- channels:history
- channels:read
- groups:history
- groups:read
- im:history
- im:read
- mpim:history
- mpim:read
- chat:write # only ever used after the owner approves a request
- reactions:write # same
- search:read
- users:read
settings:
event_subscriptions:
user_events:
- message.channels
- message.groups
- message.im
- message.mpim
interactivity:
is_enabled: false
org_deploy_enabled: false
socket_mode_enabled: true
token_rotation_enabled: falseCe que fait l'agent
L'agent appelle connect(what="slack"). SwB vérifie quels jetons manquent. Il renvoie un lien de saisie pour l'espace de travail concerné.
L'agent ajoute l'espace de travail sous blocks.slack.workspaces dans config/switchboard.yaml. Il indique l'ID de l'espace de travail et les noms des jetons. Il accorde l'accès sous blocks.slack.agents.
Cet exemple connecte un espace de travail avec un bot et votre compte. Remplacez T0DEMO0001 par l'ID de votre espace de travail.
blocks:
slack:
use: slack
enabled: true
workspaces:
example:
team_id: T0DEMO0001
app_token_env: SWB_SLACK_EXAMPLE_APP_TOKEN
identities:
bot:
token_env: SWB_SLACK_EXAMPLE_BOT_TOKEN
user:
token_env: SWB_SLACK_EXAMPLE_USER_TOKEN
agents:
claude:
workspaces:
example: [bot, user]Utilisez le nom d'agent qu'affiche switchboard_status. Ajoutez une autorisation pour chaque agent. Reprenez le même libellé d'espace de travail dans l'entrée de l'espace de travail et dans l'autorisation. Pour le manifeste réservé à votre compte, ajoutez user_only: true à côté de team_id. Retirez bot de identities. Définissez l'autorisation sur [user].
Redémarrez SwB quand connect le demande. L'agent peut vérifier chaque identité Slack avec slack_workspaces. Une identité est le bot ou votre compte.
Identifiants
| Jeton | Où Slack l'affiche | Format | Destination |
|---|---|---|---|
| Jeton de niveau application | Basic Information → App-Level Tokens | Commence par xapp- | Lien de saisie SwB |
| Jeton du bot | OAuth & Permissions → OAuth Tokens → Bot User OAuth Token | Commence par xoxb- | Lien de saisie SwB |
| Jeton utilisateur | OAuth & Permissions → OAuth Tokens → User OAuth Token | Commence par xoxp- | Lien de saisie SwB |
Vérifier la connexion
Relancez connect(what="slack") et vérifiez la présence de connected. Appelez slack_workspaces. Vérifiez que ready vaut true pour chaque identité et que connected vaut true pour l'espace de travail.
Avec un bot, mentionnez le bot dans un canal et ajoutez un nom de cible. Demandez à l'agent de consulter slack_events ou slack_wait. Pour tester une publication, utilisez slack_post depuis une identité qui a le droit d'écrire.
Résoudre les problèmes
Si SwB signale un problème de Socket Mode, ouvrez Socket Mode dans les paramètres de l'application. Activez Enable Socket Mode.
Si vous modifiez les portées de l'application, réinstallez-la. Enregistrez ensuite les nouveaux jetons avec un nouveau lien de saisie.
La recherche avec slack_search passe par votre propre compte. Elle nécessite le jeton utilisateur avec la portée search:read.