- It answers DMs and @mentions with your Agent.
- It shows each tool call in the thread and updates the status as the call runs.
- It asks for approval with buttons before a tool runs.
@cadenya/cadenya SDK.

The Agent's reply in a Slack thread. Each step of the agent loop shows its tool calls as a plan, and the final answer has feedback buttons.
Prerequisites
You need:- A Cadenya account.
- The Cadenya CLI. The next section installs it.
- A Slack workspace where you can install apps. Slack offers free developer sandboxes.
- The Slack CLI. Log in with
slack login. - Node.js 22 or later.
- ngrok, or another tunnel.
Install the Cadenya CLI
Install the CLI with Homebrew:development with the external ID of your workspace.
How it works
Slack and Cadenya do not connect to each other. Your app sits between them. It sends Slack messages to Cadenya, and it posts Cadenya’s webhook events to Slack. One Slack thread is one Objective. The app stores the link between them on the Objective:Set it up
Clone the example
Create the Agent
MODEL_ID to a model from cadenya models list:CADENYA_AGENT_ID in a later step.Set the Agent's webhook URL
3210, so start a tunnel to that port:/webhooks/cadenya to the end.Fill in .env
objectives:manage scope. This command prints the token. Cadenya shows it only when you create the key, so save it now.Run it
manifest.json and asks which workspace to install it in. The app uses Socket Mode, so Slack does not need a public URL.You should see:Send a message

An approval request in the thread. This one is for the Faker server's GenerateCurseWord tool.
GetFakerOptions first. If that happens, approve that call too.To continue the conversation, reply in the thread. The app sends each reply to the same Objective.How the code works
Most of the logic is in four files.Send a Slack message to Cadenya
The app builds an external ID from the Slack thread. If the thread already has an Objective, the app continues it. Otherwise, the app creates one. This is a shortened version ofcadenya/thread.js:
- Neither call waits for the Agent. Slack expects a response to each event within 3 seconds. An Agent that calls tools takes longer. The reply arrives later, on a webhook.
- Slack can send the same event twice. The second create fails with
409because the external ID exists, and the app ignores that error. - You can’t reuse an external ID, even after its Objective ends. If someone replies in a thread whose Objective has ended, the app creates a new Objective. Its external ID is
<external ID>-<message ts>, and the app finds it by label. enqueue: truequeues a message that arrives while the Agent is still working.
Receive webhooks
Bolt serves the webhook endpoint as a custom route. The route verifies the signature, then reads the Slack thread from the labels:http://localhost:4040. It lists each webhook with its headers and body, and it can replay one. This tool_result webhook shows the Slack labels and the external ID on data.objective:

A tool result webhook in the ngrok inspector. The Objective's labels name the Slack team, channel, thread, and user.
unwrapneeds the raw request body. Read the body before any code parses it as JSON.- Cadenya retries a failed delivery. The route stores each
webhook-idit has processed and skips repeats. - A webhook from a sub-agent includes
rootObjective. The app uses its labels, so the event goes to the thread that started the work.
Show tool calls as a plan
Events from the same step of the agent loop have the sameiterationId. One step is an assistant message plus the tool calls it requested. The app uses iterationId to group events into one Slack message.
For each iteration, the app starts a Slack message with chat.startStream in plan mode. Then it appends a chunk for each webhook. This is a simplified version of cadenya/thread-renderer.js:
task_update as a task in a plan block. The task ID is the tool call ID, so a second update changes the status of the same task.
When every tool call in the iteration has finished, the app stops the stream. The final answer also gets feedback buttons.
The app uses a Slack stream because chat.appendStream lets several webhooks add to one message. The reply text still arrives all at once. Cadenya sends text deltas on the event stream, not on webhooks.
A few details:
- Webhooks for one Objective can arrive at the same time, or out of order. For example, a
toolCalledwebhook can arrive before theassistantMessagethat requested the call. The app processes one event at a time for each Objective. It never changes a finished task back to in progress. - Slack closes a stream after 10 minutes. An approval can take longer than that. If the stream has closed, the app continues in a new message.
- Tool calls from a sub-agent do not appear in the plan. Its approval requests and errors still appear in the thread.
Approve or deny a tool call
Slack has no built-in approval step. The app posts Block Kit buttons and puts the Objective ID and tool call ID in each button’svalue. When someone clicks a button, the handler reads the IDs back:
memo when a call is denied, so write it as an instruction to the model.
The feedback buttons work the same way. A click calls objectives.createFeedback with a score of 1 or -1. Cadenya uses feedback to choose between variations.
Let the Agent act in Slack
The Faker tools run on a remote server. A client tool runs in your app instead. Your app has the Slack token, so a client tool can call the Slack API. The example defines one client tool,add_emoji_reaction, in cadenya/client-tools.js. The app passes the definition to objectives.create:
toolCalled webhook. The app calls Slack’s reactions.add, then returns the result with objectives.setToolCallContent.
You can add your own client tools the same way. For example, a tool can pin a message or look up a user. A client tool can do anything your bot token allows.
Before you deploy
The example is small on purpose. Change three things before you run it in production:- Use a stable URL. Host the app at a permanent address and update the Agent’s webhook URL. You can keep Socket Mode, unless you plan to list the app in the Slack Marketplace. The Marketplace requires HTTP.
- Store state outside the process. The app keeps two things in memory: the
webhook-idvalues it has processed, and the open Slack message for each iteration. If you run more than one process, move both to a shared store. Use a unique constraint onwebhook-id, and store each stream’stsbyiterationId. - Support more than one Slack workspace. The app uses one bot token. To serve several workspaces, add Bolt’s OAuth installation store. Then choose the token with the
slack_teamlabel.
See the conversation in Cadenya
As always, Cadenya stores the entire history of the conversation. Open the Objective in the dashboard to see each message, tool call, and approval on a timeline. The External ID in the details panel is the one the app built from the Slack thread.
The Objective for the approval example. The timeline shows the approval request, who approved it, and the tool call that followed.
Where to go next
- To connect the Agent to your own API, create a Tool Set.
- For suggested prompts, status, and streaming in Slack, see Slack’s guide to developing agents.