Skip to content

rjleaf/trello_webhook

 
 

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

11 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

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

About

💎 Ruby gem processing Trello Webhooks

Resources

License

Stars

Watchers

Forks

Packages

No packages published

Languages

  • Ruby 100.0%