Skip to content

Commit

Permalink
add timeout, callbacks to web-based call. addresses #20
Browse files Browse the repository at this point in the history
  • Loading branch information
adamgreenhall committed Jan 27, 2014
1 parent 408687a commit a783c00
Showing 1 changed file with 17 additions and 1 deletion.
18 changes: 17 additions & 1 deletion app.py
Original file line number Diff line number Diff line change
Expand Up @@ -129,7 +129,10 @@ def call_user():
call = app.config['TW_CLIENT'].calls.create(
to=params['userPhone'],
from_=campaign['number'],
url=full_url_for("connection", **params)
url=full_url_for("connection", **params),
timeLimit=app.config['TW_TIME_LIMIT'],
timeout=app.config['TW_TIMEOUT'],
status_callback=full_url_for("call_complete_status", **params),
)
result = jsonify(message=call.status, debugMode=app.debug)
result.status_code = 200 if call.status != 'failed' else 500
Expand Down Expand Up @@ -253,6 +256,19 @@ def call_complete():
return str(resp)


@app.route('call_complete_status', methods=call_methods)
def call_complete_callback():
# asynch callback from twilio on call complete
params, campaign = parse_params(request)
return jsonify(dict(
phoneNumber=request.values.get('To', ''),
callStatus=request.values.get('CallStatus', 'unknown'),
repIds=params['repIds'],
campaignId=params['campaignId'],
))



@app.route('/demo')
def demo():
return render_template('demo.html')
Expand Down

0 comments on commit a783c00

Please sign in to comment.