Skip to content

Instantly share code, notes, and snippets.

View jaboutboul's full-sized avatar

Jack Aboutboul jaboutboul

  • ex-Red Hat, ex-Twilio
  • NYC
View GitHub Profile
@jaboutboul
jaboutboul / return2me-dyanmic-twiml.java
Created August 28, 2012 19:29
Return2Me - Dynamic TwiML Generation
package com.fork4.return2me.twilio;
import com.twilio.sdk.TwilioRestResponse;
public class IvrResponse {
public static String callRedirect(String number) {
StringBuilder response = new StringBuilder("<?xml version=\"1.0\" encoding=\"UTF-8\"?>");
response.append("<Response>");
response.append("<Say>Connecting you to your representative.</Say>");
@jaboutboul
jaboutboul / return2me-extension-lookup.java
Created August 28, 2012 19:28
Return2Me - Extension Lookup
package com.fork4.return2me;
import java.io.IOException;
import java.util.HashMap;
import javax.servlet.ServletException;
import javax.servlet.http.HttpServlet;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;
@jaboutboul
jaboutboul / return2me-simple-ivr.xml
Created August 28, 2012 19:25
Return2Me - Simple IVR
<?xml version="1.0" encoding="UTF-8"?>
<Response>
<Gather action="http://return2me.elasticbeanstalk.com/fetch"
numDigits="5" timeout="10" finishOnKey="#">
<Say>Return 2 Me Demo</Say>
<Say>Enter the extension for your representative. Press pound to continue.</Say>
</Gather>
<!-- If customer doesn't input anything, prompt and try again. -->
<Say>Sorry, I didn't get your response.</Say>
<Redirect>http://return2me.elasticbeanstalk.com/ivr/incoming.xml</Redirect>
@jaboutboul
jaboutboul / return2me-sms-extension-info.java
Created August 28, 2012 19:24
Return2Me - SMS Extension Info
package com.fork4.return2me.twilio;
import java.util.HashMap;
import java.util.Map;
import com.twilio.sdk.TwilioRestClient;
import com.twilio.sdk.TwilioRestException;
import com.twilio.sdk.TwilioRestResponse;
import com.twilio.sdk.resource.factory.SmsFactory;
import com.twilio.sdk.resource.instance.Account;
@jaboutboul
jaboutboul / return2me-extension-generation.java
Created August 28, 2012 19:21
Return2Me - Extension Generation
package com.fork4.return2me;
import java.io.IOException;
import java.security.SecureRandom;
import java.util.HashMap;
import javax.servlet.ServletException;
import javax.servlet.http.HttpServlet;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;
@jaboutboul
jaboutboul / return2me-extension-mapping.java
Created August 28, 2012 19:18
Return2Me - Extension Mapping
package com.fork4.return2me.beans;
public class Extension {
final String repPhone;
final String custPhone;
final String extension;
final boolean oneTimeUse;
final boolean hasCustomerPhone;
public Extension(String repPhone, String extension, String custPhone, boolean oneTimeUse) {
@jaboutboul
jaboutboul / example.js
Created May 31, 2012 20:10 — forked from stevegraham/example.js
JavaScript TwiML generator
Twilio = Object.create({})
Twilio.TwiML = {
build: function(fn) {
var prolog = "<?xml version=\"1.0\" encoding=\"UTF-8\"?>\n";
var Buffer = function(level) {
var buffer = "";
var indent = function(i) { return new Array((i * 2) + 1).join(" ") }
var level = level || 1;
var append = function(str) {
buffer += indent(++level) + str + "\n";
@jaboutboul
jaboutboul / cof.php
Created April 12, 2012 18:14
Cost of Freedom Text Based App
<?php
header('Content-type:text/xml');
$message = $_REQUEST['Body'];
$response = '';
//our spreadsheet's key
$key = "0Aoz1Ir-h-0g5dG00N1lDVG1COTFHellrc2o2bDhoeXc";
@jaboutboul
jaboutboul / broadcast.php
Created April 2, 2012 19:15
Twilio SMS Distribution CSV File
<?php
//set the upload directory for our CSV file
$upload_path = "upload/";
//append the file name to our path so that we have a complete path
$upload_path = $upload_path . basename( $_FILES['csv_file']['name']);
//test to see if we can successfully move the file into our $upload_path directory
if(move_uploaded_file($_FILES['csv_file']['tmp_name'], $upload_path)) {
@jaboutboul
jaboutboul / credentials.php
Created April 2, 2012 19:07
Twilio SMS Distribution JS Modal
<?php
$ACCOUNT_SID = '';
$AUTH_TOKEN = '';
?>