slack-bot
Send messages and rich content to Slack channels via webhooks or Bot API. Use Block Kit for formatted announcements, marketing reports, and community updates. Trigger phrases: "post to slack", "slack message", "slack webhook", "slack notification", "slack announcement", "send to slack", "slack marke
By openclaudia · 389 installs
npx skills add openclaudia/openclaudia-skills --skill slack-bot
Source repository · Upstream listing
Slack Bot
Send messages and rich content to Slack channels using Incoming Webhooks or the Slack Web API.
Build formatted announcements, marketing reports, metrics dashboards, and community updates
with Block Kit.
Prerequisites
Requires either SLACK WEBHOOK URL or SLACK BOT TOKEN set in .env , .env.local , or
~/.claude/.env.global .
If neither variable is set, instruct the user to follow the Setup Guide section below.
Setup Guide
Option A: Incoming Webhook (Simple)
Incoming Webhooks are the fastest way to post messages. They require no OAuth scopes and are
scoped to a single channel.
1. Go to https://api.slack.com/apps and click Create New App From scratch .
2. Name the app (e.g., "Marketing Bot") and select your workspace.
3. In the left sidebar, click Incoming Webhooks and toggle it On .
4. Click Add New Webhook to Workspace at the bottom.
5. Select the channel to post to and click Allow .
6. Copy the Webhook URL (starts with https://hooks.slack.com/services/... ).
7. Add it to your environment:
Limitations: One webhook per channel. Cannot read messages, list channels, or reply to
threads programmatically (you must know the thread ts from a prior API response).
Option B: Bot Token (Full Featured)
Bot tokens give access to the full Slack Web API: post to any channel the bot is in, reply to
threads, list channels, upload files, and more.
1. Go to https://api.slack.com/apps and click Create New App From scratch .
2. Name the app and select your workspace.
3. In the left sidebar, click OAuth & Permissions .
4. Under Bot Token Scopes , add these scopes:
chat:write Post messages
chat:write.public Post to channels without joining
channels:read List public channels
files:write Upload files (optional, for images/reports)
reactions:write Add emoji reactions (optional)
5. Click Install to Workspace at the top and authorize.
6. Copy the Bot User OAuth Token (starts with xoxb ).
7. Add it to your environment:
8. Invite the bot to the channels it should post in: type /invite @YourBotName in each channel.
Optional: Set a default channel for convenience:
Method 1: Incoming Webhooks
Send a Simple Text Message
Send a Message with Username and Icon Override
Send a Message with Block Kit (Webhook)
Method 2: Slack Web API (Bot Token)
The Web API provides full control over message delivery, threading, channel management, and more.
API Base
All requests go to https://slack.com/api/ with the header Authorization: Bearer {SLACK BOT TOKEN} .
Post a Message to a Channel
The response includes a ts (timestamp) field which identifies the message. Save this value
for threading replies:
Reply to a Thread
Use the thread ts parameter to reply inside an existing thread:
To also broadcast the reply to the channel (so it appears in the main conversation as well),
add "reply broadcast": true .
Update an Existing Message
Delete a Message
List Public Channels
Useful for discovering which channel to post to:
Upload a File to a Channel
Add an Emoji Reaction
Slack Block Kit Reference
Block Kit is Slack's UI framework for building rich, interactive messages. Messages are composed
of an array of blocks, each with a specific type and structure.
Block Types
Block Type Purpose Supports mrkdwn
header Large bold title text No (plain text only)
section Primary content block with text and optional accessory Yes
divider Horizontal line separator N/A
image Full width image with alt text N/A
context Small, muted text and images (for metadata, timestamps) Yes
actions Row of interactive elements (buttons, selects, date pickers) N/A
rich text Advanced formatted text (lists, quotes, code blocks) N/A
Header Block
Section Block
Plain text section:
Section with fields (two column layout):
Section with a button accessory:
Section with an image accessory:
Divider Block
Image Block
Context Block
Actions Block (Buttons)
Button styles: "primary" (green), "danger" (red), or omit for default (gray).
Note on interactivity: Buttons with action id (no url ) require a Request URL configured
in your Slack App settings under Interactivity & Shortcuts to receive the button click
payload. Buttons with a url field open the link directly and do not require a backend.
Block Kit Limits
Limit Value
Blocks per message 50
Characters per text block 3,000
Characters per header 150
Fields per section 10
Elements per actions block 25
Elements per context block 10
Block Kit Builder
Use the visual builder to design and preview messages before coding them:
https://app.slack.com/block kit builder
Slack mrkdwn Formatting Guide
Slack uses its own markdown variant called mrkdwn. It differs from standard Markdown in
several ways.
Formatting Syntax Example
Bold text bold text
Italic text italic text
Strikethrough ~text~ ~strikethrough~
Code (inline) text inline code
Code block Multi line code block
Blockquote text Quoted text
Link <https://url\ display text Clickable link
User mention <@U0123456 @username
Channel mention < C0123456 channel
Emoji :emoji name: :rocket:
Bulleted list Start line with or Bullet point
Numbered list Start line with 1. Numbered item
Line break \n in JSON string New line
Important differences from standard Markdown:
Bold uses single asterisks bold , not double bold .
Italic uses underscores italic , not single asterisks.
Links use <url text format with a pipe, not [text](url) .
Headers do not exist in mrkdwn. Use the header block type instead.
Images cannot be inlined in mrkdwn. Use the image block or accessory instead.
Message Templates
Template 1: Product Announcement
Template 2: Weekly Metrics Report
Template 3: Blog Post Share
Template 4: Team Update / Standup
Template 5: Incident / Urgent Notification
Workflows
Workflow 1: Post a Marketing Announcement
When the user asks to post an announcement, product update, or news to Slack:
1. Gather details Ask for the announcement title, body, link, image URL, and target channel.
2. Choose a template Select from the templates above or build a custom Block Kit payload.
3. Build the payload Construct the JSON with proper mrkdwn formatting.
4. Preview Show the user the full JSON payload and describe how it will render.
5. Confirm Ask the user to approve before sending.
6. Send Execute the curl command.
7. Report Show the API response. For Web API, capture the ts for threading.
Workflow 2: Post Weekly Metrics
When the user asks to send a metrics report or dashboard to Slack:
1. Collect metrics Ask for the numbers or help pull them from analytics tools.
2. Format with fields Use section blocks with fields for the two column metric layout.
3. Add context Include week over week comparisons with arrow emoji.
4. Add takeaways Summarize 2 3 key insights in a section block.
5. Include a dashboard link Add a button to the full analytics dashboard.
6. Send and thread Post the main report, then thread detailed breakdowns as replies.
Workflow 3: Share a Blog Post
When a new blog post needs to be distributed to the team:
1. Get the URL Ask for the blog post URL, or fetch the latest from the blog.
2. Extract metadata Use WebFetch to pull the title, description, author, and OG image.
3. Build the share message Use Template 3 with social amplification snippets.
4. Add share buttons Include Twitter and LinkedIn intent URLs pre populated with the post.
5. Post to the channel Send to the team marketing channel.
Workflow 4: Community Engagement
For managing Slack community channels (public communities, customer channels):
1. Welcome messages Post a welcome message with rules and resources when new members join.
2. Scheduled updates Post weekly roundups of popular discussions or new resources.
3. Event announcements Share upcoming webinars, AMAs, or meetups with RSVP buttons.
4. Polls and feedback Use actions blocks with buttons to collect quick feedback.
5. Thread management Reply to existing threads with updates or answers.
Sending Messages with Dynamic Content
Build Payloads with Shell Variables
Build Payloads from a JSON File
For complex messages, write the payload to a file first:
Scheduled Messages
Post a message at a specific future time using chat.scheduleMessage :
List scheduled messages:
Delete a scheduled message:
Multi Channel Posting
Post the same message to multiple channels:
Error Handling
Common API Errors
Error Cause Fix
invalid auth Bad or expired token Regenerate the bot token in Slack App settings
channel not found Bot not in channel or wrong channel name Invite bot with /invite @BotName or use channel ID
not in channel Bot needs to join the channel first Invite the bot or use chat:write.public scope
too many attachments Over 50 blocks Split the message into multiple posts or thread replies
msg too long Text exceeds 40,000 characters Shorten the message or split into parts
rate limited Too many requests Wait the number of seconds in the Retry After header
missing scope Token lacks required permission Add the scope in OAuth & Permissions and reinstall the app
Validate a Response
A more robust approach using a temp file:
Tips
Always include a text field alongside blocks — it serves as the fallback for
notifications, accessibility readers, and clients that do not support Block Kit.
Use the Block Kit Builder at https://app.slack.com/block kit builder to visually design
and preview messages before building the curl commands.
For production workflows, use chat.postMessage (Web API) over webhooks. It returns a
message ts you can use for threading, updating, and deleting.
Thread long reports. Post a summary as the parent message and details as threaded replies
to keep channels clean.
Use :emoji: codes in plain text fields with "emoji": true to render emoji in headers
and button labels.
Escape special characters in mrkdwn: & becomes & , < becomes < , becomes > .
Rate limits: Slack allows roughly 1 message per second per channel. For bulk posting, add a
1 second delay between requests.
When posting metrics, use section fields for the two column layout rather than trying to
format tables in mrkdwn (Slack does not support tables).
Always show the user the full message payload and ask for confirmation before posting.