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
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_{{case.id}}">
<div class="agent_ticket_section">
{{subject}}
</div>
<div class="agent_ticket_section">
@tstachl
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
tstachl / import_customers.rb
Created Oct 29, 2013
Simple example of importing customers to desk.com using the API with the API wrapper gem https://github.com/tstachl/desk.
View import_customers.rb
require 'desk_api'
require 'csv'
client = DeskApi::Client.new({
username: 'you@example.com', # your desk.com username
password: 'yourpassword', # your desk.com password
subdomain: 'yoursubdomain' # your desk.com subdomain (https://this.desk.com)
})
CSV.foreach('./customers.csv', headers: true) do |row|
@tstachl
tstachl / DeskLabelService.class
Created Oct 31, 2013
This gist shows how you can add additional information (in this case we fetch the labels) from desk.com 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 = 'yourdomain.desk.com';
@future(callout=true)
View custom_middleware.rb
require 'desk_api'
require 'json'
site = {
username: 'you@example.com',
password: 'yourpassword',
site_name: 'yoursubdomain'
}
client = DeskApi::Client.new username: site[:username], password: site[:password], subdomain: site[:site_name]
View create_case.php
<?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' => 'support@example.com',
'password' => 'somepassword',
'subdomain' => 'devel'
});
@tstachl
tstachl / AdminReport.html
Created Dec 18, 2013
This gist shows a very simple way of fetching all admin users in your desk.com account and displaying it in a knowledge base article. IMPORTANT: this will only work if you're logged in as a desk.com agent and should never be a public article.
View AdminReport.html
<style>
table#users { width: 100%; }
table#users th { font-weight: bold; font-size: 120%; }
</style>
<table class="table table-striped" id="users">
<thead>
<tr>
<th>Name</th>
<th>Email</th>
@tstachl
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
<?php
$ch = curl_init();
curl_setopt($ch, CURLOPT_URL, "https://yoursite.desk.com/api/v2/customers/search?email=thomas%40stachl.me");
curl_setopt($ch, CURLOPT_PORT, 443);
curl_setopt($ch, CURLOPT_TIMEOUT, 15);
curl_setopt($ch, CURLOPT_USERAGENT, $_SERVER['HTTP_USER_AGENT']);
curl_setopt($ch, CURLOPT_USERPWD, "email:password");
curl_setopt($ch, CURLOPT_HTTPAUTH, CURLAUTH_BASIC);
curl_setopt($ch, CURLOPT_RETURNTRANSFER, true);
@tstachl
tstachl / Gemfile
Created Jan 15, 2014
Export knowledge base articles from desk.com and zip them up for a salesforce.com import.
View Gemfile
source 'https://rubygems.org'
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.