Skip to content

Commit 2d46ff5

Browse files
committed
Add support for configuring environment variables
This lets you more easily change the Zendesk URL and other variables. See #1
1 parent c88e9f7 commit 2d46ff5

File tree

2 files changed

+28
-6
lines changed

2 files changed

+28
-6
lines changed

Zendesk Search.alfredworkflow

504 Bytes
Binary file not shown.

src/info.plist

Lines changed: 28 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -74,7 +74,7 @@
7474
<key>createdby</key>
7575
<string>Raam Dev</string>
7676
<key>description</key>
77-
<string></string>
77+
<string>Opens in your existing Zendesk tab!</string>
7878
<key>disabled</key>
7979
<false/>
8080
<key>name</key>
@@ -100,7 +100,7 @@ query=$1
100100
101101
/usr/bin/osascript &lt;&lt; EOT
102102
set searchQuery to "$query"
103-
set serverURI to "https://wordpressvip.zendesk.com"
103+
set serverURI to (system attribute "zendesk_url")
104104
set browserURL to "/agent/search/1?q=" &amp; searchQuery
105105
set found to false
106106
@@ -193,6 +193,8 @@ EOT</string>
193193
<string>&lt;?php
194194
$query = $argv[1];
195195
$query_url = rawurlencode( $query );
196+
$subdomain_regex = getenv('subdomain_regex');
197+
$domain_regex = getenv('domain_regex');
196198
197199
// Matches variations of "#88888" or "#88888-z" or "88888" and captures just the ticket number
198200
$ticket_num_regex = '/^(?:\#?)(\d+)(?:\-?z?)$/';
@@ -204,7 +206,10 @@ $ticket_num_regex = '/^(?:\#?)(\d+)(?:\-?z?)$/';
204206
// http://vip-support.automattic.com/tickets/88888
205207
// https://wordpressvip.zendesk.com/agent/tickets/88888
206208
//
207-
$ticket_link_regex = '/^(?:https:\/\/href.li\/\?)?(?:http|https):\/\/(?:wordpressvip|vip-support)\.(?:zendesk|automattic)\.com\/(?:agent\/)?tickets\/(\d+)$/';
209+
// Configure 'subdomain_regex' and 'domain_regex' workflow environment variables
210+
// to match your ZD instance and any variations of the URL that should be matched.
211+
//
212+
$ticket_link_regex = '/^(?:https:\/\/href.li\/\?)?(?:http|https):\/\/(?:'. $subdomain_regex .')\.(?:'. $domain_regex .')\.com\/(?:agent\/)?tickets\/(\d+)$/';
208213
209214
if ( preg_match( $ticket_num_regex, $query )) {
210215
echo preg_replace( $ticket_num_regex, '$1', $query );
@@ -286,7 +291,7 @@ query=$1
286291
287292
/usr/bin/osascript &lt;&lt; EOT
288293
set ticketId to $query
289-
set serverURI to "https://wordpressvip.zendesk.com"
294+
set serverURI to (system attribute "zendesk_url")
290295
set browserURL to "/agent/tickets/" &amp; ticketId
291296
set found to false
292297
@@ -351,7 +356,11 @@ EOT</string>
351356
</dict>
352357
</array>
353358
<key>readme</key>
354-
<string></string>
359+
<string>Opens in your existing Zendesk tab!
360+
361+
This is an Alfred workflow for opening Zendesk searches in an existing Zendesk tab. While there are plenty of Alfred Zendesk workflows that perform searches and open tickets in Zendesk, they all seem to have one annoying flaw: They open a completely new Zendesk instance in a new browser tab each time, ignoring any existing Zendesk tab. This results in lots of extra tabs and makes it harder to keep track of Zendesk-related tickets, searches, etc.
362+
363+
This workflow solves this problem by using AppleScript and JavaScript to look for an existing Zendesk tab in Google Chrome and then uses that Zendesk instance to open a ticket or perform a search.💥</string>
355364
<key>uidata</key>
356365
<dict>
357366
<key>3BDF17C2-81E2-421A-8D8B-5456DD860AE6</key>
@@ -397,7 +406,20 @@ EOT</string>
397406
<integer>10</integer>
398407
</dict>
399408
</dict>
409+
<key>variables</key>
410+
<dict>
411+
<key>domain_regex</key>
412+
<string>zendesk|automattic</string>
413+
<key>subdomain_regex</key>
414+
<string>wordpressvip|vip-support</string>
415+
<key>zendesk_url</key>
416+
<string>https://wordpressvip.zendesk.com</string>
417+
</dict>
418+
<key>variablesdontexport</key>
419+
<array/>
420+
<key>version</key>
421+
<string>1.0</string>
400422
<key>webaddress</key>
401-
<string></string>
423+
<string>https://github.com/raamdev/alfred-zendesk-search</string>
402424
</dict>
403425
</plist>

0 commit comments

Comments
 (0)