How to connect a Slack agent
This guide connects a Slack app to your Agent over Socket Mode: someone messages the app, the app answers with your agent’s reply, and the conversation is remembered across messages.
Like Discord, Slack Socket Mode works differently from webhook channels like Telegram. Instead of Slack posting to a public URL, Publicus dials out to Slack and holds a persistent connection. You don’t need a public inbound URL, but the gateway service must be running.
Socket Mode uses two tokens: an app-level token (xapp-…) to open the connection, and a bot token (xoxb-…) that identifies your app. Publicus posts the agent’s answers with the same bot token, in whichever channel or direct message the message came from.
When you build with the AI builder, it opens the same setup as a card in the chat, and carries on by itself once the app is ready.
Prerequisites
Section titled “Prerequisites”- A Slack workspace where you can install an app.
- An LLM provider key for the Agent (for example an OpenAI key).
- The Publicus gateway service running. It maintains channel connections; in a standard deployment it runs alongside the queue workers.
1. Create the bot
Section titled “1. Create the bot”Go to Chat apps, choose New bot and then Slack bot, and save the form it opens, with Channel already set to Slack. Then press Check the bot on its page. This is the app’s setup, and the next step happens there.




2. Create the Slack app from the setup
Section titled “2. Create the Slack app from the setup”- Press Create the Slack app. Slack opens with the app’s settings already filled in: Socket Mode, the events it hears and the permissions it needs. Pick your workspace and press Create.
- In the app’s Basic Information → App-Level Tokens, press Generate Token and Scopes, add the
connections:writescope, and copy the token. It starts withxapp-. - In Install App, install the app to your workspace and copy the Bot User OAuth Token. It starts with
xoxb-. - Paste both tokens in the setup and press Save. Publicus checks each with Slack, keeps them in your workspace’s secrets, and switches the bot on.
- Under Where it listens, pick the channels the app should listen in, then press Save where it listens. The app joins a public channel you pick by itself. In a private channel, type
/invite @your-appthere. A message in any other channel, or a direct message, is ignored, and a message in a thread counts as its channel. Leave it empty to listen everywhere the app is.
The setup asks Slack again every few seconds until the app is ready. Each check that still fails says what to do.
The Chat app section of the bot sets what the app does around each answer: reply in the chat, answer in a thread under the message, and record a thumbs up or down as feedback are on by default. Showing the agent’s progress and approving steps in the chat are off until you turn them on.
When the agent asks a question, the app posts it under the answer. A question with a few short answers gets a button for each. One that needs a form gets Fill in the form, which sends whoever presses it a link to the form that only they see, for an hour. Who answers forms, in the same Chat app section, changes that: Anyone in the chat puts the link in the question for everyone there, and Workspace members lets only members of your workspace answer. A member whose Slack account is linked in Publicus answers without signing in. Replying in the chat answers the question too.
3. Build the flow
Section titled “3. Build the flow”The quickest route is the Slack support agent template, or Connect a channel on an agent’s card under Agents, which binds the agent to this bot. To build the flow yourself:
-
Add a Gateway trigger node (under Triggers — start the flow). Pick the bot from step 1 in its settings, connect its trigger handle to Start, then click the node’s badge on the canvas and switch Active on. This routes the bot’s incoming messages into this flow.
-
The incoming message is available on
$start:Field Expression message text {{ $start->text }}conversation id {{ $start->externalConversationId }}sender id {{ $start->externalUserId }}conversation key {{ $start->conversationKey }}Only messages people write start the flow. Slack’s own channel messages, such as someone joining or a topic change, are ignored.
-
Wire
Start → Agent. On the Agent, setpromptto{{ $start->text }}and pick your LLM secret incredential. -
Connect a Chat Thread node to the Agent’s Memory handle, with
channel=slack,conversationId={{ $start->conversationKey }}, anduserId={{ $start->externalUserId }}. This gives the agent memory per Slack conversation.
You don’t need a node for the reply. The app posts the agent’s answer in the conversation the message came from, in a thread under the message when answering in a thread is on, and inside the thread when the message was already in one. An Agent node can change any of the bot’s chat options for itself in its own Chat app section.


A Channel / Slack send node after the agent turns the app’s own reply off, so the answer is never posted twice, and answering in a thread goes off with it. Add one only to post somewhere else, or to edit a message the flow sent earlier.
Voice messages. A clip recorded in Slack arrives with empty text. For the agent to hear it, do one of these (the template does the first):
- Set the Agent’s
attachmentsto{!! json_encode($start->attachments) !!}. - Tick Slack under Type voice notes into the message from on the AI models page’s Voice messages tab. Each clip is then transcribed when it arrives and becomes
$start->textfor every flow.
With both, the agent reads the transcript made on arrival, or Slack’s own when Slack made one, and the clip is paid for once. The bot’s Chat app section says which applies.
Verify it works
Section titled “Verify it works”-
The bot: on the bot’s page, Check the bot asks Slack whether both tokens work, whether the bot may post and read messages, whether it is in each channel it listens in, and whether its workspace is among those it listens in. The page’s heading says whether the gateway holds the connection open.
-
Delivery: a message to the app adds a row to the bot’s Received frames tab, under Chat apps.


-
Run: the message creates a completed run under Runs.
-
Reply: the agent’s answer appears in the Slack channel.
-
Memory: under Conversations, a thread exists for the conversation (keyed by the channel, conversation, and user). Send a follow-up that refers to an earlier message and confirm the agent remembers.
Troubleshooting
Section titled “Troubleshooting”-
The bot never connects: the bot’s page says why in a red line under its name, for example a token Slack refused. Otherwise confirm the gateway service is running, the app-level token secret holds a valid
xapp-…token with theconnections:writescope, and Socket Mode is on in the Slack app.

-
Messages never trigger a run, and the Received frames tab stays empty: if the connection is open, no events are arriving. Check that you subscribed to the right
message.*events and reinstalled the app afterwards, that the bot is a member of the channel you are messaging (/invite @your-app), and that you subscribed tomessage.imif you are sending a direct message. If you changed any of this after connecting, toggle the bot’s Active off and on to re-open the socket. A channel missing from Only in these channels is ignored the same way. -
Event Subscriptions asks for a Request URL: Socket Mode is off. Enable it under Settings → Socket Mode, then return to Event Subscriptions.
-
The run completes but no reply arrives: the bot token is missing the
chat:writescope, or the bot is not a member of the channel (/invite @your-app). A flow with a Channel / Slack send node after the agent posts only through that node. -
The agent answers a voice clip as if nothing was said: it got an empty message. See Voice messages in step 3.
-
The run fails: open the run under Runs for the error, commonly an empty secret or a memory node missing its
channel/conversationId.
Related
Section titled “Related”- Connect an agent to a chat channel — the channel overview.
- Connect a Discord agent — the other Socket Mode channel.
- Connect a Telegram agent — the webhook-based equivalent.
- Chat apps · Channel / Slack · Secrets · Chat Threads.