Search code examples
iosnode.jsparse-platformtwiliotwilio-twiml

Twiml getting callers number


In my app I want to enable User A to call a twilio number and then User B to receive a call from the twilio number and let both Users talk.

When call button is pressed the twilio number is called.
Then the /hello function is executed.

Xcode

NSString *callString = [NSString stringWithFormat:@"telprompt://TwilioNumber"];

 [[UIApplication sharedApplication] openURL:[NSURL URLWithString:callString]];

I put the twilio number in place of 'twilionumber' and I hardcoded a number in place of 'ToCallNumber'.

Parse.com Cloud Code

////TWILIO
app.get('/hello', function(request, response) {
    var twiml = new twilio.TwimlResponse('');

    twiml.dial({callerId:'twilionumber'}, 'ToCallNumber'); //working

    response.type('text/xml');
    response.send(twiml.toString(''));
    });
    app.listen();

So far no problem. What I want is to change the ToCallNumber based on who is making the call. I have linked the users in a Parse Datatable. I need to get the caller's phonenumber in /hello function in order to call the correct user.

In the console I see the callers phone number.

Input: {"method"=>"GET", "url"=>"/hello?AccountSid=....... From=%2B"CAllersPhonenumber"&.....

I tried getting the From parameter by doing like request.params.From, From, twiml.From, twiml.params.From and other things maybe more than two hours. Can someone explain how to get that From value please?


Solution

  • I finally found the answer. It is request.param not params..

    Twilio $_REQUEST['From'] equivalent for node.js

    request.param('From');