Skip to content

Instantly share code, notes, and snippets.

@sajanp
Last active December 12, 2015 10:09
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 sajanp/4757151 to your computer and use it in GitHub Desktop.
Save sajanp/4757151 to your computer and use it in GitHub Desktop.
Quick two files to have Zendesk post to zendesk.php on a trigger, which will then ask Twilio to go to twilio.php and do stuff. Like call you and text you. You will need to load the Twilio PHP helper.
<?php
include 'Twilio.class.php';
$subject = urldecode($_GET['subject']);
$response = new Services_Twilio_Twiml();
$response->say('Hello. New Zen desk ticket.');
$response->pause("");
$response->say($subject);
$response->sms(
'New support ticket: ' . $subject,
array(
'to' => '+1231231231', // Your number to SMS to..
'from' => '+112312312' // Your Twilio number.
));
print $response;
?>
<?php
if (!isset($_POST['some-string-here'])) // This string you'll set in Zen Desk as the 'attribute name'.
{
exit('You are not Zen Desk. Get off mah lawn!');
}
else
{
$subject = urlencode($_POST['some-string-here']); // Update that same string here as well.
$subject = htmlentities($subject);
$twixml = 'http://sajanp.com/twilio/twilio.php?subject=' . $subject; // Update the URL to your twilio.php file here.
}
include 'Twilio.class.php';
$sid = "XXXXX"; // Your Twilio sid.
$token = "XXXXXX"; // Your Twilio token key.
$client = new Services_Twilio($sid, $token);
$call = $client->account->calls->create
(
'XXXX', // Your Twilio number.
'XXXX', // Your number to call.
$twixml
);
?>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment