python 3.x - Call multiple numbers sequentially using twilio outgoing call -
so i'm using twilio api outgoing calls list
nums = ['xxx-xxx-xxxx', 'jjj-jjj-jjjj'] num in nums: c = make_call(num, "hi-how-are-you!!!")
and make_call function contains twillio code
def make_call(to_number, mesg): global call_status = ['completed', 'failed', 'busy', 'no_answer'] # put own credentials here account_sid = "--------------------" auth_token = "--------------------" client = twiliorestclient(account_sid, auth_token) call = client.calls.create( to=to_number, from_=from, url=url+"/voice/reply/"+mesg, method="post", status_callback=url+"/voice/status", status_callback_method="post", timeout=10 ) return call
no idea i'm doing wrong, queues both , calls them both @ same time. if pick on call, other 1 ends. want call sequentially, , putting time.sleep()
doesn't work either.
help appreciated.
twilio evangelist here.
each call client.calls.create simple http request twilios rest api tells start outbound phone call. calls made asynchronously, if wanted call function 10 times simultaneously start ten separate phone calls.
if want make calls in serial fashion, rather using loop start calls suggest starting first call , using statuscallback route handler have twilio tell when first call has completed (and why) , in handler, start next call.
each time active call completes, twilio request statuscallback route allowing start next call in sequence.
hope helps.
Comments
Post a Comment