slack-operations

star 0

Slack API operations for messages, channels, threads, and notifications

rom-orlovich By rom-orlovich schedule Updated 1/26/2026

name: slack-operations description: Slack API operations for messages, channels, threads, and notifications user-invocable: false

Slack operations using Slack API.

Environment

  • SLACK_BOT_TOKEN - Slack bot token (xoxb-...)
  • SLACK_APP_TOKEN - Slack app token (xapp-...) for socket mode

Common Operations

Send Messages

# Simple message
curl -X POST https://slack.com/api/chat.postMessage \
  -H "Authorization: Bearer $SLACK_BOT_TOKEN" \
  -H "Content-Type: application/json" \
  -d '{"channel": "C123456", "text": "Hello from agent!"}'

# Message with blocks (rich formatting)
curl -X POST https://slack.com/api/chat.postMessage \
  -H "Authorization: Bearer $SLACK_BOT_TOKEN" \
  -H "Content-Type: application/json" \
  -d '{
    "channel": "C123456",
    "blocks": [{
      "type": "section",
      "text": {
        "type": "mrkdwn",
        "text": "*Deployment Complete* :white_check_mark:\nVersion 1.2.0 deployed"
      }
    }]
  }'

Reply to Threads

curl -X POST https://slack.com/api/chat.postMessage \
  -H "Authorization: Bearer $SLACK_BOT_TOKEN" \
  -H "Content-Type: application/json" \
  -d '{
    "channel": "C123456",
    "thread_ts": "1234567890.123456",
    "text": "Reply to thread"
  }'

List Channels

curl -X GET "https://slack.com/api/conversations.list" \
  -H "Authorization: Bearer $SLACK_BOT_TOKEN"

Send Direct Messages

# Open DM channel
curl -X POST https://slack.com/api/conversations.open \
  -H "Authorization: Bearer $SLACK_BOT_TOKEN" \
  -H "Content-Type: application/json" \
  -d '{"users": "U123456"}'

# Send DM
curl -X POST https://slack.com/api/chat.postMessage \
  -H "Authorization: Bearer $SLACK_BOT_TOKEN" \
  -H "Content-Type: application/json" \
  -d '{"channel": "D123456", "text": "Private message"}'

Message Formatting

  • *bold* - bold text
  • _italic_ - italic text
  • `code` - inline code
  • <@U123456> - Mention user
  • <#C123456> - Mention channel
  • <!channel> - Mention @channel

Notification Templates

See examples.md for deployment notifications, error alerts, and status updates.

Response Posting

Post Message (Generic)

# Post to channel
.claude/skills/slack-operations/scripts/post_message.sh \
    "C123456" \
    "Hello from agent!"

# Reply to thread
.claude/skills/slack-operations/scripts/post_message.sh \
    "C123456" \
    "Thread reply content" \
    "1234567890.123456"  # thread_ts

Python API

from core.slack_client import slack_client

# Post message
await slack_client.post_message(
    channel="C123456",
    text="Analysis results...",
    thread_ts="1234567890.123456"  # Optional
)

Agent Job Notifications

Automated notifications for Claude Code agent task lifecycle.

Environment Variables

  • SLACK_BOT_TOKEN - Required for API access
  • SLACK_NOTIFICATION_CHANNEL - Target channel (default: #ai-agent-activity)
  • SLACK_NOTIFICATIONS_ENABLED - Enable/disable notifications (default: true)

Job Start Notifications

Sent when an agent task begins processing (webhook tasks only).

# Send job start notification
.claude/skills/slack-operations/scripts/notify_job_start.sh \
    task-123 \
    jira \
    "analyze PROJ-456" \
    planning

# Parameters:
# 1. TASK_ID - Unique task identifier
# 2. SOURCE - Task source (jira, github, sentry, etc.)
# 3. COMMAND - Command being executed
# 4. AGENT - Agent handling the task (brain, planning, executor)

Job Completion Notifications

Sent when an agent task completes or fails.

# Successful completion
.claude/skills/slack-operations/scripts/notify_job_complete.sh \
    task-123 \
    completed \
    0.05 \
    "Analysis complete: Found 3 issues"

# Failed task
.claude/skills/slack-operations/scripts/notify_job_complete.sh \
    task-456 \
    failed \
    0.02 \
    "Authentication error"

# Parameters:
# 1. TASK_ID - Unique task identifier
# 2. STATUS - completed or failed
# 3. COST - Cost in USD
# 4. SUMMARY - Brief result summary

Notification Flow Integration

The task worker automatically sends notifications:

  1. Pre-job notification - When task moves to RUNNING state (webhook tasks only)
  2. Post-job notification - When task completes (success or failure)

No manual intervention required - notifications are sent automatically for all webhook-triggered tasks (Jira, GitHub, Sentry integrations).

Example Notification Output

🚀 Job Started
Source: Jira
Command: analyze PROJ-123
Task ID: task-abc123
Agent: planning

✅ Task Completed
Task ID: task-abc123
Summary: Analysis complete: Found authentication bug in login.py
Cost: $0.05

Response Posting (Webhook Tasks)

When a task originates from Slack (mention, slash command), post response back:

# Post response to originating Slack thread
post_response() {
    CHANNEL_ID=$1
    THREAD_TS=$2
    RESULT=$3

    curl -X POST https://slack.com/api/chat.postMessage \
      -H "Authorization: Bearer $SLACK_BOT_TOKEN" \
      -H "Content-Type: application/json" \
      -d "{
        \"channel\": \"$CHANNEL_ID\",
        \"thread_ts\": \"$THREAD_TS\",
        \"text\": \"$RESULT\"
      }"
}

# Example usage:
post_response "C123456" "1234567890.123456" "Analysis complete: Found 3 issues"

Rich Response with Blocks

curl -X POST https://slack.com/api/chat.postMessage \
  -H "Authorization: Bearer $SLACK_BOT_TOKEN" \
  -H "Content-Type: application/json" \
  -d '{
    "channel": "'$CHANNEL_ID'",
    "thread_ts": "'$THREAD_TS'",
    "blocks": [
      {
        "type": "header",
        "text": {"type": "plain_text", "text": "Analysis Complete"}
      },
      {
        "type": "section",
        "text": {"type": "mrkdwn", "text": "'$RESULT'"}
      },
      {
        "type": "context",
        "elements": [{"type": "mrkdwn", "text": "_Automated response by Claude Agent_"}]
      }
    ]
  }'

Task Metadata Required

For Slack response routing, task must include:

{
  "source": "slack",
  "source_metadata": {
    "channel_id": "C123456",
    "thread_ts": "1234567890.123456",
    "user_id": "U123456"
  }
}
Install via CLI
npx skills add https://github.com/rom-orlovich/agents-system --skill slack-operations
Repository Details
star Stars 0
call_split Forks 0
navigation Branch main
article Path SKILL.md
More from Creator
rom-orlovich
rom-orlovich Explore all skills →