Skip to content

Latest commit

 

History

History
62 lines (43 loc) · 1.53 KB

README.md

File metadata and controls

62 lines (43 loc) · 1.53 KB

Build Status Gem Version

TrelloWebhook

This gem will help you to quickly setup a route in your Rails application which listens to a Trello webhook

Installation

Add this line to your application's Gemfile:

gem 'trello_webhook'

And then execute:

bundle install

Configuration

First, configure a route to receive the trello webhook POST requests.

# config/routes.rb
resource :trello_webhooks, only: %i(show create), defaults: { formats: :json }

Then create a new controller:

# app/controllers/trello_webhooks_controller.rb
class TrelloWebhooksController < ActionController::Base
  include TrelloWebhook::Processor

  def update_card(payload)
    # TODO: handle updateCard webhook payload
  end

  def webhook_secret
    ENV['TRELLO_DEVELOPER_SECRET']  # From https://trello.com/app-key
  end
end

Add as many instance methods as events you want to handle in your controller.

Adding the webhook to a given board

You need the ruby-trello gem.

webhook = Trello::Webhook.new
webhook.description = "The webhook description"
webhook.id_model = "The board model id" # Run `Trello::Board.all` to find it.
webhook.callback_url = "#{ENV['BASE_URL']}/trello_webhooks"  # BASE_URL is your website's url. Use ngrok in dev.
webhook.save