0

I am trying to achieve following functionality with twillio.js on client side and ASP.NET Mvc website at the backend.

I need to connect a call between real phone number of sales person and phone number of a potential client.

For example on button click , I need to call potential client , and in a case the client answered , i need to add to the call sales person (that is not using twillio number , using regular landline)

Is it possible to achieve with twillio ?

  • 3
    Yes, it's possilble. This is pretty close to what you want: Click To Call (C# | ASP.NET MVC) https://www.twilio.com/docs/tutorials/walkthrough/click-to-call/csharp/mvc – Alex Baban Jul 11 '16 at 02:57

1 Answers1

1

Karen, hello!

Were you able to achieve what you were looking for with Alex's suggestion of the Click to Call tutorial?

https://www.twilio.com/docs/tutorials/walkthrough/click-to-call/csharp/mvc

The above uses a web form and ajax to send the form asynchronously. Then we handle the POST from our web form and connect the call via the REST API.

    /// <summary>
    /// Handle a POST from our web form and connect a call via REST API
    /// </summary>
    [HttpPost]
    public ActionResult Call(Contact contact)
    {
        if (!ModelState.IsValid)
        {
            return Json(new { success = false, message = (ModelState.Values.First()).Errors.First().ErrorMessage, });
        }

        var twilioNumber = ConfigurationManager.AppSettings["TwilioNumber"];

        // The following line is how you should get the absolute Uri in an internet faced 
        // server or a production environment
        // var handlerUri = Url.Action("Connect", "Call", null, Request.Url.Scheme);

        // this line allow us to get the absolute Uri in a local computer using a secure instrospectable 
        // service like ngrok ;)
        var handlerUri = GetTestUri();

        _twilioService.CallToNumber(twilioNumber, contact.Phone.Replace(" ", ""), handlerUri);
        return Json(new { success = true, message = "Phone call incoming!"});
    }

Please let me know if this is helpful for your use case.

Megan Speir
  • 3,745
  • 1
  • 15
  • 25