Tracecat Slackbot Best Practices
When To Use
Use this skill only for Slack-facing Tracecat automations: Slack bots, app mentions, Slack interactivity, button callbacks, thread replies, message reads, Slack event subscriptions, or Slack smoke tests.
For generic Tracecat workflow, table, run-python, or agent-preset guidance, use $tracecat-automation-best-practices instead.
Bot Architecture
Build Slack bots with ai.agent or ai.preset_agent.
- Use inline
ai.agent when the Slack behavior is specific to one workflow and should travel with that workflow.
- Use
ai.preset_agent when the bot persona, tools, and instructions should be reusable across workflows.
- Give the agent Slack send/post message tools plus list/read message or reply tools when it needs thread context.
- Fetch the Slack thread before invoking the agent, and tell the agent that thread context is required input.
- Post visible replies back to the original channel and thread. Do not answer only in the agent transcript.
The agent owns the message — composition and posting. Composing or sending a Slack
message is agentic work, not data plumbing. Reserve deterministic nodes for data plumbing
around the agent (fetching the thread, redacting, upserting state).
- WRONG: a
core.script.run_python or core.http_request node formats the text and posts to
Slack, and the agent only returns a string. This buries the wording in a script, makes
Block Kit and tone hard to iterate, and splits responsibility.
- RIGHT: the agent is given the Slack send/reply tool and owns both composing the message
(mrkdwn/Block Kit, tone) and posting it to the original thread, per its instructions.
If a deterministic step formats the agent's output for Slack, that is the smell — move the
formatting and posting into the agent.
The same rule holds for Microsoft Teams, any other chatops surface, and for opening or
commenting on a case: give the agent the tool and let the side effect be the output. The
general form is in
agent-outputs.
Prefer the model object for ai.agent; top-level model_name and model_provider are deprecated unless the user explicitly asks for the legacy shape.
args:
model:
model_name: claude-sonnet-4-6
model_provider: anthropic
Slack App Setup
For setup:
- Configure the Tracecat workflow webhook.
- Add the webhook to Slack interactivity at
https://api.slack.com/apps/{app_id}/interactive-messages.
- For @mention back-and-forth chat, configure Slack event subscriptions for app mentions and put the webhook URL in Slack with
?echo=true appended for reliable mention-thread loops.
Typical event handling:
- Receive Slack
event_callback for app_mention.
- Extract
event.channel, event.ts, event.thread_ts || event.ts, event.user, and event.text.
- Add a lightweight processing reaction if desired.
- Fetch the whole Slack thread with a Slack list replies/messages tool.
- Build an agent prompt that includes the sanitized thread JSON.
- Invoke the agent.
- Remove the processing reaction after the agent finishes.
Interactivity
For Slack buttons and block actions:
- Parse the
payload string when Slack sends URL-encoded interactivity.
- Extract
actions[0].action_id, actions[0].value, channel.id, message.ts, message.thread_ts || message.ts, and user.id.
- Button clicks should post a visible thread reply unless the product requirement is to update the original message.
- Do not add or remove reactions for button clicks unless the workflow explicitly requires it.
Prompting Rules
Slack-facing agents need explicit production posting rules in their own instructions:
- Always post to the original Slack channel and thread.
- Use Slack mrkdwn, not generic Markdown, when posting text.
- Use Block Kit only when the response needs buttons, links, compact review layout, or structured blocks.
- Use a reasonable, calm, critical tone. Keep risk language grounded in evidence rather than inflated.
- Prefer positive, preferred-vocabulary instructions over avoid-word blocklists. Naming the exact words to avoid (e.g. "suspicious", "critical", "breach") seeds those tokens into context and can prime them; instead state the phrasing you want and require risk claims to be evidence-backed.
- State each rule once. Don't restate rules in a large end-of-prompt validation checklist — duplication bloats the prompt and drifts out of sync.
- Avoid emojis unless they make the point clearer or are part of a deliberate lightweight status convention.
- Keep style rules in the preset or
ai.agent instructions. The agent reads its own instructions, not repo files.
- If a Slack post fails, return a concise failure reason and enough context for workflow debugging.
For message shapes, Block Kit layouts, and the mrkdwn rules to encode in those instructions,
see message-style.
Testing
After publishing a Slack-facing automation, do a live smoke test:
- Send a normal Slack message that mentions the bot.
- Confirm the bot posts a visible reply in the original thread.
- Confirm the Tracecat run was
trigger_type: webhook and execution_type: published.
- Inspect the execution timeline and failed action payloads with Tracecat MCP if the reply is missing or delayed.
- Confirm processing reactions are cleaned up after completion.
Do not paste secret-bearing Slack payloads or Tracecat action outputs into docs or chat. Summarize routing, status, action refs, timing, and non-sensitive behavior.
1---2name: tracecat-slackbot-best-practices3description: Use when building, editing, validating, or debugging Tracecat Slack bots and Slack-facing automations through Tracecat MCP, including Slack app mentions, interactive messages, event subscriptions, webhooks, thread replies, Slack tools, ai.agent or ai.preset_agent bots, Slack tone, and Slack smoke tests.4---56# Tracecat Slackbot Best Practices78## When To Use910Use this skill only for Slack-facing Tracecat automations: Slack bots, app mentions, Slack interactivity, button callbacks, thread replies, message reads, Slack event subscriptions, or Slack smoke tests.1112For generic Tracecat workflow, table, run-python, or agent-preset guidance, use `$tracecat-automation-best-practices` instead.1314## Bot Architecture1516Build Slack bots with `ai.agent` or `ai.preset_agent`.1718- Use inline `ai.agent` when the Slack behavior is specific to one workflow and should travel with that workflow.19- Use `ai.preset_agent` when the bot persona, tools, and instructions should be reusable across workflows.20- Give the agent Slack send/post message tools plus list/read message or reply tools when it needs thread context.21- Fetch the Slack thread before invoking the agent, and tell the agent that thread context is required input.22- Post visible replies back to the original channel and thread. Do not answer only in the agent transcript.2324**The agent owns the message — composition and posting.** Composing or sending a Slack25message is agentic work, not data plumbing. Reserve deterministic nodes for data plumbing26around the agent (fetching the thread, redacting, upserting state).2728- WRONG: a `core.script.run_python` or `core.http_request` node formats the text and posts to29 Slack, and the agent only returns a string. This buries the wording in a script, makes30 Block Kit and tone hard to iterate, and splits responsibility.31- RIGHT: the agent is given the Slack send/reply tool and owns both composing the message32 (mrkdwn/Block Kit, tone) and posting it to the original thread, per its instructions.3334If a deterministic step formats the agent's output for Slack, that is the smell — move the35formatting and posting into the agent.3637The same rule holds for Microsoft Teams, any other chatops surface, and for opening or38commenting on a case: give the agent the tool and let the side effect be the output. The39general form is in40[agent-outputs](../tracecat-automation-best-practices/references/agent-outputs.md).4142Prefer the `model` object for `ai.agent`; top-level `model_name` and `model_provider` are deprecated unless the user explicitly asks for the legacy shape.4344```yaml45args:46 model:47 model_name: claude-sonnet-4-648 model_provider: anthropic49```5051## Slack App Setup5253For setup:5455- Configure the Tracecat workflow webhook.56- Add the webhook to Slack interactivity at `https://api.slack.com/apps/{app_id}/interactive-messages`.57- For @mention back-and-forth chat, configure Slack event subscriptions for app mentions and put the webhook URL in Slack with `?echo=true` appended for reliable mention-thread loops.5859Typical event handling:60611. Receive Slack `event_callback` for `app_mention`.622. Extract `event.channel`, `event.ts`, `event.thread_ts || event.ts`, `event.user`, and `event.text`.633. Add a lightweight processing reaction if desired.644. Fetch the whole Slack thread with a Slack list replies/messages tool.655. Build an agent prompt that includes the sanitized thread JSON.666. Invoke the agent.677. Remove the processing reaction after the agent finishes.6869## Interactivity7071For Slack buttons and block actions:7273- Parse the `payload` string when Slack sends URL-encoded interactivity.74- Extract `actions[0].action_id`, `actions[0].value`, `channel.id`, `message.ts`, `message.thread_ts || message.ts`, and `user.id`.75- Button clicks should post a visible thread reply unless the product requirement is to update the original message.76- Do not add or remove reactions for button clicks unless the workflow explicitly requires it.7778## Prompting Rules7980Slack-facing agents need explicit production posting rules in their own instructions:8182- Always post to the original Slack channel and thread.83- Use Slack mrkdwn, not generic Markdown, when posting text.84- Use Block Kit only when the response needs buttons, links, compact review layout, or structured blocks.85- Use a reasonable, calm, critical tone. Keep risk language grounded in evidence rather than inflated.86- Prefer positive, preferred-vocabulary instructions over avoid-word blocklists. Naming the exact words to avoid (e.g. "suspicious", "critical", "breach") seeds those tokens into context and can prime them; instead state the phrasing you want and require risk claims to be evidence-backed.87- State each rule once. Don't restate rules in a large end-of-prompt validation checklist — duplication bloats the prompt and drifts out of sync.88- Avoid emojis unless they make the point clearer or are part of a deliberate lightweight status convention.89- Keep style rules in the preset or `ai.agent` instructions. The agent reads its own instructions, not repo files.90- If a Slack post fails, return a concise failure reason and enough context for workflow debugging.9192For message shapes, Block Kit layouts, and the mrkdwn rules to encode in those instructions,93see [message-style](references/message-style.md).9495## Testing9697After publishing a Slack-facing automation, do a live smoke test:98991. Send a normal Slack message that mentions the bot.1002. Confirm the bot posts a visible reply in the original thread.1013. Confirm the Tracecat run was `trigger_type: webhook` and `execution_type: published`.1024. Inspect the execution timeline and failed action payloads with Tracecat MCP if the reply is missing or delayed.1035. Confirm processing reactions are cleaned up after completion.104105Do not paste secret-bearing Slack payloads or Tracecat action outputs into docs or chat. Summarize routing, status, action refs, timing, and non-sensitive behavior.