I want to call my Twilio number from my cellphone, Twilio recognizes my number, rejects the call and then calls me back. Here is the code:
@application.route("/test", methods=['GET', 'POST'])
def test():
whitelist = ['81808730xxxx', '44753810xxxx', '+44753810xxxx', '+44792834xxxx', '44792834xxxx']
call_from = request.values.get('From', 'None')
if call_from in whitelist:
# "<Response><Reject /></Response>"
resp = twilio.twiml.Response()
resp.reject()
time.sleep( 10 )
account_sid = "account_sid"
auth_token = "account_auth_token"
client = TwilioRestClient(account_sid, auth_token)
call = client.calls.create(to=call_from, from_="+1646480xxxx", url="https://zshizuka.herokuapp.com/gather")
print call.sid
else:
resp = twilio.twiml.Response()
call_to = "+44792834xxxx"
resp.dial(call_to)
#return json.dumps({'success':True}), 200
return str(resp)
This produces the dreaded response: "We are sorry a system error has occurred. Goodbye".
If, however, I dial the number and hangup after the first ring it works perfectly. So I am assuming that the problem is with the reject verb. As you can see I have tried with and without twiml.
I would like to get a busy signal, call rejected (so no cost to cell phone bill) and then callback.
Grateful for help.