provider="slack"Connect Slack
Let your Python automations post, read channels and look up people as the Slack user who runs them, through your own Slack app.
The slack preset signs people in with a user token, so a run acts as the person who started it: messages are posted as them, and they only see the channels they're in.
Declare the connection
from callables import Connection, Group
slack = Connection("slack", provider="slack", scopes=["chat:write", "channels:read"])
team = Group("slack", title="Slack", connections=[slack])Call the Slack Web API with slack.token:
import requests
@team.deploy(title="Post a message")
def post(channel: str, text: str) -> str:
"""Posts a message as you."""
resp = requests.post("https://slack.com/api/chat.postMessage",
headers={"Authorization": f"Bearer {slack.token}"},
json={"channel": channel, "text": text}).json()
if not resp.get("ok"):
raise RuntimeError(f"Slack said: {resp.get('error')}")
return f"Posted to {channel}."Slack answers HTTP 200 even when a call fails, so check ok in the response.
Set up the Slack app
- At api.slack.com/apps, click Create New App → From scratch, and pick your workspace.
- Under OAuth & Permissions → Redirect URLs, add
https://callables.app/connections/callback. - On the same page, add your scopes under User Token Scopes (not Bot Token Scopes), matching
scopesin your code. - From Basic Information, copy the Client ID and Client Secret into your project's secrets as
SLACK_CLIENT_IDandSLACK_CLIENT_SECRET, or the names you giveclient_id=Secret(...)andclient_secret=Secret(...).
| You want to | User token scope |
|---|---|
| Post messages | chat:write |
| List public channels | channels:read |
| Read public channel history | channels:history |
| Look up people | users:read, users:read.email |
Testing locally
Slack expects redirect URLs to use https, so call connect's http://localhost address may be refused. If it is, test from the web app, or put a user token you already have in .env as SLACK_ACCESS_TOKEN: call local uses it directly.
A full step-by-step Slack guide is on its way. Until then, the connections docs cover how connections work.
Run your scripts on each person's own account
Declare a connection, push, and share. Everyone connects once and every run uses their account.