AgentSkillsCN

slai

通过 slai CLI 从命令行发送 Slack 消息。当用户希望发送 Slack 消息、通知频道、向 Slack 上的某人发送私信,或希望将 Slack 通知集成到脚本或工作流中时,可使用此功能。

SKILL.md
--- frontmatter
name: slai
description: Send Slack messages from the command line using slai CLI. Use when the user wants to send Slack messages, notify a channel, DM someone on Slack, or integrate Slack notifications into scripts or workflows.

Slai - Slack CLI Messenger

Send Slack messages from the command line. Configured globally, works from any directory.

Prerequisites

The slai CLI must be installed and configured:

bash
# Check if installed
slai --help

# If not installed, build from source
cd ~/user/Projects/slack-sender
./update.sh

Configuration

Slai uses global configuration stored at:

  • macOS: ~/Library/Application Support/slai/config.toml
  • Linux: ~/.config/slai/config.toml

Initial Setup

bash
# Initialize with token and default channel
slai init -t "xoxp-your-token" -c "#channel-or-user-id"

# Or initialize empty and set values later
slai init
slai config -t "xoxp-your-token"
slai config -c "#default-channel"

View/Update Config

bash
# Show current config (token is masked)
slai config --show

# Update token
slai config -t "xoxp-new-token"

# Update default channel
slai config -c "#new-channel"

Commands

Send a Message

bash
# Send to default channel
slai send -m "Hello world!"

# Send to specific channel (override default)
slai send -m "Alert!" -c "#alerts"

# Send DM to user (use user ID)
slai send -m "Hey!" -c "U01XXXXXXXX"

# Multi-line message
slai send -m "Line 1
Line 2
Line 3"

Channel Formats

FormatExampleDescription
Channel name#generalPublic channel by name
Channel IDC01234567Channel by Slack ID
User IDU01234567DM to user

Finding IDs:

  • Channel ID: Right-click channel → "View channel details" → ID at bottom
  • User ID: Click profile → "⋮" → "Copy member ID"

Common Use Cases

Deployment Notification

bash
slai send -m "Deployed v1.2.3 to production"

Script Integration

bash
#!/bin/bash
set -e

./deploy.sh
slai send -m "✅ Deployment successful at $(date)"

Error Alerting

bash
if ! ./build.sh; then
    slai send -m "❌ Build failed!" -c "#alerts"
    exit 1
fi

Git Hook (post-push)

bash
#!/bin/bash
BRANCH=$(git rev-parse --abbrev-ref HEAD)
slai send -m "Pushed to $BRANCH"

Troubleshooting

ErrorSolution
No config foundRun slai init
No token configuredRun slai config -t "xoxp-..."
No channel specifiedUse -c flag or set default with slai config -c "#channel"
channel_not_foundVerify channel name/ID, ensure you're a member
invalid_authToken expired or revoked, get new token

Getting a Slack Token

  1. Go to https://api.slack.com/apps
  2. Create New App → From scratch
  3. OAuth & Permissions → Add chat:write to User Token Scopes
  4. Install to Workspace
  5. Copy User OAuth Token (starts with xoxp-)