Basic auth test, is it working at all?
auth test { "ok": true, "url": "https://dblockdotorg.slack.com/", "team": "dblock", "user": "api", "team_id": "T04KB5WQH", "user_id": "U0HPMN0GY" }
You can pipe a JSON parser, for example find your team ID.
auth test | $.team_id [ "T04KB5WQH" ]See jsonpath for detailed syntax.
Find out the ID of the #general channel, the easy way.
channels id --channel=#general { "ok": true, "channel": { "id": "C04KB5X4D" } }Or the hard way.
channels list | $..[?(@.name=="general")].id [ "C04KB5X4D" ]
Post a message into the #general channel.
chat postMessage --as_user=true --text="Hello World" --channel=#general { "ok": true, "channel": "C04KB5X4D", "ts": "1453587435.000047", "message": { "type": "message", "user": "U07518DTL", "text": "Hello", "ts": "1453587435.000047" } }
Get names of all unarchived channels.
channels list | $..[?(@.is_archived==false)].name [ "demo", "general", "apiapi", ]
Get help.
help Commands -------- api - Api methods. auth - Auth methods. channels - Get info on your team's Slack channels, create or archive channels, invite users, set the topic and purpose, and mark a channel as read. chat - Post chat messages to Slack. dnd - Adjust and view Do Not Disturb settings for team members emoji - Emoji methods. files - Get info on files uploaded to Slack, upload new files to Slack. groups - Get info on your team's private channels. help - Shows a list of commands or help for one command im - Get info on your direct messages. mpim - Get info on your multiparty direct messages. oauth - Oauth methods. pins - Pins methods. reactions - Reactions methods. rtm - Rtm methods. search - Search your team's files and messages. stars - Stars methods. team - Team methods. usergroups - Get info on your team's user groups. users - Get info on members of your Slack team.Most commands require subcommands, get help for a specific command.
help chat NAME chat - Post chat messages to Slack. SYNOPSIS slack [global options] chat delete slack [global options] chat postMessage [--as_user arg] [--icon_emoji arg] [--icon_url arg] [--unfurl_links arg] [--unfurl_media arg] [--username arg] slack [global options] chat update [--attachments arg] [--channel arg] [--link_names arg] [--parse arg] [--text arg] [--ts arg] COMMANDS delete - This method deletes a message from a channel. postMessage - This method posts a message to a public channel, private group, or IM channel. update - This method updates a message in a channel.
If you have any questions or concerns, please message @dblockdotorg on Twitter or e-mail dblock[at]dblock[dot]org.