Nick
Nick

Reputation: 175

Twilio - Call Forwarding

I am building an application where a user will call my Twilio Number. After connecting, Twilio will call another user and connect the two parties. However, the number displayed for the second party should be Twilio's number (or no caller ID), not the user's number.

I tired adding SIP header such as privacy = full & p-asserted-identity="anonymous" but none is working.

Code I am using for the callback:

[HttpPost]
    public async Task<ActionResult> Connect(string from, string to)
    {
        //var outgoingPhoneNumber = await GatherOutgoingPhoneNumberAsync(from, to);

        var response = new TwilioResponse();
        response.Say("Please wait while we contact the other party");
        response.Dial("+14085993263", new {  });

        return TwiML(response);
    }

Is there anyway to do that?

Upvotes: 0

Views: 540

Answers (1)

Marcos Placona
Marcos Placona

Reputation: 21730

Twilio developer evangelist here.

You're very close to the solution, but what want to do is add a callerid attribute to the Dial verb. That way, you can either add your Twilio number, or your own business' verified number. To do that just change your code to the following:

[HttpPost]
public async Task<ActionResult> Connect(string from, string to)
{
    var response = new TwilioResponse();
    response.Say("Please wait while we contact the other party");
    response.Dial("+14085993263", new { callerId = "+1234567890" });
    return TwiML(response);
}

Make sure you replace callerId with the number you wish to use. The caller ID can only be one of your Twilio numbers or a verified number as stated above.

Hope this helps you

Upvotes: 2

Related Questions