A CLI tool for sending messages and DMs via Slack using User Token.
- Install dependencies
npm install- Register CLI command globally
npm link- Configure Slack User Token
cp .env.example .env
# Edit .env file and set SLACK_USER_TOKEN- Create configuration files from samples
# Create recipient lists
cp recipients/users.txt.example recipients/users.txt
cp recipients/users.json.example recipients/users.json
# Create templates
cp templates/welcome.txt.example templates/welcome.txt
cp templates/announcement.txt.example templates/announcement.txtchat:write- Send messageschannels:read- List channelsfiles:write- Upload filesgroups:read- Read private channelsim:read,im:write- Read/write DMsusers:read,users:read.email- Get user information
# Send message to a channel
slack-cli send #general "Hello, World!"
# Specify token directly
slack-cli send #general "Hello" -t xoxp-your-token# Specify user by email
slack-cli dm user@example.com "Hello!"
# Specify by username
slack-cli dm @username "Hello!"
# Specify by user ID
slack-cli dm U0123456789 "Hi there!"# Use template file (create from templates/welcome.txt.example)
slack-cli dm user@example.com "" --template templates/welcome.txt --vars '{"name":"John Doe","team":"Dev Team","department":"Engineering","date":"2024-01-15"}'# Use text file user list
slack-cli bulk-dm recipients/users.txt "Announcement message"
# Use JSON file with template
slack-cli bulk-dm recipients/users.json "" --template templates/welcome.txt
# Adjust sending interval (default: 1000ms)
slack-cli bulk-dm recipients/users.txt "Hello" --delay-ms 2000
# Send without delay (watch for rate limits)
slack-cli bulk-dm recipients/users.txt "Hello" --no-delay# List channels
slack-cli channels
# List users
slack-cli users
# Upload file
slack-cli upload #general file.pdf -c "Document attached" --title "Monthly Report"# Comment lines start with #
user1@example.com
user2@example.com
@username
U0123456789
[
{
"user": "user@example.com",
"name": "User Name",
"team": "Team Name",
"any_field": "value"
}
]Each field in the JSON file can be used as a variable in templates.
Template files use {{ variable }} format for variable substitution.
Example (create from templates/welcome.txt.example):
Hello {{ name }}!
Team: {{ team }}
Department: {{ department }}
Start Date: {{ date }}
- User not found: Ensure
users:read.emailscope is enabled for email lookups - DM send failure: Verify
im:writescope is enabled - Rate limit errors: Adjust sending interval with
--delay-msoption