Send messages to slack users with only a valid response url or a bot token and slack user id.
To install SlackSend with RubyGems:
gem install slack_send
To use SlackSend in a project managed with Bundler:
gem 'slack_send', '>= 0.0.1'
The bot token must be configured in the gem setup before you can send any message without passing a valid response url. You can do this anywhere in your application before using the gem.
SlackSend.configure do |config|
config.bot_token = ''
end
bot_token
- your Slack API bot token
Getting a bot token requires a (free) Slack account and that you agree to the terms of use for the API.
SlackSend.reply(
response_url: 'a.valid.slack/response/url',
message: {},
attachments: [],
response_type: 'in_channel'
)
response_url
- a valid slack response urlmessage
- a correctly formatted messageattachments
- optional an array of correctly formatted attachmentsresponse_type
- optional optional - will default to 'ephemeral' if not passed 'in_channel'
SlackSend.send(
user_id: 'lizard123',
message: {},
attachments: []
)
user_id
- a valid slack user idmessage
- a correctly formatted messageattachments
- optional an array of correctly formatted attachments
requires bot token configuration as above
See the Slack API documentation for the required format for slack messages and attachments.
Formatting Guidelines for Messages
Formatting Guidelines for Attachments
Author: Liz Ardolino