0.0
Repository is archived
No commit activity in last 3 years
No release in over 3 years
Process Trello Webhooks in your Rails app (Controller mixin)
2005
2006
2007
2008
2009
2010
2011
2012
2013
2014
2015
2016
2017
2018
2019
2020
2021
2022
2023
2024
 Dependencies

Development

~> 1.5
~> 10.1
~> 2.14

Runtime

 Project Readme

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