Skip to content

Instantly share code, notes, and snippets.

@RobSpectre
Last active August 29, 2015 13:56
Show Gist options
  • Save RobSpectre/8931745 to your computer and use it in GitHub Desktop.
Save RobSpectre/8931745 to your computer and use it in GitHub Desktop.
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'])
def first_step():
response = twiml.Response()
response.say("Going to connect you to the next step.")
response.redirect("/second_step")
return str(response)
# Second step where we connect them to the phone number, switching the Caller Id
@app.route('/second_step', methods=['POST'])
def second_step():
user_phone_number = request.form['To']
response = twiml.Response()
with response.dial(callerId="%s" % user_phone_number) as dial:
dial.number("+13334445555")
return str(response)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment