Web API reference is here. It includes methods that manipulate channels, chats, emojis, files, groups, ims, pins, reactions, search, stars, teams and users.
Sign up at slack.com.
This is something done in Slack, under integrations. Create a new bot, and note its API token.
source 'http://rubygems.org'
require 'http'
require 'json'
rc = HTTP.post("https://slack.com/api/api.test")
puts JSON.pretty_generate(JSON.parse(rc.body))
{
"ok": true
}
rc = HTTP.post("https://slack.com/api/auth.test")
puts JSON.pretty_generate(JSON.parse(rc.body))
{
"ok": false,
"error": "not_authed"
}
rc = HTTP.post("https://slack.com/api/auth.test", params: { token: ENV['SLACK_API_TOKEN'] })
puts JSON.pretty_generate(JSON.parse(rc.body))
{
"ok": true,
"url": "https://dblockdotorg.slack.com/",
"team": "dblock",
"user": "rubybot",
"team_id": "T04KB5WQH",
"user_id": "U07518DTL"
}
HTTP.post("https://slack.com/api/chat.postMessage", params: {
token: ENV['SLACK_API_TOKEN'],
channel: '#general',
text: 'hello world'
})
{
"ok": true,
"channel": "C04KB5X4D",
"ts": "1444747472.000002",
"message": {
"text": "hello world",
"username": "bot",
"type": "message",
"subtype": "bot_message",
"ts": "1444747472.000002"
}
}
Post with as_user: true
on behalf of the bot user.