0

I am using Twilio Appi for phone verification my this snippet is generating verification call.

ValidationRequestResult result = client.AddOutgoingCallerId(options.To, GeneratedVerificationOption());

i want to check that either call was successful or not

Soner Gönül
  • 97,193
  • 102
  • 206
  • 364

1 Answers1

0

The AddOutgoingCallerId method accepts a OutgoingCallerIdOptions object as a method parameter, which you can use to provide a StatusCallback URL.

var options = OutgoingCallerIdOptions() { StatusCallback="http://example.com/result" }
result = client.AddOutgoingCallerId("+15555555555", options);
if (result.RestException!=null) {
    Debug.Writeline("error making validation phone call");
}

Twilio will make a request to this URL when the verification call completes, passing you the result of the verification as the VerificationStatus parameter. If you are using ASP.NET MVC you can just add this as an action method parameter:

public ActionMethod PostResult(string VerificationStatus) {
    if (VerificationStatus=="success") {

    }
}

Hope that helps.

Devin Rader
  • 10,260
  • 1
  • 20
  • 32
  • Thank you @Dvein rader for your respone – user3789726 Jan 31 '16 at 16:21
  • It will, but you will need to use a tool like ngrok (ngrok.com) to expore your local website out to the public internet via a public domain. In that case the StatusCallback value would be `[yourdomain].ngrok.io/[YourRoute]/` – Devin Rader Feb 01 '16 at 14:29
  • Hey @Devin i am not able to get status of call, I am generating call like this `'ValidationRequestResult result = client.AddOutgoingCallerId("+16099575303", GeneratedVerificationOption());` Below is the method to generate options `public OutgoingCallerIdOptions GeneratedVerificationOption() { OutgoingCallerIdOptions options = new OutgoingCallerIdOptions(); options.StatusCallback = "http://7a37fb95.ngrok.io/Home/PostResult"; // options.StatusCallbackMethod = "POST"; return options; }` and my target action is like – user3789726 Feb 15 '16 at 06:09
  • Do you see the HTTP request fom Twilio logged by ngrok? Have you checked the Twilio logs to see if your application is returning an error to Twilio? – Devin Rader Feb 18 '16 at 15:58