How to retrieve "to" number in Twilio Voice callbacks when using React frontend and Python backend?

49 views Asked by At

I have created a Twilio application in Python using the client like this:

application = client.applications.create(voice_method='POST',
                                         voice_url='<voice-url>',
                                         status_callback='<voice-status-callback-url>',
                                         status_callback_method="POST",
                                         sms_url='<sms-url>',
                                         sms_method='POST',
                                         sms_status_callback='<sms-status-callback-url>',
                                         friendly_name='xyz')

Whenever a call needs to be made, I generate a token, add voice grant and send the token to React Front-end, and React uses JS SDK's Device.connect() to make the call like so:

  const callTwilioNumber = (token, phoneNumber) => {
    const postData = {
      phoneNumber: phoneNumber
    }
    currentCallDeviceCopy = new Device(token);
    let conn = await currentCallDeviceCopy.connect({ 
      params: {
        To:response.data.data,
      }
    });
    }).catch((error) => {
      ... Error handling ...
    });
  }

When I get callbacks using this implementation, The "to" parameter within the callback is an empty string. Is there any way to get the "to" num in the callback?

I have tried sending custom parameters in the Device.connect() method, but these custom parameters go to the application, and are not returned in the callbacks.

1

There are 1 answers

0
HeetGorakhiya On BEST ANSWER

Found the answer to my issue, and I'm posting the resolution for reference. The issue was that the call I was making had child calls that contained "to" and "from" numbers and other information as well. Whenever a call is made to a number which contains automated routing, call forwarding, or potentially even answering machines, then another child call is being made to the target phone number.