Inheritance: PlivoElement
        public Program()
        {
            Get["/speech"] = x =>
            {
                Plivo.XML.Response resp = new Plivo.XML.Response();

                // Add Speak XML Tag
                resp.AddSpeak("This is English", new Dictionary<string, string>()
                {
                    {"language", "en-GB"},
                    {"voice", "MAN"}
                });

                // Add Speak XML Tag
                resp.AddSpeak("Ce texte généré aléatoirement peut-être utilisé dans vos maquettes", new Dictionary<string, string>()
                {
                    {"language", "fr-FR"},
                    {"voice", "WOMAN"}
                });

                // Add Speak XML Tag
                resp.AddSpeak("Это случайно сгенерированный текст может быть использован в макете", new Dictionary<string, string>()
                {
                    {"language", "ru-RU"},
                    {"voice", "WOMAN"}
                });

                Debug.WriteLine(resp.ToString());

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

                // Add Speak XML Tag
                resp.AddSpeak("Connecting your call..", new Dictionary <string, string>()
                {
                });

                // Add Dial XML Tag
                Plivo.XML.Dial dial = new Plivo.XML.Dial(new Dictionary <string, string>()
                {
                });
                dial.AddNumber("2222222222", 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);
            };
        }
        public Program()
        {
            Get["/hangup"] = x =>
            {
                Plivo.XML.Response resp = new Plivo.XML.Response();

                // Add Speak XML Tag
                resp.AddSpeak("This call will be hung up in 1 minute", new Dictionary<string, string>(){});

                // Add Hangup XML Tag
                resp.AddHangup(new Dictionary<string, string>() 
                {
                    {"reason","busy"}, // Specify the reason for hangup
                    {"schedule","60"} // Schedule the hangup
                });    

                Debug.WriteLine(resp.ToString());

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

        }
Exemplo n.º 4
0
        public Program()
        {
            Get["/speech"] = x =>
            {
                Plivo.XML.Response resp = new Plivo.XML.Response();

                // Add Speak XML Tag
                resp.AddSpeak("This is English", new Dictionary <string, string>()
                {
                    { "language", "en-GB" },
                    { "voice", "MAN" }
                });

                // Add Speak XML Tag
                resp.AddSpeak("Ce texte généré aléatoirement peut-être utilisé dans vos maquettes", new Dictionary <string, string>()
                {
                    { "language", "fr-FR" },
                    { "voice", "WOMAN" }
                });

                // Add Speak XML Tag
                resp.AddSpeak("Это случайно сгенерированный текст может быть использован в макете", new Dictionary <string, string>()
                {
                    { "language", "ru-RU" },
                    { "voice", "WOMAN" }
                });

                Debug.WriteLine(resp.ToString());

                var output = resp.ToString();
                var res    = (Nancy.Response)output;
                res.ContentType = "text/xml";
                return(res);
            };
        }
        public Program()
        {
            Get["/greet_caller"] = x =>
            {
                var callers = new Dictionary<string, string>() { 
                    {"1111111111","ABCDE"},
                    {"2222222222","VWXYZ"},
                    {"3333333333","QWERTY"}
                };
 
                String fromNumber = Request.Query["From"];
 
                Plivo.XML.Response resp = new Plivo.XML.Response();
 
                if (callers.ContainsKey(fromNumber))
                {
                    string body = "Hello " + callers[fromNumber];
                    resp.AddSpeak(body,new Dictionary<string, string>(){});
                }
                else
                {
                    resp.AddSpeak("Hello Stranger!", new Dictionary<string, string>() { });
                }
 
                var output = resp.ToString();
                var res = (Nancy.Response)output;
                res.ContentType = "text/xml";
                return res;
            };
        }
        public Program()
        {
            Get["/forward"] = x =>
            {
                // The phone number of the person calling your Plivo number,
                // we'll use this as the Caller ID when we forward the call.
                String from_number = Request.Query["From"];

                // The number you would like to forward the call to.
                String forwarding_number = "2222222222";

                Plivo.XML.Response resp = new Plivo.XML.Response();
                Plivo.XML.Dial     dial = new Plivo.XML.Dial(new Dictionary <string, string>()
                {
                    { "callerId", from_numbers } // The phone number to be used as the caller id. It can be set to the from_number or any custom number.
                });
                dial.AddNumber(forwarding_number, 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);
            };
        }
        public Program()
        {
            Get["/call_hunting"] = x =>
            {
                Plivo.XML.Response resp = new Plivo.XML.Response();

                // Generate Dial XML
                Plivo.XML.Dial dial = new Plivo.XML.Dial(new Dictionary <string, string>()
                {
                });
                dial.AddUser("sip:[email protected]", new Dictionary <string, string>()
                {
                });
                dial.AddNumber("2222222222", new Dictionary <string, string>()
                {
                });
                dial.AddNumber("3333333333", 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);
            };
        }
Exemplo n.º 8
0
        public Program()
        {
            Get["/hangup"] = x =>
            {
                Plivo.XML.Response resp = new Plivo.XML.Response();

                // Add Speak XML Tag
                resp.AddSpeak("This call will be hung up in 1 minute", new Dictionary <string, string>()
                {
                });

                // Add Hangup XML Tag
                resp.AddHangup(new Dictionary <string, string>()
                {
                    { "reason", "busy" }, // Specify the reason for hangup
                    { "schedule", "60" } // Schedule the hangup
                });

                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>() 
                {
                    {"action","http://dotnettest.apphb.com/dial_status"}, // Redirect to this URL after leaving Dial.
                    {"method","GET"} // Submit to action URL using GET or POST.
                });
                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["/dial_status"] = x =>
            {
                // After completion of the call, Plivo will report back the status to the action URL in the Dial XML.
                String status = Request.Query["DialStatus"];
                String aleg = Request.Form["DialALegUUID"];
                String bleg = Request.Form["DialBLegUUID"];

                Debug.WriteLine("Status : {0}, ALeg UUID : {1}, BLeg UUID : {2}", status, aleg, bleg);
                return "OK";
            };
        }
        public Program()
        {
            Get["/forward"] = x =>
            {
                // The phone number of the person calling your Plivo number,
                // we'll use this as the Caller ID when we forward the call.
                String from_number = Request.Query["From"];

                // The number you would like to forward the call to.
                String forwarding_number = "2222222222";

                Plivo.XML.Response resp = new Plivo.XML.Response();
                Plivo.XML.Dial dial = new Plivo.XML.Dial(new Dictionary<string, string>() 
                {
                    {"callerId", from_numbers} // The phone number to be used as the caller id. It can be set to the from_number or any custom number.
                });
                dial.AddNumber(forwarding_number, 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;
            };
        }
Exemplo n.º 11
0
        public Program()
        {
            Get["/greet_caller"] = x =>
            {
                var callers = new Dictionary <string, string>()
                {
                    { "1111111111", "ABCDE" },
                    { "2222222222", "VWXYZ" },
                    { "3333333333", "QWERTY" }
                };

                String fromNumber = Request.Query["From"];

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

                if (callers.ContainsKey(fromNumber))
                {
                    string body = "Hello " + callers[fromNumber];
                    resp.AddSpeak(body, new Dictionary <string, string>()
                    {
                    });
                }
                else
                {
                    resp.AddSpeak("Hello Stranger!", new Dictionary <string, string>()
                    {
                    });
                }

                var output = resp.ToString();
                var res    = (Nancy.Response)output;
                res.ContentType = "text/xml";
                return(res);
            };
        }
Exemplo n.º 12
0
        public Program()
        {
            Get["/seq_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>()
                {
                    { "timeout", "20" }, // The duration (in seconds) for which the called party has to be given a ring.
                    { "action", "http://dotnettest.apphb.com/dial_status" } // Redirect to this URL after leaving Dial.
                });
                dial.AddNumber("1111111111", new Dictionary <string, string>()
                {
                });
                dial.AddNumber("2222222222", 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);
            };
        }
Exemplo n.º 13
0
        public Program()
        {
            Get["/reject_caller"] = x =>
            {
                string[] blacklist = { "1111111111", "2222222222" };

                String fromNumber = Request.Query["From"];

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

                if (blacklist.Equals(fromNumber))
                {
                    resp.AddHangup(new Dictionary <string, string>()
                    {
                        { "reason", "rejected" }
                    });
                }
                else
                {
                    resp.AddSpeak("Hello, from Plivo!", new Dictionary <string, string>()
                    {
                    });
                }

                var output = resp.ToString();
                var res    = (Nancy.Response)output;
                res.ContentType = "text/xml";
                return(res);
            };
        }
        public Program()
        {
            Get["/reject_caller"] = x =>
            {
                string[] blacklist = {"1111111111","2222222222"};
 
                String fromNumber = Request.Query["From"];
 
                Plivo.XML.Response resp = new Plivo.XML.Response();
 
                if (blacklist.Equals(fromNumber))
                {
                    resp.AddHangup(new Dictionary<string, string>()
                {
                    {"reason", "rejected"}
                });
                }
                else
                {
                    resp.AddSpeak("Hello, from Plivo!", new Dictionary<string, string>() { });
                }
 
                var output = resp.ToString();
                var res = (Nancy.Response)output;
                res.ContentType = "text/xml";
                return res;
            };
        }
        public Program()
        {
            Get["/record_api"] = x =>
            {
                Plivo.XML.Response resp = new Plivo.XML.Response();
                String getdigits_action_url = "http://dotnettest.apphb.com/recording_action";
                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.
                    {"numDigitd","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
                    {"redirect","false"} // Redirect to action URL if true. If false,only request the URL and continue to next element.
                });

                gd.AddSpeak("Press 1 to record this call", new Dictionary<string, string>());
                resp.Add(gd);
                resp.AddWait(new Dictionary<string, string>() 
                {
                    {"length","10"} // Time to wait in seconds
                });

                Debug.WriteLine(resp.ToString());

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

            Get["/recording_action"] = x =>
            {
                String digits = Request.Query["Digits"];
                String uuid = Request.Query["CallUUID"];
                Debug.WriteLine("Digit pressed : {0}, Call UUID : {1}", digits, uuid);

                if (digits == "1")
                {
                    string auth_id = "Your AUTH_ID";
                    string auth_token = "Your AUTH_TOKEN";

                    RestAPI plivo = new RestAPI(auth_id, auth_token);

                    IRestResponse<Plivo.API.Record> resp = plivo.record(new Dictionary<string, string>() 
                    {
                        { "call_uuid", uuid } // ID of the call
                    });

                    Debug.WriteLine(resp.Content);
                }
                else
                {
                    Debug.WriteLine("Invalid");
                }

                return "OK";
            };
        }
Exemplo n.º 16
0
        public Program()
        {
            Get["/record_api"] = x =>
            {
                Plivo.XML.Response resp = new Plivo.XML.Response();
                String             getdigits_action_url = "http://dotnettest.apphb.com/recording_action";
                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.
                    { "numDigitd", "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
                    { "redirect", "false" } // Redirect to action URL if true. If false,only request the URL and continue to next element.
                });

                gd.AddSpeak("Press 1 to record this call", new Dictionary <string, string>());
                resp.Add(gd);
                resp.AddWait(new Dictionary <string, string>()
                {
                    { "length", "10" } // Time to wait in seconds
                });

                Debug.WriteLine(resp.ToString());

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

            Get["/recording_action"] = x =>
            {
                String digits = Request.Query["Digits"];
                String uuid   = Request.Query["CallUUID"];
                Debug.WriteLine("Digit pressed : {0}, Call UUID : {1}", digits, uuid);

                if (digits == "1")
                {
                    string auth_id    = "Your AUTH_ID";
                    string auth_token = "Your AUTH_TOKEN";

                    RestAPI plivo = new RestAPI(auth_id, auth_token);

                    IRestResponse <Plivo.API.Record> resp = plivo.record(new Dictionary <string, string>()
                    {
                        { "call_uuid", uuid } // ID of the call
                    });

                    Debug.WriteLine(resp.Content);
                }
                else
                {
                    Debug.WriteLine("Invalid");
                }

                return("OK");
            };
        }
Exemplo n.º 17
0
        public Program()
        {
            Get["/response/conference"] = x =>
            {
                Plivo.XML.Response resp = new Plivo.XML.Response();

                //  Add Speak XML Tag
                resp.AddSpeak("You will now be placed into a demo conference. This is brought to you by Plivo. To know more, visit us at Plivo.com", new Dictionary <string, string>()
                {
                });

                // Add Conference XML Tag
                resp.AddConference("demo", new Dictionary <string, string>()
                {
                    { "enterSound", "beep:2" },                                              // Used to play a sound when a member enters the conference
                    { "record", "true" },                                                    // Option to record the call
                    { "action", "http://dotnettest.apphb.com/response/conf_action" },        // URL to which the API can send back parameters
                    { "method", "GET" },                                                     // method to invoke the action Url
                    { "callbackUrl", "http://dotnettest.apphb.com/response/conf_callback" }, // If specified, information is sent back to this URL
                    { "callbackMethod", "GET" },                                             // Method used to notify callbackUrl
                });

                Debug.WriteLine(resp.ToString());

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

            // Action URL Example
            Get["/response/conf_action"] = x =>
            {
                String conf_name   = Request.Query["ConferenceName"];
                String conf_uuid   = Request.Query["ConferenceUUID"];
                String conf_mem_id = Request.Query["ConferenceMemberID"];
                String record_url  = Request.Query["RecordUrl"];
                String record_id   = Request.Query["RecordingID"];

                Debug.WriteLine("Conference Name : {0}, Conference UUID : {1}, Conference Member ID : {2}, Record URL : {3}, Record ID : {4}", conf_name, conf_uuid, conf_mem_id, record_url, record_id);
                return("Done");
            };

            //  Callback URL Example
            Get["/response/conf_callback"] = x =>
            {
                String conf_action = Request.Query["ConferenceAction"];
                String conf_name   = Request.Query["ConferenceName"];
                String conf_uuid   = Request.Query["ConferenceUUID"];
                String conf_mem_id = Request.Query["ConferenceMemberID"];
                String call_uuid   = Request.Query["CallUUID"];
                String record_url  = Request.Query["RecordUrl"];
                String record_id   = Request.Query["RecordingID"];

                Debug.WriteLine("Conference Action : {0}, Conference Name : {1}, Conference UUID : {2}, Conference Member ID : {3}, Call UUID : {4}, Record URL : {5}, Record ID : {6}", conf_action, conf_name, conf_uuid, conf_mem_id, call_uuid, record_url, record_id);
                return("Done");
            };
        }
Exemplo n.º 18
0
        public Program()
        {
            Get["/speak_api"] = x =>
            {
                Plivo.XML.Response resp = new Plivo.XML.Response();
                
                String getdigits_action_url = "http://dotnettest.apphb.com/speak_action";

                // 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. 
                    {"retries","1"}, // Indicates the number of retries the user is allowed to input the digits,
                    {"redirect","false"} // Redirect to action URL if true. If false,only request the URL and continue to next element.
                });

                // Add GetDigits Speak XML Tag
                gd.AddSpeak("Press 1 to listen to a message",new Dictionary<string,string>());
                resp.Add(gd);

                // Add Wait XML Tag
                resp.AddWait(new Dictionary<string, string>() 
                {
                    {"length","10"}
                });

                Debug.WriteLine(resp.ToString());

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

            Get["/speak_action"] = x =>
            {
                String digits = Request.Query["Digits"];
                String uuid = Request.Query["CallUUID"];
                Debug.WriteLine("Digit pressed : {0}, Call UUID : {1}",digits, uuid );

                RestAPI plivo = new RestAPI("Your AUTH_ID", "Your AUTH_TOKEN";

                // Call to Speak API
                IRestResponse<GenericResponse> resp = plivo.speak(new Dictionary<string, string>() 
                {
                    { "call_uuid", uuid }, // ID of the call
                    { "text", "Hello, from Speak API" }, // Text to be played.
                    { "voice", "WOMAN" }, // The voice to be used, can be MAN,WOMAN. Defaults to WOMAN.
                    {"language","en-GB"} // The language to be used
                });

                Debug.WriteLine(resp.Content);
                return "Speak API";
            };
        }
        public Program()
        {
            Get["/response/conference"] = x =>
            {
                Plivo.XML.Response resp = new Plivo.XML.Response();

                //  Add Speak XML Tag
                resp.AddSpeak("You will now be placed into a demo conference. This is brought to you by Plivo. To know more, visit us at Plivo.com", new Dictionary<string, string>() { });

                // Add Conference XML Tag
                resp.AddConference("demo",new Dictionary<string,string>()
                {
                    {"enterSound","beep:2"}, // Used to play a sound when a member enters the conference
                    {"record","true"}, // Option to record the call
                    {"action","http://dotnettest.apphb.com/response/conf_action"}, // URL to which the API can send back parameters
                    {"method","GET"}, // method to invoke the action Url
                    {"callbackUrl","http://dotnettest.apphb.com/response/conf_callback"}, // If specified, information is sent back to this URL
                    {"callbackMethod","GET"}, // Method used to notify callbackUrl
                });

                Debug.WriteLine(resp.ToString());

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

            // Action URL Example
            Get["/response/conf_action"] = x =>
            {
                String conf_name = Request.Query["ConferenceName"];
                String conf_uuid = Request.Query["ConferenceUUID"];
                String conf_mem_id = Request.Query["ConferenceMemberID"];
                String record_url = Request.Query["RecordUrl"];
                String record_id = Request.Query["RecordingID"];

                Debug.WriteLine("Conference Name : {0}, Conference UUID : {1}, Conference Member ID : {2}, Record URL : {3}, Record ID : {4}", conf_name, conf_uuid, conf_mem_id, record_url, record_id);
                return "Done";
            };

            //  Callback URL Example
            Get["/response/conf_callback"] = x =>
            {
                String conf_action = Request.Query["ConferenceAction"];
                String conf_name = Request.Query["ConferenceName"];
                String conf_uuid = Request.Query["ConferenceUUID"];
                String conf_mem_id = Request.Query["ConferenceMemberID"];
                String call_uuid = Request.Query["CallUUID"];
                String record_url = Request.Query["RecordUrl"];
                String record_id = Request.Query["RecordingID"];

                Debug.WriteLine("Conference Action : {0}, Conference Name : {1}, Conference UUID : {2}, Conference Member ID : {3}, Call UUID : {4}, Record URL : {5}, Record ID : {6}", conf_action, conf_name, conf_uuid, conf_mem_id, call_uuid, record_url, record_id);
                return "Done";
            };
        }
 static void Main(string[] args)
 {
     Response resp = new Response();
     resp.AddRecord(new Dictionary<string, string>() {
         { "transcriptUrl", "http=>//some.server/action/" },
         { "transcriptMethod", "GET" },
         { "transcriptType", "auto" },
     });
     //Console.WriteLine(resp.ToString());
 }
 static void Main(string[] args)
 {
     Response resp = new Response();
     resp.AddGetDigits(new Dictionary<string, string>() {
         { "action", "http://some.server/action/" },
         { "method", "GET" },
         { "digitTimeout", "5" },
         { "finishOnKey", "#" },
     });
     //Console.WriteLine(resp.ToString());
 }
        public Program()
        {
            // Generates a Conference XML
            Get["/conference"] = x =>
            {
                Plivo.XML.Response resp = new Plivo.XML.Response();
                resp.AddSpeak("You will now be placed into a demo conference. This is brought to you by Plivo. To know more, visit us at Plivo.com", new Dictionary <string, string>()
                {
                });
                resp.AddConference("demo", new Dictionary <string, string>()
                {
                    { "enterSound", "beep:1" },                                     // Used to play a sound when a member enters the conference
                    { "callbackUrl", "http://dotnettest.apphb.com/conf_callback" }, // If specified, information is sent back to this URL
                    { "callbackMethod", "GET" },                                    // Method used to notify callbackUrl
                });

                Debug.WriteLine(resp.ToString());

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

            // Record API is called in the callback URL to record the conference
            Get["/conf_callback"] = x =>
            {
                String events    = Request.Query["Event"];
                String conf_name = Request.Query["ConferenceName"];

                // The recording starts when the user enters the conference room
                if (events == "ConferenceEnter")
                {
                    string auth_id    = "Your AUTH_ID";
                    string auth_token = "Your AUTH_TOKEN";

                    RestAPI plivo = new RestAPI(auth_id, auth_token);
                    IRestResponse <Plivo.API.Record> resp = plivo.record_conference(new Dictionary <string, string>()
                    {
                        { "conference_name", conf_name } // Name of the conference
                    });

                    Debug.WriteLine(resp.Content);
                }
                else
                {
                    Debug.WriteLine("Invalid");
                }

                return("Done");
            };
        }
Exemplo n.º 23
0
        static void Main(string[] args)
        {
            Plivo.XML.Response resp = new Plivo.XML.Response();

            resp.AddSpeak("Здравствуйте, Это сообщение от Charlie. Машина за Nixon, приедет приблизительно в 10. Пожалуйста, будьте готовы к этому времени. Мы Вам позвоним еще раз когда машина подъедет к Вашему дому. Спасибо", new Dictionary<string, string>()
            {
                {"language", "ru-RU"},
                {"voice", "WOMAN"}
            });

            Console.Write("TTS Output:\n");
            Console.Write(resp.ToString());
        }
Exemplo n.º 24
0
        static void Main(string[] args)
        {
            Plivo.XML.Response resp = new Plivo.XML.Response();

            resp.AddSpeak("Здравствуйте, Это сообщение от Charlie. Машина за Nixon, приедет приблизительно в 10. Пожалуйста, будьте готовы к этому времени. Мы Вам позвоним еще раз когда машина подъедет к Вашему дому. Спасибо", new Dictionary <string, string>()
            {
                { "language", "ru-RU" },
                { "voice", "WOMAN" }
            });

            Console.Write("TTS Output:\n");
            Console.Write(resp.ToString());
        }
        public Program()
        {
            // Generates a Conference XML
            Get["/conference"] = x =>
            {
                Plivo.XML.Response resp = new Plivo.XML.Response();
                resp.AddSpeak("You will now be placed into a demo conference. This is brought to you by Plivo. To know more, visit us at Plivo.com", new Dictionary<string, string>() { });
                resp.AddConference("demo", new Dictionary<string, string>()
                {
                    {"enterSound","beep:1"}, // Used to play a sound when a member enters the conference
                    {"callbackUrl","http://dotnettest.apphb.com/conf_callback"}, // If specified, information is sent back to this URL
                    {"callbackMethod","GET"}, // Method used to notify callbackUrl
                });

                Debug.WriteLine(resp.ToString());

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

            // Record API is called in the callback URL to record the conference
            Get["/conf_callback"] = x =>
            {
                String events = Request.Query["Event"];
                String conf_name = Request.Query["ConferenceName"];

                // The recording starts when the user enters the conference room 
                if (events == "ConferenceEnter")
                {
                    string auth_id = "Your AUTH_ID";
                    string auth_token = "Your AUTH_TOKEN";

                    RestAPI plivo = new RestAPI(auth_id, auth_token);
                    IRestResponse<Plivo.API.Record> resp = plivo.record_conference(new Dictionary<string, string>()
                    {
                        {"conference_name",conf_name} // Name of the conference
                    });

                    Debug.WriteLine(resp.Content);
                }
                else
                {
                    Debug.WriteLine("Invalid");
                }

                return "Done";
            };
        }
Exemplo n.º 26
0
        public Program()
        {
            Get["/speak/"] = x =>
            {
                IEnumerable <string> signature = Request.Headers["X-Plivo-Signature"];
                String[]             sign      = (String[])signature;
                String actualsignature         = sign[0];

                String auth_token = "Your AUHT TOKEN";

                Dictionary <string, string> parameters = new Dictionary <string, string>();
                if (Request.Query != null)
                {
                    foreach (String key in Request.Query.Keys)
                    {
                        String value = Request.Query[key];
                        parameters.Add(key, value);
                    }
                }

                String url = Request.Url.SiteBase + Request.Url.Path;

                if (Request.Form != null)
                {
                    foreach (String key in Request.Form.Keys)
                    {
                        String value = Request.Form[key];
                        parameters.Add(key, value);
                    }
                }

                bool valid = XPlivoSignature.Verify(url, parameters, actualsignature, auth_token);
                Debug.WriteLine("Valid : " + valid);

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

                // Add Speak XML Tag
                resp.AddSpeak("Hello, Welcome to Plivo", new Dictionary <string, string>()
                {
                });

                Debug.WriteLine(resp.ToString());

                var output = resp.ToString();
                var res    = (Nancy.Response)output;
                res.ContentType = "text/xml";
                return(res);
            };
        }
        static void Main(string[] args)
        {
            Response resp = new Response();
            resp.AddRecord(new Dictionary<string,string>() {
                { "action", "http://some.domain/recordfile" },
                { "startOnDialAnswer", "true" }
            });

            Dial dial = new Dial(new Dictionary<string, string>() {
                { "callerId", "12222222222" },
            });
            dial.AddNumber("12121212121", new Dictionary<string,string>());
            resp.Add(dial);
            Console.WriteLine(resp.ToString());
        }
 protected void Page_Load(object sender, EventArgs e)
 {
     Plivo.XML.Response resp = new Plivo.XML.Response();
     Plivo.XML.Dial dial = new Plivo.XML.Dial(new Dictionary<string, string>() { });
     if (Request.HttpMethod == "GET")
     {
         int i = 0;
         for(;i<Request.QueryString.Count;i++)
         {
             if (Request.QueryString.GetKey(i) == "Numbers")
                 dial.AddNumber(Request.QueryString.Get(i), new Dict
     ionary<string, string>());
             else if (Request.QueryString.GetKey(i) == "Users")
                 dial.AddUser(Request.QueryString.Get(i), new Dictionary<string, string>());
         }
 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());
 }
Exemplo n.º 30
0
        public Program()
        {
            Get["/call_whisper"] = x =>
            {
                Plivo.XML.Response resp = new Plivo.XML.Response();

                // Generate DIal XML
                Plivo.XML.Dial dial = new Plivo.XML.Dial(new Dictionary <string, string>()
                {
                    { "confirmSound", "http://dotnettest.apphb.com/confirm_sound" }, // A remote URL fetched with POST HTTP request which must return an
                                                                                     // XML response with Play, Wait and/or Speak elements only.
                    { "confirmKey", "5" } // The digit to be pressed by the called party to accept the call.
                });
                dial.AddNumber("1111111111", new Dictionary <string, string>()
                {
                });
                dial.AddNumber("2222222222", new Dictionary <string, string>()
                {
                });
                dial.AddNumber("3333333333", 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["/confirm_sound"] = x =>
            {
                Plivo.XML.Response resp = new Plivo.XML.Response();

                //Generate Speak XML
                resp.AddSpeak("Press 5 to answer the call", 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["/call_transfer"] = x =>
            {
                Plivo.XML.Response resp = new Plivo.XML.Response();

                // Add speak XML tag
                resp.AddSpeak("Please wait while your call is being transferred", new Dictionary <string, string>()
                {
                });

                // Add Redirect XML tag
                resp.AddRedirect("http://dotnettest.apphb.com/connect", new Dictionary <string, string>()
                {
                });

                Debug.WriteLine(resp.ToString());

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

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

                // Generate Dial XML
                Plivo.XML.Dial dial = new Plivo.XML.Dial(new Dictionary <string, string>()
                {
                    { "action", "http://dotnettest.apphb.com/dial_status" }, // Redirect to this URL after leaving Dial.
                    { "method", "GET" },                                     // Submit to action URL using GET or POST.
                    { "redirect", "true" } // If set to false, do not redirect to action URL. We expect an XML from the action URL if this parameter is set to true.
                });
                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);
            };
        }
        public Program()
        {
            Get["/speak/"] = x =>
            {
                IEnumerable<string> signature = Request.Headers["X-Plivo-Signature"];
                String[] sign = (String[])signature;
                String actualsignature = sign[0];

                String auth_token = "Your AUHT TOKEN";

                Dictionary<string,string> parameters = new Dictionary<string,string>();
                if (Request.Query != null)
                {
                    foreach (String key in Request.Query.Keys)
                    {
                        String value = Request.Query[key];
                        parameters.Add(key, value);
                    }
                }

                String url = Request.Url.SiteBase + Request.Url.Path;
                
                if (Request.Form != null)
                {
                    foreach (String key in Request.Form.Keys)
                    {
                        String value = Request.Form[key];
                        parameters.Add(key, value);
                    }
                }

                bool valid = XPlivoSignature.Verify(url, parameters, actualsignature, auth_token);
                Debug.WriteLine("Valid : " + valid);
                
                Plivo.XML.Response resp = new Plivo.XML.Response();

                // Add Speak XML Tag
                resp.AddSpeak("Hello, Welcome to Plivo", 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["/speak"] = x =>
            {
                Plivo.XML.Response resp = new Plivo.XML.Response();

                // Add Speak XML Tag
                resp.AddSpeak("Hello, Welcome to Plivo", 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["dynamic_caller_id"] = x =>
            {
                Plivo.XML.Response resp = new Plivo.XML.Response();

                // Generate Dial XML
                Plivo.XML.Dial dial = new Plivo.XML.Dial(new Dictionary<string, string>() { });
                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;
            };
        }
Exemplo n.º 36
0
    protected void Page_Load(object sender, EventArgs e)
    {
        Plivo.XML.Response resp = new Plivo.XML.Response();
        Plivo.XML.Dial     dial = new Plivo.XML.Dial(new Dictionary <string, string>()
        {
        });
        if (Request.HttpMethod == "GET")
        {
            int i = 0;
            for (; i < Request.QueryString.Count; i++)
            {
                if (Request.QueryString.GetKey(i) == "Numbers")
                {
                    dial.AddNumber(Request.QueryString.Get(i), new Dict
                                   ionary <string, string>());
                }
                else if (Request.QueryString.GetKey(i) == "Users")
                {
                    dial.AddUser(Request.QueryString.Get(i), new Dictionary <string, string>());
                }
            }
            resp.Add(dial);
        }
        else if (Request.HttpMethod == "POST")
        {
            int i = 0;
            for (; i < Request.Form.Count; i++)
            {
                if (Request.Form.GetKey(i) == "Numbers")
                {
                    dial.AddNumber(Request.Form.Get(i), new Dictionary <string, string>());
                }
                else if (Request.Form.GetKey(i) == "Users")
                {
                    dial.AddUser(Request.Form.Get(i), new Dictionary <string, string>());
                }
            }
            resp.Add(dial);
        }

        Response.Write(resp.ToString());
        Response.ContentType = "text/xml";
        Response.End();
    }
Exemplo n.º 37
0
        public Program()
        {
            // Generate a Record XML and ask the caller to leave a message.
            // The recorded file will be sent to the 'action' URL.
            Get["/voicemail"] = x =>
            {
                Plivo.XML.Response resp = new Plivo.XML.Response();
                resp.AddSpeak("Please leave your message after the beep", new Dictionary <string, string>()
                {
                });
                resp.AddRecord(new Dictionary <string, string>()
                {
                    { "action", "http://dotnettest.apphb.com/save_record_url" },         // Submit the result of the record to this URL
                    { "method", "GET" },                                                 // HTTP method to submit the action URL
                    { "maxLength", "30" },                                               // Maximum number of seconds to record
                    { "transcriptionType", "auto" },                                     // The type of transcription required
                    { "transcriptionUrl", "http://dotnettest.apphb.com/transcription" }, // The URL where the transcription while be sent from Plivo
                    { "transcriptionMethod", "GET" } // The method used to invoke transcriptionUrl
                });

                Debug.WriteLine(resp.ToString());

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

            // Action URL Example
            Get["/save_record_url"] = x =>
            {
                String record_url = Request.Query["RecordUrl"];
                Debug.WriteLine("Recording URL : {0}", record_url);
                return("OK");
            };

            // Transcription URL Example
            Get["/transcription"] = x =>
            {
                String transcription = Request.Query["transcription"];
                Debug.WriteLine("Transcription : {0}", transcription);
                return("OK");
            };
        }
Exemplo n.º 38
0
        public Program()
        {
            // Generate a Record XML
            Get["/record"] = x =>
            {
                Plivo.XML.Response resp = new Plivo.XML.Response();
                resp.AddRecord(new Dictionary <string, string>()
                {
                    { "action", "http://dotnettest.apphb.com/record_action" },        // Submit the result of the record to this URL
                    { "method", "GET" },                                              // HTTP method to submit the action URL
                    { "callbackUrl", "http://dotnettest.apphb.com/record_callback" }, // If set, this URL is fired in background when the recorded file is ready to be used.
                    { "callbackMethod", "GET" } // Method used to notify the callbackUrl.
                });

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

            // Action URL Example
            Get["/record_action"] = x =>
            {
                String record_url      = Request.Query["RecordUrl"];
                String record_duration = Request.Query["RecordingDuration"];
                String record_id       = Request.Query["RecordingID"];

                Debug.WriteLine("Record URL : {0}, Recording Duration : {1}, Record ID : {2}", record_url, record_duration, record_id);
                return("Done");
            };

            // Callback URL Example
            Get["/record_callback"] = x =>
            {
                String record_url      = Request.Query["RecordUrl"];
                String record_duration = Request.Query["RecordingDuration"];
                String record_id       = Request.Query["RecordingID"];

                Debug.WriteLine("Record URL : {0}, Recording Duration : {1}, Record ID : {2}", record_url, record_duration, record_id);
                return("Done");
            };
        }
        public Program()
        {
            Get["/speak"] = x =>
            {
                Plivo.XML.Response resp = new Plivo.XML.Response();

                // Add Speak XML Tag
                resp.AddSpeak("Hello, Welcome to Plivo", 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()
        {
            // Generate a Record XML and ask the caller to leave a message.
            // The recorded file will be sent to the 'action' URL.
            Get["/voicemail"] = x =>
            {
                Plivo.XML.Response resp = new Plivo.XML.Response();
                resp.AddSpeak("Please leave your message after the beep", new Dictionary<string, string>() { });
                resp.AddRecord(new Dictionary<string, string>()
                {
                    {"action","http://dotnettest.apphb.com/save_record_url"}, // Submit the result of the record to this URL
                    {"method","GET"}, // HTTP method to submit the action URL
                    {"maxLength","30"}, // Maximum number of seconds to record 
                    {"transcriptionType","auto"}, // The type of transcription required
                    {"transcriptionUrl", "http://dotnettest.apphb.com/transcription"}, // The URL where the transcription while be sent from Plivo
                    {"transcriptionMethod","GET"} // The method used to invoke transcriptionUrl
                });

                Debug.WriteLine(resp.ToString());

                var output = resp.ToString();
                var res = (Nancy.Response)output;
                res.ContentType = "text/xml";
                return res;
            };
            
            // Action URL Example
            Get["/save_record_url"] = x =>
            {
                String record_url = Request.Query["RecordUrl"];
                Debug.WriteLine("Recording URL : {0}", record_url);
                return "OK";
            };
            
            // Transcription URL Example
            Get["/transcription"] = x =>
            {
                String transcription = Request.Query["transcription"];
                Debug.WriteLine("Transcription : {0}", transcription);
                return "OK";
            };
        }
        public Program()
        {
            Get["/call_transfer"] = x =>
            {
                Plivo.XML.Response resp = new Plivo.XML.Response();

                // Add speak XML tag
                resp.AddSpeak("Please wait while your call is being transferred", new Dictionary<string, string>() { });

                // Add Redirect XML tag
                resp.AddRedirect("http://dotnettest.apphb.com/connect", new Dictionary<string, string>() { });

                Debug.WriteLine(resp.ToString());

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

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

                // Generate Dial XML
                Plivo.XML.Dial dial = new Plivo.XML.Dial(new Dictionary<string, string>() 
                {
                    {"action","http://dotnettest.apphb.com/dial_status"}, // Redirect to this URL after leaving Dial. 
                    {"method","GET"}, // Submit to action URL using GET or POST.
                    {"redirect", "true"} // If set to false, do not redirect to action URL. We expect an XML from the action URL if this parameter is set to true. 
                });
                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;
            };
        }
        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["/dtmf"] = x =>
            {
                Plivo.XML.Response resp = new Plivo.XML.Response();

                // Add Speak XML Tag
                resp.AddSpeak("Sending digits", new Dictionary<string, string>() { });

                // Add DTMF XML Tag
                resp.AddDTMF("12345", 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["/call_whisper"] = x =>
            {
                Plivo.XML.Response resp = new Plivo.XML.Response();

                // Generate DIal XML
                Plivo.XML.Dial dial = new Plivo.XML.Dial(new Dictionary<string, string>() 
                {
                    {"confirmSound","http://dotnettest.apphb.com/confirm_sound"}, // A remote URL fetched with POST HTTP request which must return an 
                                                                                  // XML response with Play, Wait and/or Speak elements only.
                    {"confirmKey","5"} // The digit to be pressed by the called party to accept the call.
                });
                dial.AddNumber("1111111111", new Dictionary<string, string>() { });
                dial.AddNumber("2222222222", new Dictionary<string, string>() { });
                dial.AddNumber("3333333333", 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["/confirm_sound"] = x =>
            {
                Plivo.XML.Response resp = new Plivo.XML.Response();

                //Generate Speak XML
                resp.AddSpeak("Press 5 to answer the call", 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["dynamic_caller_id"] = x =>
            {
                Plivo.XML.Response resp = new Plivo.XML.Response();

                // Generate Dial XML
                Plivo.XML.Dial dial = new Plivo.XML.Dial(new Dictionary <string, string>()
                {
                });
                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);
            };
        }
        public Program()
        {
            Get["/connect"] = x =>
            {
                Plivo.XML.Response resp = new Plivo.XML.Response();

                // Add Speak XML Tag
                resp.AddSpeak("Connecting your call..", new Dictionary<string, string>() { });

                // Add Dial XML Tag
                Plivo.XML.Dial dial = new Plivo.XML.Dial(new Dictionary<string, string>() { });
                dial.AddNumber("2222222222", 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;
            };
        }
        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;
            };
        }
Exemplo n.º 49
0
        public Program()
        {
            Get["/dtmf"] = x =>
            {
                Plivo.XML.Response resp = new Plivo.XML.Response();

                // Add Speak XML Tag
                resp.AddSpeak("Sending digits", new Dictionary <string, string>()
                {
                });

                // Add DTMF XML Tag
                resp.AddDTMF("12345", 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["/seq_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>() 
                {
                    {"timeout", "20"}, // The duration (in seconds) for which the called party has to be given a ring.
                    {"action", "http://dotnettest.apphb.com/dial_status"} // Redirect to this URL after leaving Dial. 
                });
                dial.AddNumber("1111111111", new Dictionary<string, string>() { });
                dial.AddNumber("2222222222", 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;
            };
        }
Exemplo n.º 51
0
        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>()
                {
                    { "action", "http://dotnettest.apphb.com/dial_status" }, // Redirect to this URL after leaving Dial.
                    { "method", "GET" } // Submit to action URL using GET or POST.
                });
                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["/dial_status"] = x =>
            {
                // After completion of the call, Plivo will report back the status to the action URL in the Dial XML.
                String status = Request.Query["DialStatus"];
                String aleg   = Request.Form["DialALegUUID"];
                String bleg   = Request.Form["DialBLegUUID"];

                Debug.WriteLine("Status : {0}, ALeg UUID : {1}, BLeg UUID : {2}", status, aleg, bleg);
                return("OK");
            };
        }
        public Program()
        {
            Get["/answer_incoming"] = x =>
            {
                Plivo.XML.Response resp = new Plivo.XML.Response();

                resp.AddRecord(new Dictionary<string, string>()
                {
                    {"action","http://dotnettest.apphb.com/record_action"}, // Submit the result of the record to this URL.
                    {"method","GET"}, // Submit to action url using GET or POST
                    {"redirect","false"}, // If false, don't redirect to action url, only request the url and continue to next element.
                    {"recordSession","true"} // Record current call session in background 
                });

                resp.AddWait(new Dictionary<string, string>()
                {
                    {"length", "10"} // Time to wait in seconds
                });

                Dial dial = new Dial(new Dictionary<string, string>()
                {
                    {"callbackUrl",""}, // URL that is notified by Plivo when one of the following events occur : 
                                        // called party is bridged with caller, called party hangs up, caller has pressed any digit
                    {"callbackMethod","GET"} // Method used to notify callbackUrl.
                });

                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;
            };
            
            // The Callback URL of Dial will make a request to the Record API which will record only the B Leg
            // Play API is invoked which will play a music only on the B Leg.
            Get["dial_outbound"] = x =>
            {
                string events = Request.Query["Event"];
                string call_uuid = Request.Query["CallUUID"];
                Debug.WriteLine("Event : " + events);
                Debug.WriteLine("Call UUID : " + call_uuid);

                if (events == "DialAnswer")
                {
                    string auth_id = "Your AUTH_ID";
                    string auth_token = "Your AUTH_TOKEN";

                    RestAPI plivo = new RestAPI(auth_id, auth_token);
                    IRestResponse<Plivo.API.Record> resp = plivo.record(new Dictionary<string, string>()
                    {
                        {"call_uuid",call_uuid}, // ID of the call
                        {"callback_url","http://dotnettest.apphb.com/record_callback"}, // The URL invoked by the API when the recording ends.
                        {"callback_method","GET"} // The method which is used to invoke the callback_url URL. Defaults to POST.
                    });

                    Debug.WriteLine(resp.Content);

                    RestAPI plivo1 = new RestAPI(auth_id, auth_token);
                    IRestResponse<GenericResponse> resp1 = plivo1.play(new Dictionary<string, string>()
                    {
                        {"call_uuid",call_uuid}, // ID of the call
                        {"url","https://s3.amazonaws.com/plivocloud/Trumpet.mp3"} // A single URL or a list of comma separated URLs pointing to an mp3 or wav file.
                    });

                    Debug.WriteLine(resp1.Content);
                }    
                else
                {
                    Debug.WriteLine("Invalid");                        
                }

                return "OK";
            };

            // The Callback URL of record api will return the B Leg record details.
            Get["/record_callback"] = x =>
            {
                String record_url = Request.Query["RecordUrl"];
                String record_duration = Request.Query["RecordingDuration"];
                String record_id = Request.Query["RecordingID"];

                Debug.WriteLine("Record URL : {0}, Recording Duration : {1}, Record ID : {2}", record_url, record_duration, record_id);
                return "Done";
            };
        }
Exemplo n.º 53
0
        public Program()
        {
            Get["/answer_incoming"] = x =>
            {
                Plivo.XML.Response resp = new Plivo.XML.Response();

                resp.AddRecord(new Dictionary <string, string>()
                {
                    { "action", "http://dotnettest.apphb.com/record_action" }, // Submit the result of the record to this URL.
                    { "method", "GET" },                                       // Submit to action url using GET or POST
                    { "redirect", "false" },                                   // If false, don't redirect to action url, only request the url and continue to next element.
                    { "recordSession", "true" } // Record current call session in background
                });

                resp.AddWait(new Dictionary <string, string>()
                {
                    { "length", "10" } // Time to wait in seconds
                });

                Dial dial = new Dial(new Dictionary <string, string>()
                {
                    { "callbackUrl", "" }, // URL that is notified by Plivo when one of the following events occur :
                                           // called party is bridged with caller, called party hangs up, caller has pressed any digit
                    { "callbackMethod", "GET" } // Method used to notify callbackUrl.
                });

                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);
            };

            // The Callback URL of Dial will make a request to the Record API which will record only the B Leg
            // Play API is invoked which will play a music only on the B Leg.
            Get["dial_outbound"] = x =>
            {
                string events    = Request.Query["Event"];
                string call_uuid = Request.Query["CallUUID"];
                Debug.WriteLine("Event : " + events);
                Debug.WriteLine("Call UUID : " + call_uuid);

                if (events == "DialAnswer")
                {
                    string auth_id    = "Your AUTH_ID";
                    string auth_token = "Your AUTH_TOKEN";

                    RestAPI plivo = new RestAPI(auth_id, auth_token);
                    IRestResponse <Plivo.API.Record> resp = plivo.record(new Dictionary <string, string>()
                    {
                        { "call_uuid", call_uuid },                                        // ID of the call
                        { "callback_url", "http://dotnettest.apphb.com/record_callback" }, // The URL invoked by the API when the recording ends.
                        { "callback_method", "GET" } // The method which is used to invoke the callback_url URL. Defaults to POST.
                    });

                    Debug.WriteLine(resp.Content);

                    RestAPI plivo1 = new RestAPI(auth_id, auth_token);
                    IRestResponse <GenericResponse> resp1 = plivo1.play(new Dictionary <string, string>()
                    {
                        { "call_uuid", call_uuid }, // ID of the call
                        { "url", "https://s3.amazonaws.com/plivocloud/Trumpet.mp3" } // A single URL or a list of comma separated URLs pointing to an mp3 or wav file.
                    });

                    Debug.WriteLine(resp1.Content);
                }
                else
                {
                    Debug.WriteLine("Invalid");
                }

                return("OK");
            };

            // The Callback URL of record api will return the B Leg record details.
            Get["/record_callback"] = x =>
            {
                String record_url      = Request.Query["RecordUrl"];
                String record_duration = Request.Query["RecordingDuration"];
                String record_id       = Request.Query["RecordingID"];

                Debug.WriteLine("Record URL : {0}, Recording Duration : {1}, Record ID : {2}", record_url, record_duration, record_id);
                return("Done");
            };
        }
Exemplo n.º 54
0
        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);
            };
        }
Exemplo n.º 55
0
        public Program()
        {
            Get["/basic_wait"] = x =>
            {
                Plivo.XML.Response resp = new Plivo.XML.Response();

                // Add Speak XML Tag
                resp.AddSpeak("I will wait for 10 seconds", new Dictionary <string, string>()
                {
                });

                // Add Wait XML Tag
                resp.AddWait(new Dictionary <string, string>()
                {
                    { "length", "10" }
                });

                // Add Speak XML Tag
                resp.AddSpeak("I just waited 10 seconds", new Dictionary <string, string>()
                {
                });

                Debug.WriteLine(resp.ToString());

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

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

                // Add Wait XML Tag
                resp.AddWait(new Dictionary <string, string>()
                {
                    { "length", "10" }
                });

                // Add Speak XML Tag
                resp.AddSpeak("Hello", new Dictionary <string, string>()
                {
                });

                Debug.WriteLine(resp.ToString());

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

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

                // Add Wait XML Tag
                resp.AddWait(new Dictionary <string, string>()
                {
                    { "length", "100" },
                    { "beep", "true" }
                });

                // Add Speak XML Tag
                resp.AddSpeak("Hello", new Dictionary <string, string>()
                {
                });

                Debug.WriteLine(resp.ToString());

                var output = resp.ToString();
                var res    = (Nancy.Response)output;
                res.ContentType = "text/xml";
                return(res);
            };
        }
Exemplo n.º 56
0
        public Program()
        {
            // When the call is answered, a text is played which prompts the user to press 1 to transfer the call.
            // Once the digit is pressed, the transfer API request is made and the call is transfered to another number.

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

                // 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.
                    { "retries", "1" },                 // Indicates the number of retries the user is allowed to input the digits
                    { "redirect", "false" },            // Redirect to action URL if true. If false,only request the URL and continue to next element.
                    { "numDigits", "1" }
                });

                // Add Speak XML Tag
                gd.AddSpeak("Press 1 to transfer this call", new Dictionary <string, string>());
                resp.Add(gd);

                // Add Wait XML Tag
                resp.AddWait(new Dictionary <string, string>()
                {
                    { "length", "10" }
                });

                Debug.WriteLine(resp.ToString());

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

            // The Transfer API is invoked by the Get Digits action URL

            Get["/transfer_action"] = x =>
            {
                String digits = Request.Query["Digits"];
                String uuid   = Request.Query["CallUUID"];
                Debug.WriteLine("Digit pressed : {0}, Call UUID : {1}", digits, uuid);

                RestAPI plivo = new RestAPI("Your AUTH_ID", "Your AUTH_TOKEN");

                // Transfer API
                IRestResponse <GenericResponse> resp = plivo.transfer_call(new Dictionary <string, string>()
                {
                    { "call_uuid", uuid },                                 // ID of the call
                    { "aleg_url", "http://dotnettest.apphb.com/connect" }, // URL to transfer for aleg
                    { "aleg_method", "GET" } // Method to invoke the aleg_url
                });

                Debug.WriteLine(resp.Content);
                return("Transfer API");
            };
        }
        public Program()
        {
            Get["/basic_wait"] = x =>
            {
                Plivo.XML.Response resp = new Plivo.XML.Response();

                // Add Speak XML Tag
                resp.AddSpeak("I will wait for 10 seconds", new Dictionary<string, string>() { });

                // Add Wait XML Tag
                resp.AddWait(new Dictionary<string, string>()
                {
                    {"length", "10"}
                });

                // Add Speak XML Tag
                resp.AddSpeak("I just waited 10 seconds", new Dictionary<string, string>() { });

                Debug.WriteLine(resp.ToString());

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

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

                // Add Wait XML Tag
                resp.AddWait(new Dictionary<string, string>()
                {
                    {"length", "10"}
                });

                // Add Speak XML Tag
                resp.AddSpeak("Hello", new Dictionary<string, string>() { });

                Debug.WriteLine(resp.ToString());

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

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

                // Add Wait XML Tag
                resp.AddWait(new Dictionary<string, string>()
                {
                    {"length", "100"},
                    {"beep", "true"}
                });

                // Add Speak XML Tag
                resp.AddSpeak("Hello", 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()
        {
            // When the call is answered, a text is played which prompts the user to press 1 to transfer the call.
            // Once the digit is pressed, the transfer API request is made and the call is transfered to another number.

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

                // 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. 
                    {"retries","1"}, // Indicates the number of retries the user is allowed to input the digits
                    {"redirect","false"}, // Redirect to action URL if true. If false,only request the URL and continue to next element.
                    {"numDigits","1"}
                });

                // Add Speak XML Tag
                gd.AddSpeak("Press 1 to transfer this call", new Dictionary<string, string>());
                resp.Add(gd);

                // Add Wait XML Tag
                resp.AddWait(new Dictionary<string, string>() 
                {
                    {"length","10"}
                });

                Debug.WriteLine(resp.ToString());

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

            // The Transfer API is invoked by the Get Digits action URL

            Get["/transfer_action"] = x =>
            {
                String digits = Request.Query["Digits"];
                String uuid = Request.Query["CallUUID"];
                Debug.WriteLine("Digit pressed : {0}, Call UUID : {1}", digits, uuid);

                RestAPI plivo = new RestAPI("Your AUTH_ID", "Your AUTH_TOKEN");

                // Transfer API
                IRestResponse<GenericResponse> resp = plivo.transfer_call(new Dictionary<string, string>() 
                {
                    { "call_uuid", uuid }, // ID of the call
                    { "aleg_url", "http://dotnettest.apphb.com/connect" }, // URL to transfer for aleg
                    { "aleg_method", "GET" } // Method to invoke the aleg_url
                });

                Debug.WriteLine(resp.Content);
                return "Transfer API";
            };
        }