Skip to content

Instantly share code, notes, and snippets.

View RobSpectre's full-sized avatar

Rob Spectre RobSpectre

View GitHub Profile
var http = require('http'),
twilio = require('twilio');
http.createServer(function (req, res) {
//Create TwiML response
var twiml = new twilio.TwimlResponse();
twiml.record();
res.writeHead(200, {'Content-Type': 'text/xml'});
res.end(twiml.toString());
@RobSpectre
RobSpectre / app.py
Created February 16, 2014 12:29
Example of receiving an SMS.
from flask import Flask
from flask import request
from twilio import twiml
# Declare and configure application
app = Flask(__name__)
@app.route('/sms', methods=['POST'])
@RobSpectre
RobSpectre / app.py
Created February 15, 2014 22:56
Example serial script with Flask and Twilio
from flask import Flask
from flask import request
from twilio import twiml
import serial
# Declare and configure application
app = Flask(__name__, static_url_path='/static')
@RobSpectre
RobSpectre / app.py
Created February 15, 2014 21:57
Setting a conversation cookie using Flask
from flask import Flask
from flask import session
from flask import make_response
from twilio import twiml
app = Flask(__name__)
@app.route('/tracking_conversation', methods=['POST'])
def tracking_conversation():
@RobSpectre
RobSpectre / app.py
Created February 15, 2014 17:05
Quick sketch of your use case
from flask import Flask
from flask import request
from twilio import twiml
from twilio.rest import TwilioRestClient
# Declare and configure application
app = Flask(__name__, static_url_path='/static')
app.config.from_pyfile('local_settings.py')
@RobSpectre
RobSpectre / app.py
Last active August 29, 2015 13:56
Caller ID Switcheroo
from flask import Flask
from flask import request
from twilio import twiml
# Declare and configure application
app = Flask(__name__)
# First step where we tell the user we are going to connect them to a phone number.
@app.route('/first_step', methods=['POST'])
@RobSpectre
RobSpectre / top.sls
Created November 22, 2013 19:37
Getting KeyError on "development" every time I run highstate. Full stacktrace: 2013-11-22 14:30:19,849 [salt.minion ][WARNING ] The minion function caused an exception: Traceback (most recent call last): File "/usr/lib/pymodules/python2.7/salt/minion.py", line 633, in _thread_return ret['return'] = func(*args, **kwargs) File "/usr/lib/pymodules/…
base:
'*':
- git
- users
- vim
- ssh
- python
- apt
- salt
@RobSpectre
RobSpectre / 1_gather.php
Created November 4, 2013 00:23
Example of taking a prompt and forwarding to two different numbers.
<?php
header('Content-type: text/xml');
?>
<Response>
<Gather action='/2_handler.php' numDigits='1'>
<Say>Press 1 for US support.</Say>
<Say>Press 2 for other support.</Say>
</Gather>
</Response>
@RobSpectre
RobSpectre / conference.xml
Created October 28, 2013 12:54
Example of building a conference call for Gabi.
<Response>
<Dial><Conference>Gabi's Conference Call</Conference></Dial>
</Response>
@RobSpectre
RobSpectre / app.py
Created October 18, 2013 11:03
Validating requests on GAE
import webapp2
import logging
from twilio.util import RequestValidator
from twilio import twiml
AUTH_TOKEN = 'xxxxx'
class MainPage(webapp2.RequestHandler):
def twilio_request_validator(self):