0
votes

I am using the browser client and trying to capture the number the caller dialed to reach us. Instead of conn.parameters.To giving me the number the caller dialed, it's giving me the client id that the calls was sent to.

How can I get the dialed number when receiving an incoming call in the browser client?

Thanks

2

2 Answers

1
votes

OK, here is how I solved this. I liked Devins ideas but didn't want to involve third part libraries or a database just to accomplish this task.

I hope I am explaining this well enough so it helps someone else down the road.

OK, I solved this by doing the following:

I created a callinfo.php page which required one parameter, the callsid. In the .js page I was able to get the callsid with

var myCallSid = conn.parameters.CallSid;

inside: Twilio.Device.incoming(function (conn) {

Then I did an ajax call to my callinfo.php by posting the myCallSid to it.

Inside my callinfo.php page the call sid didn't really get me the To number I was after because the callsid was not really for the incoming call, it was for the second leg of the call where the client was called. So, technically the To parameter was really client: joe shmoe or something like that.

So.. What I did was inside my callinfo.php I pulled the call info of the first leg of the call by referencing the parent_call_sid of the second callsid.

Once I had the parentcallsid I used that to lookup info on the call, grab the "to" and whatever else I wanted and return it to my .js file. Once in the JS file, I could of course do what I wanted with the beautiful gems of data I had mined :-)

No database calls, no third party libraries or tools and I got the data I wanted and then some. In the PHP page I can grab all sorts of other data as shown here: https://www.twilio.com/docs/api/rest/call

0
votes

Twilio evangelist here.

Unfortunately thats not something we pass along as part of the parameters object. What I would do in your scenario is either:

a) use something like socket.io or signalr (or some other real-time communication framework) to send the From phone number from your server app that is handling Twilios HTTP request to the client, or

b) when Twilio makes HTTP request to your app, have your server app store the From phone number and then from the client make an ajax request back to the server to retrieve it.

Hope that helps.