示例#1
0
        public void testCallUsingCallObject()
        {
            Tropo tropo = new Tropo();

            IDictionary <string, string> headers = new Dictionary <String, String>();

            headers.Add("foo", "bar");
            headers.Add("bling", "baz");

            StartRecording recording = new StartRecording(AudioFormat.Mp3, Method.Post, "http://blah.com/recordings/1234.wav", "jose", "password");

            List <String> to = new List <String>(1);

            to.Add("3055195825");

            Call call = new Call();

            call.Recording     = recording;
            call.Headers       = headers;
            call.Timeout       = 10;
            call.AnswerOnMedia = false;
            call.Channel       = Channel.Text;
            call.Network       = Network.SMS;
            call.To            = to;
            call.From          = "3055551212";

            tropo.Call(call);
            Assert.AreEqual(this.callJsonAllOptions, tropo.RenderJSON());
        }
        public void testCallUsingCallObject()
        {
            Tropo tropo = new Tropo();

            IDictionary <string, string> headers = new Dictionary <String, String>();

            headers.Add("foo", "bar");
            headers.Add("bling", "baz");


            List <String> to = new List <String>(1);

            to.Add("3055195825");

            Call call = new Call();

            call.Headers          = headers;
            call.Timeout          = 10;
            call.AnswerOnMedia    = false;
            call.Channel          = Channel.Text;
            call.Network          = Network.SMS;
            call.To               = to;
            call.From             = "3055551212";
            call.MachineDetection = new MachineDetection("It is rather for us to be here dedicated to the great task remaining before us—that from these honored dead we take increased devotion to that cause for which they here gave the last full measure of devotion—that we here highly resolve that these dead shall not have died in vain—that this nation, under God, shall have a new birth of freedom, and that government of the people, by the people, for the people, shall not perish from the earth.");
            call.CallbackUrl      = "samplecallbackurl";
            call.Voice            = "voicefoo";
            call.Label            = "appidIdAsLabel";

            tropo.Call(call);
            Assert.AreEqual(this.callJsonCallObject, renderJSONToText(tropo));
        }
        protected void Page_Load(object sender, EventArgs e)
        {
            // Create a new instance of the Tropo object.
            Tropo tropo = new Tropo();

            // Create a transcription object to use with recording.
            Transcription trancription = new Transcription();

            trancription.Url         = "mailto:[email protected]";
            trancription.EmailFormat = "omit";
            trancription.Id          = "asyncUploadNULL";

            // Set up grammar for recording.
            Choices choices = new Choices();

            choices.Value      = "[10 DIGITS]";
            choices.Terminator = "#";

            // Construct a prompt to use with the recording.
            Say say = new Say();

            say.Value = "Please say your account number";
            //say.Value = "Fourscore and seven years ago our fathers brought forth, on this continent, a new nation, conceived in liberty, and dedicated to the proposition that all men are created equal.Now we are engaged in a great civil war, testing whether that nation, or any nation so conceived, and so dedicated, can long endure. We are met on a great battle - field of that war.We have come to dedicate a portion of that field, as a final resting-place for those who here gave their lives, that that nation might live.It is altogether fitting and proper that we should do this.But, in a larger sense, we cannot dedicate, we cannot consecrate—we cannot hallow—this ground.The brave men, living and dead, who struggled here, have consecrated it far above our poor power to add or detract. The world will little note, nor long remember what we say here, but it can never forget what they did here. It is for us the living, rather, to be dedicated here to the unfinished work which they who fought here have thus far so nobly advanced.It is rather for us to be here dedicated to the great task remaining before us—that from these honored dead we take increased devotion to that cause for which they here gave the last full measure of devotion—that we here highly resolve that these dead shall not have died in vain—that this nation, under God, shall have a new birth of freedom, and that government of the people, by the people, for the people, shall not perish from the earth.";
            tropo.Call("+8613466549249");
            // Use the record() method to set up a recording.
            //tropo.Record(3, false, true, choices, AudioFormat.Wav, 10, 600, Method.Post, null, true, say, 15, trancription, null, "http://54.88.99.156:9080/FileUpload/uploadFile");
            tropo.Record(3, null, null, null, null, choices, say, AudioFormat.Wav, 10, 600, Method.Post, "whname", true, trancription, "http://54.88.99.156:9080/FileUpload/uploadFile", null, null, 15, 5, null, "none");
            tropo.On("continue", "TropoResult.aspx", new Say("This is a on say in record"));
            // Hangup when finished.
            //tropo.Hangup();

            HttpContext.Current.Trace.Warn("learn trace of dot net" + DateTime.Now.ToString());

            tropo.RenderJSON(Response);
        }
        public void testConference()
        {
            Tropo tropo = new Tropo();

            tropo.Call("3035551212");
            tropo.Say("Welcome to the conference.");
            tropo.Conference("123456789098765432", false, "testConference", false, true, "#");
            tropo.Say("Thank you for joining the conference.");

            Assert.AreEqual(this.conferenceJson, renderJSONToText(tropo));
        }
        protected void Page_Load(object sender, EventArgs e)
        {
            using (StreamReader reader = new StreamReader(Request.InputStream))
            {
                // Get the JSON submitted from Tropo.
                string sessionJSON = TropoUtilities.parseJSON(reader);

                // Create a new instance of the Tropo object.
                Tropo tropo = new Tropo();

                try
                {
                    // Create a new Session object and pass in the JSON submitted from Tropo.
                    Session tropoSession = new Session(sessionJSON);

                    // Get parameters submitted with Session API call.
                    string sendToNumber   = tropoSession.Parameters.Get("sendToNumber");
                    string sendFromNumber = tropoSession.Parameters.Get("sendFromNumber");
                    string channel        = tropoSession.Parameters.Get("channel");
                    string network        = tropoSession.Parameters.Get("network");
                    string msg            = tropoSession.Parameters.Get("msg");

                    // Send an outbound message.
                    tropo.Call(sendToNumber, sendFromNumber, network, channel, true, 60, null, null);
                    tropo.Say(msg);

                    // Render the JSON for Tropo to consume.
                    Response.Write(tropo.RenderJSON());
                }

                catch (JsonReaderException ex)
                {
                    EventLog log = new EventLog();
                    log.Source = "TROPOWEBAPI";
                    log.WriteEntry("Tropo WebAPI Exception " + ex.Message, EventLogEntryType.Error);
                    Response.StatusCode = 500;
                    tropo.Say("An error occured in the application. Bad JSON");
                }

                catch (Exception ex)
                {
                    EventLog log = new EventLog();
                    log.Source = "TROPOWEBAPI";
                    log.WriteEntry("Tropo WebAPI Exception " + ex.Message, EventLogEntryType.Error);
                    Response.StatusCode = 500;
                    tropo.Say("An error occured in the application.");
                }

                finally
                {
                    Response.Write(tropo.RenderJSON());
                }
            }
        }
        protected void Page_Load(object sender, EventArgs e)
        {
            using (StreamReader reader = new StreamReader(Request.InputStream))
            {
                // Get the JSON submitted from Tropo.
                string sessionJSON = TropoUtilities.parseJSON(reader);

                // Create a new instance of the Tropo object.
                Tropo tropo = new Tropo();

                try
                {
                    // Create a new Session object and pass in the JSON submitted from Tropo.
                    Session tropoSession = new Session(sessionJSON);

                    // Get parameters submitted with Session API call.
                    string numberToDial    = tropoSession.Parameters.Get("numberToDial");
                    string textMessageBody = tropoSession.Parameters.Get("textMessageBody");

                    string sendFromNumber = "+17754641173";
                    string channel        = "TEXT";
                    string network        = "SMS";

                    // Send an outbound message.
                    //tropo.Call(numberToDial, sendFromNumber, network, channel, true, 60, null);
                    tropo.Call(numberToDial);
                    tropo.Say("You will hear current time " + textMessageBody);
                    tropo.Hangup();
                }

                catch (JsonReaderException ex)
                {
                    EventLog log = new EventLog();
                    log.Source = "TROPOWEBAPI";
                    log.WriteEntry("Tropo WebAPI Exception " + ex.Message, EventLogEntryType.Error);
                    Response.StatusCode = 500;
                    tropo.Say("An error occured in the application. Bad JSON");
                }

                catch (Exception ex)
                {
                    EventLog log = new EventLog();
                    log.Source = "TROPOWEBAPI";
                    log.WriteEntry("Tropo WebAPI Exception " + ex.Message, EventLogEntryType.Error);
                    Response.StatusCode = 500;
                    tropo.Say("An error occured in the application.");
                }

                finally
                {
                    tropo.RenderJSON(Response);
                }
            }
        }
        public void testConferenceWithEvents()
        {
            Tropo tropo = new Tropo();

            string[] signals = new string[] { "conferenceOver" };
            tropo.Call("3035551212");
            tropo.Say("Welcome to the conference.");
            tropo.Conference("123456789098765432", signals, false, "testConference", false, true, "#");

            Assert.AreEqual(this.conferenceJsonWithEvents, renderJSONToText(tropo));
        }
        public void testToOnly()
        {
            List <String> numbersToCall = new List <String>();

            numbersToCall.Add("3055195825");
            numbersToCall.Add("3054445567");

            Tropo tropo = new Tropo();

            tropo.Call(numbersToCall);
            Assert.AreEqual(this.callJson, renderJSONToText(tropo));
        }
        public void testCallUseAllOptions()
        {
            Tropo tropo = new Tropo();

            IDictionary <string, string> headers = new Dictionary <String, String>();

            headers.Add("foo", "bar");
            headers.Add("bling", "baz");


            tropo.Call("3055195825", "3055551212", Network.SMS, Channel.Text, false, 10, headers);
            Assert.AreEqual(this.callJsonAllOptions, renderJSONToText(tropo));
        }
示例#10
0
        private static void ConvertCall(global::VoiceModel.Call model, ref Tropo tmodel)
        {
            List <string> toList = new List <string>();

            toList.Add(model.to);

            TropoCSharp.Tropo.Call call = new TropoCSharp.Tropo.Call()
            {
                To   = toList,
                From = model.from
            };
            tmodel.Call(call);
        }
        public void testCallWithEvents()
        {
            Tropo tropo = new Tropo();

            string[] signals = new string[] { "tooLong", "callOver" };

            IDictionary <string, string> headers = new Dictionary <String, String>();

            headers.Add("x-foo", "bar");
            headers.Add("x-bling", "baz");

            tropo.Call("3055195825", signals, "3055551414", Network.Pstn, Channel.Voice, true, 60, headers);
            Assert.AreEqual(this.callJsonWithEvents, renderJSONToText(tropo));
        }
示例#12
0
        public void testCallUseAllOptions()
        {
            Tropo tropo = new Tropo();

            IDictionary <string, string> headers = new Dictionary <String, String>();

            headers.Add("foo", "bar");
            headers.Add("bling", "baz");

            StartRecording recording = new StartRecording(AudioFormat.Mp3, Method.Post, "http://blah.com/recordings/1234.wav", "jose", "password");

            tropo.Call("3055195825", "3055551212", Network.SMS, Channel.Text, false, 10, headers, recording);
            Assert.AreEqual(this.callJsonAllOptions, tropo.RenderJSON());
        }
        public void testConferenceWithPromptsAndpromptLogSecurity()
        {
            Tropo tropo = new Tropo();

            string[] signals = new string[] { "conferenceOver" };
            tropo.Call("3035551212");
            tropo.Say("Welcome to the conference.");
            JoinPrompt  joinPrompt  = new JoinPrompt("somebody join the conference");
            LeavePrompt leavePrompt = new LeavePrompt("some one leave the conference");

            tropo.Conference("123456789098765432", signals, 4, false, "testConference", false, true, "#", joinPrompt, leavePrompt, "none");

            Assert.AreEqual(this.conferenceJsonWithWithPromptsAndpromptLogSecurity, renderJSONToText(tropo));
        }
        protected void Page_Load(object sender, EventArgs e)
        {
            using (StreamReader reader = new StreamReader(Request.InputStream))
            {
                // Create a new instance of the Tropo object.
                Tropo tropo = new Tropo();

                if (!String.IsNullOrEmpty(Request.QueryString["signal"]))
                {
                    if (Request.QueryString["signal"] == "interruptConference")
                    {
                        tropo.Say(". Now, rejoin the conference. Press the pound key to  exit without hanging up.");
                        tropo.Conference(Request.QueryString["confid"], false, "testConference", false, true, "#");
                        tropo.Say("You have now left the conference.");
                        tropo.Hangup();
                    }
                    else
                    {
                        tropo.Say("The call is now over.  Gooddbye.");
                        tropo.Hangup();
                    }
                }

                else
                {
                    // Get the JSON submitted from Tropo.
                    string sessionJSON = TropoUtilities.parseJSON(reader);

                    // Create a new Session object and pass in the JSON submitted from Tropo.
                    Session tropoSession = new Session(sessionJSON);

                    // Create a signal to end the conference.
                    string[] signals = new string[] { "interruptConference", "endCall" };


                    // Call an outbound number and create a conference.
                    tropo.Call(tropoSession.Parameters["callToNumber"]);
                    tropo.Say("Welcome to the conference.");
                    //tropo.Conference(tropoSession.Parameters["conferenceID"], signals, false, "testConference", false, true, "#");
                    JoinPrompt  joinPrompt  = new JoinPrompt("somebody join the conference");
                    LeavePrompt leavePrompt = new LeavePrompt("some one leave the conference");
                    tropo.Conference(tropoSession.Parameters["conferenceID"], signals, 3, false, "testConference", false, true, "#", joinPrompt, leavePrompt, "none");
                    tropo.On("interruptConference", "Conference.aspx?signal=interruptConference&confid=" + tropoSession.Parameters["conferenceID"], new Say("You have left the conference."));
                    tropo.On("endCall", "Conference.aspx?signal=endCall", new Say("You have left the conference."));
                }

                tropo.RenderJSON(Response);
            }
        }
        protected void Page_Load(object sender, EventArgs e)
        {
            using (StreamReader reader = new StreamReader(Request.InputStream))
            {
                // Get the JSON submitted from Tropo.
                string sessionJSON = TropoUtilities.parseJSON(reader);

                // Create a new instance of the Tropo object.
                Tropo tropo = new Tropo();

                try
                {
                    // Create a new Session object and pass in the JSON submitted from Tropo.
                    Session tropoSession = new Session(sessionJSON);

                    // Get parameters submitted with Session API call.
                    string numberToDial = tropoSession.Parameters.Get("numberToDial");
                    //numberToDial = "5093176303";
                    string sendFromNumber = tropoSession.Parameters.Get("sendFromNumber");
                    //sendFromNumber = "14082041999";
                    string channel         = tropoSession.Parameters.Get("channel");
                    string network         = tropoSession.Parameters.Get("network");
                    string textMessageBody = tropoSession.Parameters.Get("textMessageBody");

                    string[] week = new string[4];
                    week[0] = "http://artifacts.voxeolabs.net.s3.amazonaws.com/test/test.png";
                    week[1] = "this is 这是第二行";
                    week[2] = "https://www.travelchinaguide.com/images/photogallery/2012/beijing-tiananmen-tower.jpg";
                    week[3] = "Today is 13 Aug";
                    //week[3] = "https://me888dia.giphy.com/media/LHZyixOnHwDDy/giphy.gif";


                    string currenT = DateTime.Now.ToString("yyyy/MM/dd HH:MM tt");
                    Say    say     = new Say();
                    say.Value = "this is MMS test for webapi Csharp SDk sent @ " + currenT;
                    say.Media = week;



                    // Send an outbound message.
                    tropo.Call(numberToDial, sendFromNumber, network, channel, true, 60, null);
                    // tropo.Say(textMessageBody);
                    tropo.Say(say);

                    //tropo.RenderJSON(Response);
                }

                catch (JsonReaderException ex)
                {
                    EventLog log = new EventLog();
                    log.Source = "TROPOWEBAPI";
                    log.WriteEntry("Tropo WebAPI Exception " + ex.Message, EventLogEntryType.Error);
                    Response.StatusCode = 500;
                    tropo.Say("An error occured in the application. Bad JSON");
                }

                catch (Exception ex)
                {
                    EventLog log = new EventLog();
                    log.Source = "TROPOWEBAPI";
                    log.WriteEntry("Tropo WebAPI Exception " + ex.Message, EventLogEntryType.Error);
                    Response.StatusCode = 500;
                    tropo.Say("An error occured in the application.");
                }

                finally
                {
                    tropo.RenderJSON(Response);
                }
            }
        }
        public void Page_Load(object sender, EventArgs args)
        {
            // Create a new instance of the Tropo object.
            Tropo tropo = new Tropo();

            Say say1 = new Say("Are you frank on windows. thanks to jerry");
            Say say2 = new Say("Are you frank on Mac.  thanks to jerry");
            Say say3 = new Say("http://192.168.26.55:8080/tropo/script/I.mp3");

            // Choices for the Ask.
            //Choices choices = new Choices("1,2,3");

            // Set up the dialog.
            //tropo.Call("sip:[email protected]:5678");

            IDictionary <string, string> headers = new Dictionary <String, String>();

            headers.Add("foo", "bar");
            headers.Add("bling", "baz");


            List <String> to = new List <String>(1);

            //to.Add("sip:[email protected]:5678");
            to.Add("sip:[email protected]:5678");

            Call call = new Call();

            call.Headers       = headers;
            call.Timeout       = 10;
            call.AnswerOnMedia = false;
            call.Channel       = Channel.Voice;
            //call.Network = Network.SMS;
            call.To = to;
            //call.From = "3055551212";
            call.MachineDetection = new MachineDetection("For the most accurate results, the introduction should be long enough to give Tropo time to detect a human or machine.");
            //call.MachineDetection = new MachineDetection();
            //call.Voice = Voice.UsEnglishFemale_Allison;
            call.Voice = "en-us";
            //call.CallbackUrl = "http://192.168.26.88:8080/FileUpload/uploadFile";
            //call.CallbackUrl = "http://requestb.in/zm7e2zzm";
            call.CallbackUrl = "http://192.168.26.88:8080/FileUpload/receiveJson";
            //call.PromptLogSecurity = "none";
            call.Label = "canUseAppidASLabel";

            //tropo.Hangup();
            tropo.Call(call);
            //tropo.Call("sip:[email protected]:5678");
            tropo.Say(say1);
            //tropo.Hangup();

            Transfer             transfer   = new Transfer();
            IEnumerable <string> transferTo = new string[] { "sip:[email protected]:5678", "sip:[email protected]:5678" };
            string from = "87473032";

            //string[] names = { "sip:[email protected]:5678", "sip:[email protected]:5678" };
            //to = (IEnumerable<string>)names.GetEnumerator();
            transfer.To            = transferTo;
            transfer.From          = from;
            transfer.AnswerOnMedia = true;
            On on = new On();

            on.Event = "connect";
            on.Next  = "http://192.168.26.55:8080/tropo/script/I.mp3";
            on.Next  = "http://freewavesamples.com/files/Kawai-K5000W-AddSquare-C4.wav";
            on.Say   = say3;
            //on.Post = "http://requestb.in/1cp3mf01";
            on.Post = "http://192.168.26.88:8080/FileUpload/receiveJson";
            //transfer.On = on;
            transfer.RingRepeat  = 3;
            transfer.PlayTones   = true;
            transfer.CallbackUrl = "http://192.168.26.88:8080/FileUpload/rece666iveJson";
            MachineDetection ma = new MachineDetection("At some point in the future there may be a standard libpcap release with remote capture support, and at some point after that Apple may pick up that release, and at some point the OS X version of Wireshark may be modified to use those capabilities if present.");

            transfer.MachineDetection = ma;
            //transfer.PromptLogSecurity = "";
            transfer.Label = "transferL55abel";
            tropo.Transfer(transfer);

            ////tropo.On("ring", "http://freewavesamples.com/files/Kawai-K5000W-AddSquare-C4.wav", say3);


            ////tropo.On()

            ////tropo.Call("sip:[email protected]:5678");
            ////tropo.Say(say2);
            ////tropo.Hangup();


            tropo.On("continue", "TropoResult.aspx", new Say("call test result"));

            tropo.RenderJSON(Response);
        }
示例#17
0
        public void Page_Load(object sender, EventArgs args)
        {
            // Create a new instance of the Tropo object.
            Tropo tropo = new Tropo();

            Say say1 = new Say("Are you frank on windows. thanks to jerry");
            Say say2 = new Say("Are you frank on Mac.  thanks to jerry");
            Say say3 = new Say("http://192.168.26.55:8080/tropo/script/I.mp3");

            // Choices for the Ask.
            //Choices choices = new Choices("1,2,3");

            // Set up the dialog.
            //tropo.Call("sip:[email protected]:5678");

            IDictionary <string, string> headers = new Dictionary <String, String>();

            headers.Add("foo", "bar");
            headers.Add("bling", "baz");

            StartRecording recording = new StartRecording(AudioFormat.Mp3, Method.Post, "http://blah.com/recordings/1234.wav", "jose", "password");

            List <String> to = new List <String>(1);

            to.Add("sip:[email protected]:5678");
            //to.Add("sip:[email protected]:5678");

            Call call = new Call();

            call.Recording     = recording;
            call.Headers       = headers;
            call.Timeout       = 10;
            call.AnswerOnMedia = false;
            call.Channel       = Channel.Voice;
            //call.Network = Network.SMS;
            call.To = to;
            //call.From = "3055551212";
            call.MachineDetection = new MachineDetection("For the most accurate results, the introduction should be long enough to give Tropo time to detect a human or machine. The longer the introduction, the more time we have to determine how the call was answered. If the introduction is long enough to play until the voicemail beep plays, Tropo will have the most accurate detection. It takes a minimum of four seconds to determine if a call was answered by a human or machine, so introductions four seconds or shorter will always return HUMAN.");
            //call.MachineDetection = new MachineDetection();
            //call.Voice = Voice.UsEnglishFemale_Allison;
            call.Voice             = "en-us";
            call.CallbackUrl       = "";
            call.PromptLogSecurity = "";
            call.Label             = "canUseAppidASLabel";

            //tropo.Hangup();
            tropo.Call(call);
            //tropo.Call("sip:[email protected]:5678");
            tropo.Say(say1);
            //tropo.Hangup();

            //Transfer transfer = new Transfer();
            //IEnumerable<string> transferTo = new string[] { "sip:[email protected]:5678", "sip:[email protected]:5678" };
            //string from = "87473032";
            ////string[] names = { "sip:[email protected]:5678", "sip:[email protected]:5678" };
            ////to = (IEnumerable<string>)names.GetEnumerator();
            //transfer.To = transferTo;
            //transfer.From = from;
            ////transfer.AnswerOnMedia = true;
            ////On on = new On();
            ////on.Event = Event.Ring;
            ////on.Next = "http://192.168.26.55:8080/tropo/script/I.mp3";
            ////on.Next = "http://freewavesamples.com/files/Kawai-K5000W-AddSquare-C4.wav";
            ////on.Say = say3;
            ////transfer.On = on;
            //tropo.Transfer(transfer);

            ////tropo.On("ring", "http://freewavesamples.com/files/Kawai-K5000W-AddSquare-C4.wav", say3);


            ////tropo.On()

            ////tropo.Call("sip:[email protected]:5678");
            ////tropo.Say(say2);
            ////tropo.Hangup();

            tropo.On("continue", "TropoResult.aspx", new Say("call test result"));

            tropo.RenderJSON(Response);
        }