Home > DeveloperSection > Forums > Twilio inbound call handling
Jack C
Jack C

Total Post:13

Points:91
Posted on    October-18-2010 10:13 AM

 ASP.Net ASP.Net 
Ratings:


 1 Reply(s)
 2067  View(s)
Rate this:
Hi,

I am using Twilio service to handle inbound call to a number, but I'm unable to do that.
You can find more about Twilio api at http://www.twilio.com/.

Please help its urgent.


Alex R
Alex R

Total Post:40

Points:280
Posted on    October-20-2010 7:38 AM

Hello Jack,

You can do this by simply creating an .aspx page. Write the following code to accomplish your goal.

string strxml = "<?xml version=\"1.0\" encoding=\"utf-8\" ?>";

    protected void Page_Load(object sender, EventArgs e)

    {       

        HttpContext current = HttpContext.Current;

 

        string pollId = null;

        string msg;

        if (!string.IsNullOrEmpty(current.Request.Form["Digits"]))

        {

            pollId = current.Request.Form["Digits"];

            if (pollId == "1")

            {

                msg = "You will get the list of latest offer soon. Thanks for calling mindstick.";

                current.Response.Write(strxml + @"<Response><Say voice='woman'>" + msg + @"</Say><Sms>We are processing your request. Thanks for calling MindStick.</Sms></Response>");

            }

            else if (pollId == "2")

            {

                msg = "This is not the right time to talk to our experts, please call later. Thanks for calling mindstick.";

                current.Response.Write(strxml + @"<Response><Say voice='woman'>" + msg + @"</Say></Response>");

            }

            else

            {

                msg = "You have provide the wrong input. Please provide correct input.Please press 1 for latest offers and press 2 to talk to our experts.";

                poll(current, msg);

            }

        }

        if (string.IsNullOrEmpty(pollId))

        {

            string introMsg = "Welcome to MindStick Software. Please press 1 for latest offers and press 2 to talk to our experts.";

            poll(current, introMsg);

        }

    }

    protected void poll(HttpContext current, string introMsg)

    {

        string actionSelf = current.Request.Url.ToString().Replace(":" + current.Request.Url.Port.ToString(), "");       

        current.Response.Write(strxml + @"<Response><Say voice='woman'>Welcome.</Say><Gather method = 'Post' numDigits='1' action ='" + actionSelf + "'><Say voice='woman'>" + introMsg + @"</Say></Gather></Response>");

        return;

    }

You can make changes in the message according to your needs.

Now, host this page on your server and give the address of this web page in Twilio Voice URL.

Now call the Twilio Number and check.




Don't want to miss updates? Please click the below button!

Follow MindStick