0

I'm building a system to allow sales representative to call from PC to their customer on phone. I'm using Dial feature of twilio:

var callerId = ConfigurationManager.AppSettings["TwilioCallerId"];
var response = new VoiceResponse();
var dial = new Dial(callerId: callerId);
if (Regex.IsMatch(to, "^[\\d\\+\\-\\(\\) ]+$")){
    dial.Number(to);
}else{
    dial.Client(to);
}
response.Dial(dial);

This works properly to connect sales representative with their customers.

Now i have a requirement to play a prerecorded voice if end user do not picks up the call and its reached to voicemail for leaving a message on an answering machine. I have seen this feature in rest api but not sure how it can be used with dial to connect sales representative and customer.

What's the best way to achieve this?

Milind Anantwar
  • 81,290
  • 25
  • 94
  • 125

1 Answers1

0

From the Twilio Document centre:

static void Main(string[] args)
{
    // Find your Account Sid and Token at twilio.com/console
    const string accountSid = "ACXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX";
    const string authToken = "your_auth_token";

    TwilioClient.Init(accountSid, authToken);

    var call = CallResource.Create(
        machineDetection: "Enable",
        url: new Uri("https://handler.twilio.com/twiml/EH8ccdbd7f0b8fe34357da8ce87ebe5a16"),
        to: new Twilio.Types.PhoneNumber("+1562300000"),
        from: new Twilio.Types.PhoneNumber("+18180000000"),
        pathAccountSid: "ACXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX"
    );

    Console.WriteLine(call.Sid);
}

Where the result of the call can be machine_start, human, fax, unknown. So depending on the result you can play your message or connect to human?

Link here for you: TwilioDocs

EDIT

Scroll to the bottom of this TwilioDocs, seems like you hook on callback of the CallResource? Their version 5 is different from what I'm used to.

Wurd
  • 465
  • 2
  • 15