Reputation: 569
I have searched the internet but I can not find this.
I have created an application with Python and Flask which accepts incoming calls and redirects to the address where I have defined in webhook. (with ngrok)
@app.route("/incomingCall", methods=['GET', 'POST'])
def incomingCall():
......
....
@app.route("/gather", methods=['GET', 'POST'])
def gather():
@app.route("/status_callback", methods=['POST'])
def status_callback():
print("-->/status_callback")
resp = VoiceResponse()
resp.redirect('/beginiing')
return str(resp)
If during the call the caller drops the call prematurely how can I detect that?. Right now my app hangs during the gather.
in order to get the status of call I have added this at initialization
strTwilio = sid + ":" + token
acTokenTwilio = b64encode(strTwilio.encode()).decode("ascii")
twilioHeaderAcc1 = {'Authorization': 'Basic %s' % acTokenTwilio, 'Content-Type':'application/x-www-form-urlencoded'}
payLoad = {"status_callback":myNgrokUrl, "status_callback_event":["completed"]}
twilioStatusCallbackUrl = "https://api.twilio.com/2010-04-01/Accounts/" + "AC......" # AC... is my account SID
resp = s.post(twilioStatusCallbackUrl, data=json.dumps(payLoad), headers=twilioHeaderAcc1, timeout=15)
Upvotes: 0
Views: 1800
Reputation: 1
For context here, the user is setting the voice and status callback URLs via the incoming phone numbers resource. To achieve this, you need to pass the staus callback URL as a parameter. Please see the example below, on how this is done using the Python helper library.
incoming_phone_number = client \
.incoming_phone_numbers('PNXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX') \
.update(
voice_url='https://xxxxxxx.ngrok.io/voice',
status_callback='https://xxxxxxx.ngrok.io/status_callback'
)
Upvotes: 0
Reputation: 73057
Twilio developer evangelist here.
To get notified of updates to an inbound call, including when a phone call is completed, you should set up a Status Callback URL for your number. You can do this by editing your number in the dashboard and setting the field here:
You can see the details that are sent to a StatusCallback URL here.
Upvotes: 0
Reputation: 10781
Setting the Status call back URL for the inbound Twilio number your application is using from the Twilio Console.
Upvotes: 0