TWILIO INBOUND CALL HANDLING

Jack C

Total Post:13

Points:91
Posted by  Jack C
 2860  View(s)
Ratings:
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.
  1. Alex R

    Post:40

    Points:280
    Re: Twilio inbound call handling

    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.



Answer

NEWSLETTER

Enter your email address here always to be updated. We promise not to spam!