python - How do you get the phone number of the current call in progress from Twilio? -
i trying allow current caller leave callback number after specifying gather function.
i imagine need use
calls = client.calls.list(status="in-progress")
i'm not sure go here. there way sid of current call can phone number?
the calls.list()
method returns list of call resources can iterate through or retrieve index.
from twilio.rest import twiliorestclient account_sid = acxxxxxxxxxx auth_token = yyyyyyyyyyyyy client = twiliorestclient(account_sid, auth_token) calls = client.calls.list(status='in-progress') call in calls: print(call.sid) first_call = calls[0]
the phone numbers related call in-progress
available via to
, from_
attributes. use case, suspect phone number looking available here:
from twilio.rest import twiliorestclient account_sid = acxxxxxxxxxx auth_token = yyyyyyyyyyyyy client = twiliorestclient(account_sid, auth_token) calls = client.calls.list(status='in-progress') first_call = calls[0] to_number = first_call.to from_number = first_call.from_
in fact can see attributes available call in call resource's __dict__
method.
from twilio.rest import twiliorestclient account_sid = acxxxxxxxxxx auth_token = yyyyyyyyyyyyy client = twiliorestclient(account_sid, auth_token) calls = client.calls.list(status='in-progress') first_call = calls[0] print(first_call.__dict__)
hope helps!
Comments
Post a Comment