static void Main(string[] args)
 {
     Response resp = new Response();
     resp.AddSpeak("Hi, Plivo calling", new Dictionary<string, string>() {
         { "language", "en-US" },
         { "voice", "WOMAN" }
     });
     resp.AddPlay("http://examples.com/play/Trumpet.mp3", new Dictionary<string, string>() {
         { "loop", "2" }
     });
     resp.AddWait(new Dictionary<string, string>() {
         { "length", "3" }
     });
     Console.WriteLine(resp.ToString());
 }
        public Program()
        {
            Get["/play"] = x =>
            {
                Plivo.XML.Response resp = new Plivo.XML.Response();

                // Add Play tag
                resp.AddPlay("https://s3.amazonaws.com/plivocloud/music.mp3", new Dictionary<string, string>() { });

                Debug.WriteLine(resp.ToString());

                var output = resp.ToString();
                var res = (Nancy.Response)output;
                res.ContentType = "text/xml";
                return res;
            };
        }
        public Program()
        {
            Get["/play"] = x =>
            {
                Plivo.XML.Response resp = new Plivo.XML.Response();

                // Add Play tag
                resp.AddPlay("https://s3.amazonaws.com/plivocloud/music.mp3", new Dictionary <string, string>()
                {
                });

                Debug.WriteLine(resp.ToString());

                var output = resp.ToString();
                var res    = (Nancy.Response)output;
                res.ContentType = "text/xml";
                return(res);
            };
        }
        public Program()
        {
            Get["/dial"] = x =>
            {
                Plivo.XML.Response resp = new Plivo.XML.Response();

                // Generate Dial XML
                Plivo.XML.Dial dial = new Plivo.XML.Dial(new Dictionary <string, string>()
                {
                    { "dialMusic", "http://dotnettest.apphb.com/custom_tone" } // Music to be played to the caller while the call is being connected.
                });
                dial.AddNumber("1111111111", new Dictionary <string, string>()
                {
                });

                resp.Add(dial);
                Debug.WriteLine(resp.ToString());

                var output = resp.ToString();
                var res    = (Nancy.Response)output;
                res.ContentType = "text/xml";
                return(res);
            };

            Get["/custom_tone"] = x =>
            {
                Plivo.XML.Response resp = new Plivo.XML.Response();

                // Add Play XML Tags
                resp.AddPlay("https://s3.amazonaws.com/plivocloud/music.mp3", new Dictionary <string, string>()
                {
                });

                Debug.WriteLine(resp.ToString());

                var output = resp.ToString();
                var res    = (Nancy.Response)output;
                res.ContentType = "text/xml";
                return(res);
            };
        }
        public Program()
        {
            Get["/dial"] = x =>
            {
                Plivo.XML.Response resp = new Plivo.XML.Response();

                // Generate Dial XML
                Plivo.XML.Dial dial = new Plivo.XML.Dial(new Dictionary<string, string>() 
                {
                    {"dialMusic","http://dotnettest.apphb.com/custom_tone"} // Music to be played to the caller while the call is being connected.
                });
                dial.AddNumber("1111111111", new Dictionary<string, string>() { });
                
                resp.Add(dial);
                Debug.WriteLine(resp.ToString());

                var output = resp.ToString();
                var res = (Nancy.Response)output;
                res.ContentType = "text/xml";
                return res;
            };

            Get["/custom_tone"] = x =>
            {
                Plivo.XML.Response resp = new Plivo.XML.Response();
             
                // Add Play XML Tags
                resp.AddPlay("https://s3.amazonaws.com/plivocloud/music.mp3", new Dictionary<string, string>() { });

                Debug.WriteLine(resp.ToString());

                var output = resp.ToString();
                var res = (Nancy.Response)output;
                res.ContentType = "text/xml";
                return res;
            };
        }
        public Program()
        {
            //  This file will be played when a caller presses 2.
            String PLIVO_SONG = "https://s3.amazonaws.com/plivocloud/music.mp3";
            // This is the message that Plivo reads when the caller dials in
            String IVR_MESSAGE1 = "Welcome to the Plivo IVR Demo App. Press 1 to listen to a pre recorded text in different languages. Press 2 to listen to a song.";

            String IVR_MESSAGE2 = "Press 1 for English. Press 2 for French. Press 3 for Russian";
            // This is the message that Plivo reads when the caller does nothing at all
            String NO_INPUT_MESSAGE = "Sorry, I didn't catch that. Please hangup and try again later.";
            // This is the message that Plivo reads when the caller inputs a wrong number.
            String WRONG_INPUT_MESSAGE = "Sorry, it's a wrong input.";

            Get["/response/ivr"] = x =>
            {
                Plivo.XML.Response resp = new Plivo.XML.Response();
                String             getdigits_action_url = "http://dotnettest.apphb.com/response/ivr";

                // Add GetDigits XML Tag
                GetDigits gd = new GetDigits("", new Dictionary <string, string>()
                {
                    { "action", getdigits_action_url },
                    { "method", "POST" },
                    { "timeout", "7" },
                    { "numDigits", "1" },
                    { "retries", "1" }
                });

                // Add Speak XML Tag
                gd.AddSpeak(IVR_MESSAGE1, new Dictionary <string, string>()
                {
                });
                resp.Add(gd);
                // Add Speak XML Tag
                resp.AddSpeak(NO_INPUT_MESSAGE, new Dictionary <string, string>()
                {
                });

                Debug.WriteLine(resp.ToString());

                var output = resp.ToString();
                var res    = (Nancy.Response)output;
                res.ContentType = "text/xml";
                return(res);
            };

            Post["/response/ivr"] = x =>
            {
                String digit = Request.Form["Digits"];
                Debug.WriteLine("Digit pressed : {0}", digit);

                Plivo.XML.Response resp = new Plivo.XML.Response();

                if (digit == "1")
                {
                    String getdigits_action_url = "http://dotnettest.apphb.com/response/tree";

                    // Add GetDigits XML Tag
                    GetDigits gd = new GetDigits("", new Dictionary <string, string>()
                    {
                        { "action", getdigits_action_url }, // The URL to which the digits are sent.
                        { "method", "GET" },                // Submit to action URL using GET or POST.
                        { "timeout", "7" },                 // Time in seconds to wait to receive the first digit.
                        { "numDigits", "1" },               // Maximum number of digits to be processed in the current operation.
                        { "retries", "1" } // Indicates the number of retries the user is allowed to input the digits
                    });

                    // Add Speak XML Tag
                    gd.AddSpeak(IVR_MESSAGE2, new Dictionary <string, string>()
                    {
                    });
                    resp.Add(gd);
                    // Add Speak XML Tag
                    resp.AddSpeak(NO_INPUT_MESSAGE, new Dictionary <string, string>()
                    {
                    });
                }
                else if (digit == "2")
                {
                    // Add Play XML Tag
                    resp.AddPlay(PLIVO_SONG, new Dictionary <string, string>()
                    {
                    });
                }
                else
                {
                    // Add Speak XML Tag
                    resp.AddSpeak(WRONG_INPUT_MESSAGE, new Dictionary <string, string>()
                    {
                    });
                }

                Debug.WriteLine(resp.ToString());

                var output = resp.ToString();
                var res    = (Nancy.Response)output;
                res.ContentType = "text/xml";
                return(res);
            };

            Get["/response/tree"] = x =>
            {
                Plivo.XML.Response resp  = new Plivo.XML.Response();
                String             digit = Request.Query["Digits"];

                // Add Speak XMLTag
                if (digit == "1")
                {
                    resp.AddSpeak("This message is being read out in English", new Dictionary <string, string>()
                    {
                        { "language", "en-GB" }
                    });
                }
                else if (digit == "2")
                {
                    resp.AddSpeak("Ce message est lu en français", new Dictionary <string, string>()
                    {
                        { "language", "fr-FR" }
                    });
                }
                else if (digit == "3")
                {
                    resp.AddSpeak("Это сообщение было прочитано в России", new Dictionary <string, string>()
                    {
                        { "language", "ru-RU" }
                    });
                }
                else
                {
                    resp.AddSpeak(WRONG_INPUT_MESSAGE, new Dictionary <string, string>()
                    {
                    });
                }

                Debug.WriteLine(resp.ToString());

                var output = resp.ToString();
                var res    = (Nancy.Response)output;
                res.ContentType = "text/xml";
                return(res);
            };
        }
        public Program()
        {
            //  This file will be played when a caller presses 2.
            String PLIVO_SONG = "https://s3.amazonaws.com/plivocloud/music.mp3";
            // This is the message that Plivo reads when the caller dials in
            String IVR_MESSAGE1 = "Welcome to the Plivo IVR Demo App. Press 1 to listen to a pre recorded text in different languages. Press 2 to listen to a song.";

            String IVR_MESSAGE2 = "Press 1 for English. Press 2 for French. Press 3 for Russian";
            // This is the message that Plivo reads when the caller does nothing at all
            String NO_INPUT_MESSAGE = "Sorry, I didn't catch that. Please hangup and try again later.";
            // This is the message that Plivo reads when the caller inputs a wrong number.
            String WRONG_INPUT_MESSAGE = "Sorry, it's a wrong input.";

            Get["/response/ivr"] = x =>
            {
                Plivo.XML.Response resp = new Plivo.XML.Response();
                String getdigits_action_url = "http://dotnettest.apphb.com/response/ivr";

                // Add GetDigits XML Tag
                GetDigits gd = new GetDigits("", new Dictionary<string, string>()
                {
                    {"action", getdigits_action_url},
                    {"method", "POST"},
                    {"timeout","7"},
                    {"numDigits","1"},
                    {"retries","1"}
                });

                // Add Speak XML Tag
                gd.AddSpeak(IVR_MESSAGE1, new Dictionary<string, string>() { });
                resp.Add(gd);
                // Add Speak XML Tag
                resp.AddSpeak(NO_INPUT_MESSAGE, new Dictionary<string, string>() { });

                Debug.WriteLine(resp.ToString());

                var output = resp.ToString();
                var res = (Nancy.Response)output;
                res.ContentType = "text/xml";
                return res;
            };

            Post["/response/ivr"] = x =>
            {
                String digit = Request.Form["Digits"];
                Debug.WriteLine("Digit pressed : {0}", digit);

                Plivo.XML.Response resp = new Plivo.XML.Response();

                if (digit == "1")
                {
                    String getdigits_action_url = "http://dotnettest.apphb.com/response/tree";

                    // Add GetDigits XML Tag
                    GetDigits gd = new GetDigits("", new Dictionary<string, string>()
                {
                    {"action", getdigits_action_url}, // The URL to which the digits are sent. 
                    {"method", "GET"}, // Submit to action URL using GET or POST.
                    {"timeout","7"}, // Time in seconds to wait to receive the first digit.
                    {"numDigits","1"}, // Maximum number of digits to be processed in the current operation. 
                    {"retries","1"} // Indicates the number of retries the user is allowed to input the digits
                });

                    // Add Speak XML Tag
                    gd.AddSpeak(IVR_MESSAGE2, new Dictionary<string, string>() { });
                    resp.Add(gd);
                    // Add Speak XML Tag
                    resp.AddSpeak(NO_INPUT_MESSAGE, new Dictionary<string, string>() { });
                }
                else if (digit == "2")
                {
                    // Add Play XML Tag
                    resp.AddPlay(PLIVO_SONG, new Dictionary<string, string>() { });
                }
                else
                {
                    // Add Speak XML Tag
                    resp.AddSpeak(WRONG_INPUT_MESSAGE, new Dictionary<string, string>() { });
                }

                Debug.WriteLine(resp.ToString());

                var output = resp.ToString();
                var res = (Nancy.Response)output;
                res.ContentType = "text/xml";
                return res;
            };

            Get["/response/tree"] = x =>
            {
                Plivo.XML.Response resp = new Plivo.XML.Response();
                String digit = Request.Query["Digits"];

                // Add Speak XMLTag
                if (digit == "1")
                {
                    resp.AddSpeak("This message is being read out in English", new Dictionary<string, string>()
                    {
                        {"language","en-GB"}
                    });
                }
                else if (digit == "2")
                {
                    resp.AddSpeak("Ce message est lu en français", new Dictionary<string, string>()
                    {
                        {"language","fr-FR"}
                    });
                }
                else if (digit == "3")
                {
                    resp.AddSpeak("Это сообщение было прочитано в России", new Dictionary<string, string>()
                    {
                        {"language","ru-RU"}
                    });
                }
                else
                {
                    resp.AddSpeak(WRONG_INPUT_MESSAGE, new Dictionary<string, string>() { });
                }

                Debug.WriteLine(resp.ToString());

                var output = resp.ToString();
                var res = (Nancy.Response)output;
                res.ContentType = "text/xml";
                return res;
            };
        }