Oscar connects to Slack as an app with a bot user. It uses Socket Mode (a websocket Oscar opens) for messages and button presses, and the Web API for everything it sends. No public address, request URL or open port is needed.
Set it up
- Create the app from a manifest. Open
api.slack.com/apps, Create New App →
From a manifest, pick your workspace, and paste:What the scopes are for: reading mentions and the messages in channels, private channels, direct messages and group messages Oscar is in (
display_information: name: Oscar description: Oscar Agent features: bot_user: display_name: Oscar always_online: true app_home: messages_tab_enabled: true messages_tab_read_only_enabled: false oauth_config: scopes: bot: - app_mentions:read - channels:history - groups:history - im:history - mpim:history - chat:write - files:read - files:write - reactions:write - users:read settings: event_subscriptions: bot_events: - app_mention - message.channels - message.groups - message.im - message.mpim interactivity: is_enabled: true org_deploy_enabled: false socket_mode_enabled: true token_rotation_enabled: false*:history); posting and editing its own messages (chat:write); reading files you send and uploading files (files:read,files:write); the 👀/✅ marks (reactions:write); and people's display names, when a message does not carry them (users:read; without it Oscar names them by member id). If you only want Oscar to answer mentions, you can leave outchannels:history,groups:historyand the matchingmessage.channelsandmessage.groupsevents. It then sees only messages that mention it, so free-response channels and follow-ups in threads without a mention no longer work. - Install it and copy the bot token. Install App (or OAuth &
Permissions → Install to Workspace), allow it, then copy the Bot
User OAuth Token (
xoxb-…). - Make an app-level token. Basic Information → App-Level
Tokens → Generate Token and Scopes, add the
connections:writescope, generate, and copy the token (xapp-…). Socket Mode connects with it. Put both tokens into$OSCAR_HOME/credentials.env(mode 0600):Oscar refuses a token of the wrong kind in either place and says which one goes where.SLACK_BOT_TOKEN=xoxb-... SLACK_APP_TOKEN=xapp-... - Say who may talk to Oscar. In Slack, open your profile, then the
⋮ menu → Copy member ID:(comma-separated for several; also
SLACK_ALLOWED_USERS=U012AB3CDslack_allowed_usersinconfig.toml). Only member ids count: Slack display names are not unique. Or let the bot find you:oscar slack owner --add, then send the bot a direct message (oscar setupoffers the same). It listens over Socket Mode like the gateway, so stop a running gateway first (oscar gateway stop); while one holds the app-level token it refuses and says so. - Check it:
oscar slack probeprints the bot's name, its id and the workspace, whether the app-level token opens a Socket Mode connection, and who is allowed. - Run it:
oscar slack serve(Slack alone) oroscar gateway serve(every configured platform; see Chat gateways, also for running it as a service). - Talk to it: open the app under Apps in Slack's sidebar and send
it a direct message, or invite it to a channel (
/invite @Oscar) and mention it:@Oscar what changed in the last release?
Channels and threads
In channels Oscar answers only when mentioned. A mention at the top of a
channel is answered in a thread under your message; in a thread Oscar
started or answered in, and in a thread under one of its own messages (a
conversation handed over with /handoff slack, a scheduled job's result),
no mention is needed. Not in free-response channels, for ! commands, or
in slack_no_thread_channels. Oscar remembers the threads under your
messages while it runs: after a restart, mention it once in such an older
thread to pick it up again. A reply in the thread under a job's result
goes to the model with the result quoted before it. Messages from people not on the allowed
list are ignored in channels and told no in direct messages. A thread
counts as its channel for the lists below. The model sees who wrote each
message ([Yuri|U012AB3CD] …, the display name and member id).
| Variable (config key) | Meaning |
|---|---|
SLACK_REQUIRE_MENTION (slack_require_mention) |
false: answer every message in channels (default true); !mention on|off|default changes one channel |
SLACK_FREE_RESPONSE_CHANNELS (slack_free_response_channels) |
channel ids where every message is for Oscar |
SLACK_ALLOWED_CHANNELS (slack_allowed_channels) |
when set, the only channels Oscar answers in (direct messages are not affected) |
SLACK_IGNORED_CHANNELS (slack_ignored_channels) |
channels never answered in, even when mentioned |
SLACK_AUTO_THREAD (slack_auto_thread) |
false: answer a mention in the channel itself (default true) |
SLACK_NO_THREAD_CHANNELS (slack_no_thread_channels) |
channels answered in place even with threads on |
Channel ids: open the channel's details (click its name); the id (C…) is
at the bottom. A direct message's id starts with D.
A thread is a conversation of its own (replies stay in it). Its room is
<channel id>/<thread ts>, as in slack:C0123ABC/1700000000.000100 for
send_message and scheduled results. In a channel each person has a
conversation of their own unless slack_group_sessions = "shared" (see
rooms shared by several people).
A channel's own settings go in [rooms."slack:<channel id>"]; a thread
takes its channel's table unless it has one of its own.
What it looks like
- Commands are typed with
!(!new,!status,!stop; see Chat gateways). Slack keeps/for its own slash commands. - Replies are the model's Markdown turned into Slack's formatting (bold, italics, strikethrough, links, lists and code blocks; headings become bold lines), split under 3900 characters. Links are never unfurled: Slack would otherwise fetch every address a reply names.
- Approvals and questions come with buttons. A press from someone not on the list gets a reply only they can see; after a decision the buttons go and the decision is added to the message.
- While working, Oscar reacts 👀 and edits an activity message listing
each call with a short preview
(tool activity); then ✅ or ❌. A
message sent during a turn gets ⚡, ⏳ or ⏩. Slack has no typing
indicator for apps.
SLACK_REACTIONS=falseturns reactions off;SLACK_PROGRESS(off,new,all,verbose) or!verbosesets how much the activity message shows. - Voice clips, pictures, files, and spoken or picture replies: see
Voice, pictures and files. Files are fetched with the
bot token only from Slack's file host, up to 50 MB; uploads go up to
100 MB (
SLACK_UPLOAD_LIMIT_MB, configslack_upload_limit_mb, up to 1000). - Socket Mode does not replay events: a message sent while Oscar was not
connected is not answered. Slack refreshes connections every few hours:
Oscar opens the new connection before it closes the old one, so nothing
is missed; after a dropped connection it connects again at once,
waiting longer each time when connecting keeps failing. One app's events are shared between all its
open connections, so two gateways on this machine (another profile, say)
cannot share one
SLACK_APP_TOKEN: the second leaves Slack off.
Other settings
| Variable | Meaning |
|---|---|
SLACK_ALLOW_ALL_USERS=true |
answer everyone in the workspace (careful) |
SLACK_PAIRING=on (slack_pairing) |
strangers who write privately get a pairing code |
SLACK_ADMINS, SLACK_APPROVERS (slack_admins, slack_approvers) |
member ids: who may use the admin commands, who may answer approvals (roles) |
SLACK_HOME_CHANNEL (slack_home_channel) |
the channel a job or message goes to when only slack is named |
SLACK_PROXY |
Web API calls and the Socket Mode websocket through a proxy (see proxies) |
SLACK_API_URL |
another Web API base (tests) |