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.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());
        }
        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");
            };
        }
Exemple #4
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()
        {
            // 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["/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";
            };
        }
        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");
            };
        }