Last active
August 29, 2015 13:56
-
-
Save RobSpectre/8931745 to your computer and use it in GitHub Desktop.
Caller ID Switcheroo
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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