微算力 · API 导航与自营网关
API 接入 EN
未登录登录
💬

Slack 消息自动化,一键触达团队

Slack Automator · v4.0.0
效率 安全 B 级 作者 xueyetianya 公开目录收录
1.2k 下载 0 安装 3.3k 收藏 14 浏览

简介

通过 Incoming Webhook 自动化 Slack 消息发送、频道通知与定时任务,支持模板变量与历史记录导出,适合 DevOps 团队集成。

原始描述

Automate Slack messaging, channels, and search with Block Kit. Use when sending scheduled messages, syncing channels, monitoring chats, notifying teams.

通过你的 Agent 添加

点「快速安装」复制一段指令,粘给你正在用的 Agent(Claude Code、Codex、OpenClaw 等),它会自己完成安装。

或者手动安装

Claude Codeunzip -o skill.zip -d ~/.claude/skills/slack-automator/
其它 Agent解压到它自己的 skills 目录,目录名用 slack-automator

包里是 SKILL.md 加作者附带的文件,解压后目录名就是技能名。 技能申请的权限由作者决定,装之前请确认它能读什么、能执行什么。

中文使用说明 来自收录源

核心功能与用法

slack-automator 是一款基于 Bash 的 Slack 自动化 CLI 工具,通过 Incoming Webhooks 实现消息推送、频道通知、定时任务与模板管理。核心功能包括:

  • 消息发送:send 发送普通文本,notify 定向推送到指定频道,format 支持多种 Slack mrkdwn 格式(粗体、代码块、列表等)。
  • 模板系统:template save 创建带 {{variable}} 占位符的模板,template use 实时替换变量发送,适合 CI/CD 流水线复用。
  • 定时任务:schedule add 支持 HH:MM 简写或完整 cron 表达式,任务存储于本地 JSON,需配合系统 cron 实现触发。
  • 数据管理:history 查看最近 20 条发送记录,stats 统计成功率与操作分布,export 支持 JSON/CSV/TXT 导出。
  • 配置管理:config 设置默认频道、用户名、emoji 图标,webhook URL 本地存储并部分脱敏展示。

显著优点

  1. 零依赖轻量化:仅依赖 bash 4.0+、curl 与 python3(用于 JSON 解析),无需复杂运行时。
  2. 模板化工作流:预定义部署、告警等模板,减少重复命令编写,提升 CI/CD 集成效率。
  3. 完整审计能力:本地持久化历史记录与统计,便于故障排查与合规审查。
  4. 灵活调度:支持 cron 表达式与简易时间格式,满足周期性通知需求。

潜在局限与风险

  • Webhook 单点依赖:仅支持 Incoming Webhooks,无法使用 Slack API 的完整功能(如搜索、频道管理、权限控制)。
  • 定时任务需外部触发:schedule 仅持久化配置,不内置守护进程,必须依赖系统 cron 或手动触发。
  • 本地明文存储:~/.slack-automator/config.json 以明文保存 webhook URL,若设备失陷存在泄露风险。
  • 无原生 OAuth:不支持 Slack 的 OAuth 权限体系,无法动态切换工作区或细粒度授权。

适合人群

  • DevOps/运维工程师:用于部署通知、监控告警的自动化推送。
  • 小型技术团队:无需复杂 Bot 开发,快速实现 Slack 集成。
  • CI/CD 流水线使用者:通过模板变量实现环境动态注入。

常规风险

  • Webhook URL 泄露:URL 具备发送权限,泄露后可能被滥用 spam。
  • 定时任务配置错误:cron 表达式语法错误可能导致任务未触发或高频误发。
  • 网络依赖:Slack 服务不可用或网络隔离时消息发送失败,需配合重试机制。

技能正文


version: "4.0.0" name: slack-automator description: "Automate Slack messaging, channels, and search with Block Kit. Use when sending scheduled messages, syncing channels, monitoring chats, notifying teams." author: BytesAgain homepage: https://bytesagain.com source: https://github.com/bytesagain/ai-skills

slack-automator

Send messages to Slack channels via Incoming Webhooks. Supports direct messaging, channel notifications, message templates with variable substitution, scheduled messages, formatting helpers, and full send history with export.

Requirements

  • bash 4.0+
  • curl (for HTTP requests to Slack)
  • python3 (for JSON handling — typically pre-installed)
  • Slack Incoming Webhook URL — see setup below

How to Get a Slack Webhook URL

  1. Go to https://api.slack.com/apps
  2. Click Create New App → From scratch
  3. Name it (e.g., "Automator") and select your workspace
  4. In the left sidebar, click Incoming Webhooks
  5. Toggle Activate Incoming Webhooks to On
  6. Click Add New Webhook to Workspace
  7. Select the channel to post to and click Allow
  8. Copy the webhook URL (starts with https://hooks.slack.com/services/...)

Setup

Configure the webhook URL before sending messages:

scripts/script.sh connect https://hooks.slack.com/services/T00000/B00000/xxxxxxxx

Verify connectivity:

scripts/script.sh webhook test

Commands

connect <webhook_url>

Save a Slack Incoming Webhook URL to local configuration. The URL is stored in ~/.slack-automator/config.json.

# Save your webhook URL
scripts/script.sh connect https://hooks.slack.com/services/T00000/B00000/xxxxxxxx
# ✅ Webhook URL saved.

send <message>

Send a plain text message to Slack via the configured webhook.

# Send a simple message
scripts/script.sh send "Hello from Slack Automator!"

# Send a message with emoji
scripts/script.sh send "🚀 Deployment complete — v2.1.0 is live!"

# Send multi-word messages
scripts/script.sh send Build succeeded, all 142 tests passing.

notify <channel> <message>

Send a message to a specific Slack channel. The channel name will be prefixed with # if not already present.

# Notify the alerts channel
scripts/script.sh notify alerts "⚠️ Server CPU at 95%!"

# Notify with # prefix (also works)
scripts/script.sh notify "#deployments" "v3.0.2 deployed to production"

# Notify the team channel
scripts/script.sh notify general "Standup in 5 minutes!"

schedule add <time> <message>

Add a scheduled message. Time can be in HH:MM format (converted to daily cron) or a full cron expression. Schedules are saved to ~/.slack-automator/schedule.json.

# Schedule a daily message at 9:00 AM
scripts/script.sh schedule add 09:00 "Good morning, team! ☀️"

# Schedule with cron expression (every Friday at 6 PM)
scripts/script.sh schedule add "0 18 * * 5" "Happy Friday! 🎉"

# Schedule hourly reminder
scripts/script.sh schedule add "0 * * * *" "Hourly status check"

Note: Schedules are saved locally. To actually trigger them, set up a cron job that runs slack-automator send with the scheduled messages.

schedule list

Display all scheduled messages with their IDs, cron expressions, and status.

scripts/script.sh schedule list
# === Scheduled Messages ===
#   ✅ [1710820800] 0 9 * * * — Good morning, team! ☀️
#   ✅ [1710820900] 0 18 * * 5 — Happy Friday! 🎉

schedule remove <id>

Remove a scheduled message by its ID.

scripts/script.sh schedule remove 1710820900
# ✅ Removed schedule 1710820900.

template list

List all saved message templates.

scripts/script.sh template list
# === Message Templates ===
#   📝 deploy — 🚀 Deployed *{{service}}* to production.
#   📝 alert — ⚠️ Alert: {{message}} (severity: {{level}})

template save <name> <message>

Save a reusable message template. Use {{variable}} placeholders for dynamic values.

# Save a deploy notification template
scripts/script.sh template save deploy "🚀 Deployed *{{service}}* to production ({{version}})."

# Save an alert template
scripts/script.sh template save alert "⚠️ {{level}}: {{message}}"

# Save a welcome template
scripts/script.sh template save welcome "👋 Welcome to the team, {{name}}!"

template use <name> [var=value ...]

Send a message using a saved template. Variables in {{var}} are replaced with provided var=value pairs.

# Use deploy template with variables
scripts/script.sh template use deploy service=api-server version=v2.1.0
# Sends: 🚀 Deployed *api-server* to production (v2.1.0).

# Use alert template
scripts/script.sh template use alert level=HIGH message="Database connection timeout"

# Use welcome template
scripts/script.sh template use welcome name=Alice

webhook test

Send a test message to verify webhook connectivity. The test message includes a timestamp.

scripts/script.sh webhook test
# Testing webhook connectivity...
# ✅ Webhook is working! Test message sent.

webhook info

Show the current webhook configuration. The URL is partially masked for security.

scripts/script.sh webhook info
# === Webhook Configuration ===
#   URL: https://hooks.slack.com/services/T0...xxxxxxxx
#   Full URL stored in: ~/.slack-automator/config.json

format <style> <message>

Format a message using Slack's mrkdwn syntax and optionally send it. Available styles:

Style Slack Syntax Example Output
bold *text* text
italic _text_ text
code `text` text
codeblock ```text``` code block
quote > text quoted text
strike ~text~ text
list • item bulleted list
# Format as bold
scripts/script.sh format bold "Important announcement"
# Output: *Important announcement*

# Format as code block
scripts/script.sh format codeblock "const x = 42;"
# Output: ```const x = 42;```

# Format comma-separated items as bullet list
scripts/script.sh format list "Task 1, Task 2, Task 3"
# Output:
# • Task 1
# • Task 2
# • Task 3

history

Show the 20 most recent messages from the send history, including timestamps, actions, status, and channels.

scripts/script.sh history
# === Message History ===
#   ✅ [2025-03-19 09:00:00] send: Good morning, team!
#   ✅ [2025-03-19 09:15:30] notify → #alerts: CPU alert cleared
#   ❌ [2025-03-19 10:00:00] send: Failed message (webhook down)
#   Total: 42 message(s)

stats

Show usage statistics including message counts, success rate, action breakdown, and date range.

scripts/script.sh stats
# === Slack Automator Stats ===
#   Messages sent:    42
#   Successful:       40
#   Failed:           2
#   Success rate:     95.2%
#   Scheduled:        3
#   Templates:        5
#
#   Actions breakdown:
#     send: 30
#     notify: 8
#     template-use: 4
#
#   Period: 2025-01-15 → 2025-03-19

export <format>

Export message history to a file. Supported formats: json, csv, txt.

# Export as JSON
scripts/script.sh export json
# ✅ Exported history to ~/.slack-automator/export.json

# Export as CSV (for spreadsheets)
scripts/script.sh export csv
# ✅ Exported 42 entries to ~/.slack-automator/export.csv

# Export as plain text
scripts/script.sh export txt

config [key] [value]

View or set configuration values. Available keys: webhook_url, default_channel, username, icon_emoji.

# View all configuration
scripts/script.sh config
# === Slack Automator Configuration ===
#   webhook_url = https://hooks.slack.com/...
#   default_channel = #general

# Set a specific value
scripts/script.sh config default_channel "#engineering"
# ✅ Set default_channel = #engineering

# Get a specific value
scripts/script.sh config default_channel
# default_channel = #engineering

help

Print usage information and the list of all available commands.

scripts/script.sh help

version

Print the current version string.

scripts/script.sh version
# slack-automator v3.0.2

Data Storage

All data is stored in ~/.slack-automator/:

File Purpose
config.json Webhook URL and settings
history.json Complete message send history
schedule.json Scheduled messages
templates/ Saved message templates (.txt)

Examples

Quick Start

# 1. Connect your webhook
scripts/script.sh connect https://hooks.slack.com/services/T00/B00/xxx

# 2. Test it works
scripts/script.sh webhook test

# 3. Send your first message
scripts/script.sh send "Hello, Slack! 👋"

CI/CD Integration

# Save a deploy template
scripts/script.sh template save deploy "🚀 *{{service}}* deployed to *{{env}}* ({{version}})"

# Use it in your pipeline
scripts/script.sh template use deploy service=web-app env=production version=v1.2.3

Monitoring Alerts

# Direct alert to a channel
scripts/script.sh notify alerts "🔴 Database connection pool exhausted — 0/50 available"

# Formatted alert
scripts/script.sh format bold "CRITICAL: Payment service unreachable"

Powered by BytesAgain | bytesagain.com | hello@bytesagain.com

正文来自原始发布页, 版权归作者所有,许可未标注。 权利人认为有不妥,可申请下架。

标签

slackautomationwebhookci-cdmessagingbashdevopsmonitoring

同类 Skill