Skip to content

Instantly share code, notes, and snippets.

@synoptase
Last active August 29, 2015 14:13
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save synoptase/1f4802bec625f65bc32f to your computer and use it in GitHub Desktop.
Save synoptase/1f4802bec625f65bc32f to your computer and use it in GitHub Desktop.
Dashing Helpscout widget

Preview

Description

A simple widget that retrieves the number of unassigned tickets in Helpscout, a web-based help desk.

##Dependencies

json

Add it to dashing's gemfile:

gem 'json'

and run bundle install.

Usage

  • Install the widget with dashing install 1f4802bec625f65bc32f or create a helpscout.rb file in your jobs directory
  • Add gem "json" to your Gemfile
  • Set the mailbox_id & helpscout_token parameters
    • mailbox_id can be found in the url of your helpscout dashboard https://secure.helpscout.net/mailbox/YOUR_ACCOUNT/MAILBOX_ID/
    • helpscout_token can be set by following this guide: http://developer.helpscout.net/help-desk-api

Add the follwing html to your dashboard .erb file:

<li data-row="2" data-col="5" data-sizex="1" data-sizey="1">
  <div data-id="helpscout"
   data-view="Number"
   data-title="Open tickets"
   style="background-color:#2a4258;"
   data-moreinfo="Open tickets in ACME mailbox"></div>
  <i class="icon-envelope icon-background"></i>
</li>

Notes

The Net:HTTP request doesn't verify the SSL certificate. I was just too lazy to do it. Feel free to add in the comments, i'll add it in the code.

require "net/https"
require "uri"
require "json"
# Settings
#
helpscout_url = "https://api.helpscout.net/v1"
mailbox_id = 42 # change me
helpscout_token = '' # change me
uri = URI.parse(helpscout_url)
http = Net::HTTP.new(uri.host, uri.port)
http.use_ssl = true
SCHEDULER.every '10s', :first_in => 0 do |job|
request = Net::HTTP::Get.new(File.join(uri.request_uri, "mailboxes", "#{mailbox_id.to_s}.json"))
request.basic_auth helpscout_token.to_s, 'x'
response = http.request(request)
data = JSON.parse response.body
unassigned = data['item']['folders'].find { |i| i['name'] == "Unassigned" }
send_event('helpscout', { current: unassigned['totalCount'] })
end
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment