Skip to content
This repository

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP

Flowdock Integration #35

Merged
merged 2 commits into from over 1 year ago

1 participant

Prateek Dayal
This page is out of date. Refresh to see the latest.
1  Gemfile
@@ -22,6 +22,7 @@ gem 'evernote-thrift'
22 22 gem 'highrise'
23 23 gem 'jaconda'
24 24 gem 'ruby-trello', :require => 'trello'
  25 +gem 'flowdock'
25 26
26 27 gem 'guard-shotgun', :git =>'git://github.com/rchampourlier/guard-shotgun.git', :group => :development
27 28 gem 'execjs', :group => :development
4 Gemfile.lock
@@ -33,6 +33,9 @@ GEM
33 33 faraday (>= 0.7.4, < 0.9)
34 34 ffi (1.1.5)
35 35 flexmock (0.9.0)
  36 + flowdock (0.3.0)
  37 + httparty (~> 0.7)
  38 + multi_json
36 39 guard (1.5.0)
37 40 listen (>= 0.4.2)
38 41 lumberjack (>= 1.0.2)
@@ -133,6 +136,7 @@ DEPENDENCIES
133 136 faraday
134 137 faraday_middleware
135 138 flexmock
  139 + flowdock
136 140 guard-shotgun!
137 141 haml
138 142 hashie
BIN  apps/flowdock/assets/images/icon.png
24 apps/flowdock/assets/views/button/overlay.hbs
... ... @@ -0,0 +1,24 @@
  1 +<!--
  2 + Set overlay: true in the config
  3 + This file will be rendered on the overlay
  4 + The below code sample is taken from the Pivotal App
  5 +-->
  6 +
  7 +<h3>Edit the Story Details</h3>
  8 +{{#each tickets}}
  9 + {{#ticket}}
  10 + <ol>
  11 + <li>
  12 + <label for="title">Story Title</label>
  13 + <input name="title" value="{{subject}}">
  14 + </li>
  15 + <li>
  16 + <label for="description">Story Description</label>
  17 + <textarea name="description">
  18 +{{content.text}} \n
  19 +https://{{../../company.subdomain}}.supportbee.com/tickets/{{id}}
  20 + </textarea>
  21 + </li>
  22 + </ol>
  23 + {{/ticket}}
  24 +{{/each}}
17 apps/flowdock/config.yml
... ... @@ -0,0 +1,17 @@
  1 +name: Flowdock
  2 +slug: flowdock
  3 +access: public
  4 +
  5 +description: "Send new ticket, reply and comment notifications to Flowdock"
  6 +
  7 +category: notification
  8 +
  9 +tags:
  10 +- flowdock
  11 +- chat
  12 +
  13 +developer:
  14 + name: Prateek
  15 + email: prateek@supportbee.com
  16 + twitter: "@prateekdayal"
  17 + github: prateekdayal
77 apps/flowdock/flowdock.rb
... ... @@ -0,0 +1,77 @@
  1 +module Flowdock
  2 + module EventHandler
  3 + def ticket_created
  4 + return unless settings.notify_ticket_created.to_s == '1'
  5 + ticket = payload.ticket
  6 + paste_in_flowdock :content => ticket.content.html,
  7 + :subject => ticket.subject,
  8 + :link => get_link,
  9 + :poster => ticket.requester,
  10 + :tags => ['new_ticket']
  11 + end
  12 +
  13 + def agent_reply_created
  14 + return unless settings.notify_agent_reply_created.to_s == '1'
  15 + ticket = payload.ticket
  16 + reply = payload.reply
  17 + paste_in_flowdock :content => reply.content.html,
  18 + :subject => ticket.subject,
  19 + :link => get_link,
  20 + :poster => reply.replier,
  21 + :tags => ['agent_reply']
  22 + end
  23 +
  24 + def customer_reply_created
  25 + return unless settings.notify_customer_reply_created.to_s == '1'
  26 + ticket = payload.ticket
  27 + reply = payload.reply
  28 + paste_in_flowdock :content => reply.content.html,
  29 + :subject => ticket.subject,
  30 + :link => get_link,
  31 + :poster => reply.replier,
  32 + :tags => ['customer_reply']
  33 + end
  34 +
  35 + def comment_created
  36 + return unless settings.notify_comment_created.to_s == '1'
  37 + ticket = payload.ticket
  38 + comment = payload.comment
  39 + paste_in_flowdock :content => comment.content.html,
  40 + :subject => ticket.subject,
  41 + :link => get_link,
  42 + :poster => comment.commenter,
  43 + :tags => ['comment']
  44 + end
  45 + end
  46 +end
  47 +
  48 +module Flowdock
  49 + class Base < SupportBeeApp::Base
  50 + string :token, :required => true, :label => 'Flow API Token'
  51 + boolean :notify_ticket_created, :default => true, :label => 'Notify when Ticket is created'
  52 + boolean :notify_customer_reply_created, :default => true, :label => "Notify when a customer replied"
  53 + boolean :notify_agent_reply_created, :default => true, :label => "Notify when an agent replies"
  54 + boolean :notify_comment_created, :default => true, :label => "Notify when a comment is posted"
  55 +
  56 + white_list :notify_ticket_created, :notify_agent_reply_created, :notify_customer_reply_created, :notify_comment_created
  57 +
  58 + private
  59 +
  60 + def get_link
  61 + "https://#{auth.subdomain}.supportbee.com/tickets/#{payload.ticket.id}"
  62 + end
  63 +
  64 + def paste_in_flowdock(options)
  65 + puts options.inspect
  66 + get_room(options[:poster]).push_to_team_inbox :subject => options[:subject],
  67 + :content => options[:content],
  68 + :link => options[:link],
  69 + :tags => options[:tags]
  70 + end
  71 +
  72 + def get_room(poster)
  73 + @client = Flowdock::Flow.new(:api_token => settings.token.strip,
  74 + :source => "SupportBee", :from => {:name => poster.name, :address => poster.email})
  75 + end
  76 + end
  77 +end

Tip: You can add notes to lines in a file. Hover to the left of a line to make a note

Something went wrong with that request. Please try again.