Easily add Slack WebHooks integration and send messages from your Ruby application.
Add this line to your application's Gemfile:
gem 'slackhook'
And then execute:
$ bundle
Or install it yourself as:
$ gem install slackhook
To use this gem you only need to configure the Incoming WebHook integration in Slack.
You can find this using your slack account and going to Incoming WebHooks and select your default channel.
Well, now you are ready to send messages to Slack channels \0/!
# This is how you send messages to your default channel.
Slackhook.send_hook({webhook_url: "your_webhook_url", text: "test message"})
There are also username
and icon_type
(slackbot is the default) options to be more specific about the nickname and avatar which would appear on the chat.
You can use the channel
option if the message is goint to be sent to a non default channel.
> require "slackhook"
> Slackhook.send_hook({ webhook_url: "your_webhook_url",
text: "test message",
channel: "@your-channel",
username: "testbot",
icon_type: ":trollface:"})
You can also use icon_url
instead of icon_type
if you want to use some additional icon image.
- Fork it
- Create your feature branch (
git checkout -b my-new-feature
) - Commit your changes (
git commit -am 'Add some feature'
) - Push to the branch (
git push origin my-new-feature
) - Create a new Pull Request
- Uriel Molina urielable
- Daniel Becker danielbecker