This is a basic Rails API that routes Heroku webhook events to Slack.
git clone https://github.com/apartmentlist/heroto_rooter.git
bundle install
rake db:create
rake db:migrate
Create a new bot
integration
and set the API key into the SLACK_API_TOKEN environment varible, which is
read into the
slack-ruby-client in
config/initializers/slack.rb.
Routing is set in the Rooter objects. Add one with the application name, Slack
channel, and emoji to use as the avatar.
Rooter.create(
app: 'heroto-rooter',
channel: 'log_info',
emoji: 'speaking_head_in_silhouette'
)
Heroku needs to know where to send events. You can pick and choose your events if you like, or subscribe to everything with:
./scripts/add_webhooks.rb <host> <app> [app ...]
hostis your instance's application host, eg.rooter.example.comappis the name (or many names) of the Heroku app to install the webhook on
Notifications are looked up by the [resource, action] pair found in an event,
for example %w[release create]. To notify about a new event, write a subclass
of Notification::Base with the #body you want to post, and then add the
class to the Event::NOTIFICATION_MAP, keyed by its resource and action.
See the LICENSE file for license rights and limitations.