Skip to content

Instantly share code, notes, and snippets.

Thomas Stachl tstachl

Block or report user

Report or block tstachl

Hide content and notifications from this user.

Learn more about blocking users

Contact Support about this user’s behavior.

Learn more about reporting abuse

Report abuse
View GitHub Profile
tstachl / case_theme.html
Created Oct 10, 2013
Very simple example of how you can use JavaScript within case themes.
View case_theme.html
<div id="save_{{}}">
<div class="agent_ticket_section">
<div class="agent_ticket_section">
tstachl / pagination_LastToFirst_example.js
Created Oct 22, 2013
This is an example of how you can use the desk.js pagination from the last page to the first page.
View pagination_LastToFirst_example.js
// get the first cases page
client.cases(function(err, cases) {
// define a worker function that handles the
// cases and starts over with the previous page
// make sure you have a "callback" (doSomethingElse)
// function defined before going into this loop
function workCases(err, cases) {
// test if cases is null (previous will return null
// if there is no previous page)
if (cases !== null) {
tstachl / import_customers.rb
Created Oct 29, 2013
Simple example of importing customers to using the API with the API wrapper gem
View import_customers.rb
require 'desk_api'
require 'csv'
client ={
username: '', # your username
password: 'yourpassword', # your password
subdomain: 'yoursubdomain' # your subdomain (
CSV.foreach('./customers.csv', headers: true) do |row|
tstachl / DeskLabelService.class
Created Oct 31, 2013
This gist shows how you can add additional information (in this case we fetch the labels) from with the Sealsforce integration.
View DeskLabelService.class
public class DeskLabelService
private static String OAUTH_KEY = 'your_consumer_key';
private static String OAUTH_SECRET = 'your_consumer_secret';
private static String ACCESS_TOKEN = 'your_access_token';
private static String ACCESS_TOKEN_SECRET = 'your_access_token_secret';
public static String DESK_DOMAIN = '';
View custom_middleware.rb
require 'desk_api'
require 'json'
site = {
username: '',
password: 'yourpassword',
site_name: 'yoursubdomain'
client = username: site[:username], password: site[:password], subdomain: site[:site_name]
View create_case.php
$case = array(
'type' => 'email',
'subject' => 'Email Case Subject',
'priority' => 4,
'status' => 'open',
'labels' => array('Spam', 'Ignore'),
'message' => array(
'direction' => 'in',
View FetchGroupsAndUsers.cls
global class FetchGroupsAndUsers implements Schedulable, Database.Batchable<DeskResource>, Database.AllowsCallouts
public static String CRON_EXPRESSION = '0 0 0 * * ? *';
global static final DeskClient DESK_CLIENT = new DeskClient(new Map<String, String>{
'username' => '',
'password' => 'somepassword',
'subdomain' => 'devel'
tstachl / AdminReport.html
Created Dec 18, 2013
This gist shows a very simple way of fetching all admin users in your account and displaying it in a knowledge base article. IMPORTANT: this will only work if you're logged in as a agent and should never be a public article.
View AdminReport.html
table#users { width: 100%; }
table#users th { font-weight: bold; font-size: 120%; }
<table class="table table-striped" id="users">
tstachl / search_customer_create_case.php
Created Dec 18, 2013
This php script shows how you search for a customer before creating the case, however it doesn't plan for the customer not existing, you'd have to check the response for total_entries == 0 or an empty entries array and create the customer accordingly.
View search_customer_create_case.php
$ch = curl_init();
curl_setopt($ch, CURLOPT_URL, "");
curl_setopt($ch, CURLOPT_PORT, 443);
curl_setopt($ch, CURLOPT_TIMEOUT, 15);
curl_setopt($ch, CURLOPT_USERPWD, "email:password");
curl_setopt($ch, CURLOPT_RETURNTRANSFER, true);
tstachl / Gemfile
Created Jan 15, 2014
Export knowledge base articles from and zip them up for a import.
View Gemfile
source ''
ruby '2.0.0'
gem 'desk_api', '0.5.0'
gem 'rubyzip', '1.1.0'
gem 'open_uri_redirections', '0.1.4'
You can’t perform that action at this time.