kshitij vyas
kshitij vyas

Reputation: 21

Setting up call between two twilio numbers

We want to setup a call between two purchased twilio number. We have done the configuration for both number on twilio account. We have setup the webhook for both outbound and incoming call. Right now we are able to call from twilio to personal number, But call get cut after the "say" message on incoming webhook.

Here is the sample code make call webhook for outbound call:

@app.route('/placeCall', methods=['GET', 'POST'])
def placeCall():
  account_sid = os.environ.get("ACCOUNT_SID", ACCOUNT_SID)
  api_key = os.environ.get("API_KEY", API_KEY)
  api_key_secret = os.environ.get("API_KEY_SECRET", API_KEY_SECRET)

  client = Client(api_key, api_key_secret, account_sid)
  to = request.values.get("to")
  
    to = "+13344296930" // this is twilio number.
  
  #to = "13373525804"
  print(to)
  call = None

  if to is None or len(to) == 0:
    print("in the if")
    print(to)
    call = client.calls.create(url=request.url_root + 'incoming', to='client:' + IDENTITY, from_=CALLER_ID)
  elif to[0] in "+13344296930" and (len(to) == 1 or to[1:].isdigit()):
    print("in the elseif")
    print(to)

    call = client.calls.create(url=request.url_root + 'incoming', to=to, from_=CALLER_NUMBER)
  else:
    print("in the else")
    call = client.calls.create(url=request.url_root + 'incoming', to='client:' + to, from_=CALLER_ID)
  return str(call)

Here is incoming call code webhook:

@app.route('/incoming', methods=['GET', 'POST'])
def incoming():
  resp = VoiceResponse()
  print("incoming response is---")
  print(resp)
  resp.say("Congratulations! You have received your first inbound call! Good bye.")

  #resp.dial("+13344296930")
  return str(resp)

So we are able to hear the Congratulation message. But nothing is happening after that, our nunmber never receive the call. Can you please guide me if there need to be some other even handle afteer this message that I am missing. To my understading there shall be a call to the giving twilio number. Any help will be helpful.

Note: I am able to call to my peersonal number by passing it in incoming-call webhook.

I am expecting a call between twilio number to other twilio number in mobile application

Upvotes: 0

Views: 42

Answers (0)

Related Questions