コード例 #1
0
        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());
                }
            }
        }
コード例 #2
0
        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);
        }
コード例 #3
0
        public void testAskMethodWithAllArguements()
        {
            Tropo tropo = new Tropo();

            tropo.Ask(1, false, new Choices("[5 DIGITS]"), 30, "foo", true, new Say("Please enter your 5 digit zip code."), 30);
            Assert.AreEqual(this.askJsonWithOptions, tropo.RenderJSON());
        }
コード例 #4
0
        protected void Page_Load(object sender, EventArgs e)
        {
            // Create a new instance of the Tropo object.
            Tropo tropo = new Tropo();

            // Set the voice property.
            tropo.Voice = Voice.UsEnglishMale_Steven;

            Say say = new Say("Please record your 45 second message after the beep, press pound when complete.");

            tropo.Say(say);

            Record record = new Record()
            {
                Bargein = true,
                Beep    = true,
                Say     = new Say(""),
                Format  = "audio/mp3",
                MaxTime = 45,
                Choices = new Choices("", "dtmf", "#"),
                Url     = "../UploadRecording"
            };

            tropo.Record(record);

            // Render JSON for Tropo to consume.
            Response.Write(tropo.RenderJSON());
        }
コード例 #5
0
        /// <summary>
        /// Must be used from an endpoint URL.
        /// This will parse the active session and send the specified messages.
        /// As of now, it only supports sending through the MSN Network IM
        /// </summary>
        /// <param name="reader"></param>
        /// <param name="messages"></param>
        /// <returns></returns>
        public static string ExecuteSession(StreamReader reader, Dictionary <string, List <string> > messages)
        {
            string sessionJSON = reader.ReadToEnd();
            Tropo  tropo       = new Tropo();

            try
            {
                Session tropoSession = new Session(sessionJSON);

                foreach (var kvp in messages)
                {
                    string to   = kvp.Key;
                    string from = "*****@*****.**";

                    foreach (string msg in kvp.Value)
                    {
                        tropo.Message(new Say(msg), new List <string>()
                        {
                            to
                        }, false, Channel.Text, from, from, Network.Msn, false, 30);
                    }
                }
            }
            catch
            {
            }
            return(tropo.RenderJSON());
        }
コード例 #6
0
        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.Uri         = "mailto:[email protected]";
            trancription.EmailFormat = "omit";

            // 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";

            // Use the record() method to set up a recording.
            tropo.Record(3, false, true, choices, AudioFormat.Wav, 10, 60, Method.Post, null, true, say, 5, trancription, null, "http://somehost.com/record.aspx");

            // Hangup when finished.
            tropo.Hangup();

            // Render the JSON for Tropo to consume.
            Response.Write(tropo.RenderJSON());
        }
コード例 #7
0
        public void Page_Load(object sender, EventArgs args)
        {
            // Create a new instance of the Tropo object.
            Tropo tropo = new Tropo();

            // Call the say method of the Tropo object and give it a prompt to say.
            //tropo.Say("Hello World!");

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

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

            Message message = new Message();

            message.To   = to;
            message.From = "sip:[email protected]";
            message.Say  = new Say("I am a message 1");
            message.PromptLogSecurity = "suppress";
            message.Voice             = "en-us";

            tropo.Message(message);

            tropo.RenderJSON(Response);
        }
コード例 #8
0
        protected void Page_Load(object sender, EventArgs e)
        {
            // Create a new instance of the Tropo object.
            Tropo tropo = new Tropo();

            // Set the voice property.
            //tropo.Voice = Voice.UsEnglishMale_Steven;

            Say say = new Say("Please record your 45 second message after the 32 beeps, press pound when complete.");

            tropo.Say(say);

            StartRecording startRecording = new StartRecording();

            startRecording.AsyncUpload = true;
            tropo.StartRecording(false, AudioFormat.Wav, Method.Post, "http://192.168.26.88:8080/FileUpload/uploadFile", "", "", "", "plain", "");

            //Say say2 = new Say("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.");
            Say say2 = new Say("I love beijing, hi tropo new version");

            tropo.Say(say2);


            tropo.StopRecording();


            Say say3 = new Say("is it wait 8 seconds?");

            tropo.Say(say3);

            tropo.RenderJSON(Response);
        }
コード例 #9
0
        protected void Page_Load(object sender, EventArgs e)
        {
            // Create a new instance of the Tropo object.
            Tropo tropo = new Tropo();

            //tropo.Voice = Voice.UsEnglishFemale_Susan;

            // Create an array of signals - used to interupt the Ask.
            // string[] signals = new string[] {"endCall", "tooLong"};

            // A prompt to use with the Ask.
            Say say = new Say("This is an Ask test with events. Please enter 1, 2 or 3.");

            var says = new Collection <Say>();

            says.Add(new Say("Sorry, I did not hear anything.", "timeout"));
            says.Add(new Say("Don't think that was a year. ", "nomatch:1"));
            says.Add(new Say("Nope, still not a year.", "nomatch:2"));
            says.Add(new Say("No match 3.", "nomatch:3"));
            says.Add(new Say("What is your birth year?"));


            // Choices for the Ask.
            Choices choices = new Choices("[4 DIGITS]");

            // Set up the dialog.
            tropo.Ask(1, true, 3, choices, null, "year", true, says, 7);
            tropo.On(Event.Continue, "YourAge.aspx", null);   // Fires when the user provides valid input.
            tropo.On(Event.Incomplete, "FailAge.aspx", null); // Fires when the user provides valid input.

            //tropo.Hangup();

            tropo.RenderJSON(Response);
        }
コード例 #10
0
        protected void Page_Load(object sender, EventArgs e)
        {
            // Create a new instance of the Tropo object.
            Tropo tropo = new Tropo();

            // Set the voice to use when saying a prompt.
            tropo.Voice = Voice.UsEnglishMale_Steven;

            // A prompt to give the say to the recipient.
            Say say = new Say("This is a reminder call. Remember, you have a meeting at 2 PM");

            // An ArrayList to hold the numbers to call (first call answered hears the prompt).
            List <String> to = new List <String>();

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

            // Create an endpoint object to denote who the call is from.
            string from = "7777777777";

            // Call the message method of the Tropo object and pass in values.
            tropo.Message(say, to, false, Channel.Voice, from, "reminder", Network.Pstn, true, 60);

            // Render the JSON for Tropo to consume.
            Response.Write(tropo.RenderJSON());
        }
コード例 #11
0
        public void Page_Load(object sender, EventArgs args)
        {
            using (StreamReader reader = new StreamReader(Request.InputStream))
            {
                Tropo tropo = new Tropo();

                try
                {
                    IEnumerable <string> redirect2     = new string[] { "sip:[email protected]" };
                    IEnumerable <string> redirect1     = new string[] { "sip:[email protected]:5678" };
                    IEnumerable <string> redirectfrank = new string[] { "sip:[email protected]:5678" };
                    string too  = "sip:[email protected]:5678";      // in my test, X-Lite client did not success
                    string too2 = "sip:[email protected]:5678"; // use another application success
                    tropo.Redirect(too2, "redirectwindows", null);
                }

                catch (JsonReaderException)
                {
                    tropo.Say("Sorry, an error occured. I choked on some JSON");
                }

                catch (Exception ex)
                {
                    tropo.Say("Sorry, an error occured. " + ex.Message);
                }

                finally
                {
                    tropo.RenderJSON(Response);
                }
            }
        }
コード例 #12
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());
        }
コード例 #13
0
        public void testNewStartRecording()
        {
            Tropo tropo = new Tropo();

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

            Assert.AreEqual(this.startRecordingJson, tropo.RenderJSON());
        }
コード例 #14
0
ファイル: TropoUtilities.cs プロジェクト: cfaiette/VoiceModel
        private static string ConversionError()
        {
            Tropo tmodel = new Tropo();

            tmodel.Say("Error translating VoiceModel to Tropo object.");

            return(tmodel.RenderJSON());
        }
コード例 #15
0
ファイル: TropoUtilities.cs プロジェクト: cfaiette/VoiceModel
        private static string ConvertCall(global::VoiceModel.Call model)
        {
            Tropo tmodel = new Tropo();

            ConvertCall(model, ref tmodel);
            tmodel.On("continue", model.nextUri, null);
            return(tmodel.RenderJSON());
        }
コード例 #16
0
ファイル: TropoUtilities.cs プロジェクト: cfaiette/VoiceModel
        private static string ConvertSay(global::VoiceModel.Say model)
        {
            Tropo tmodel = new Tropo();

            ConvertPromptList(model.prompts, model.json, ref tmodel);
            tmodel.On("continue", model.nextUri, null);
            return(tmodel.RenderJSON());
        }
コード例 #17
0
        protected void Page_Load(object sender, EventArgs e)
        {
            using (StreamReader reader = new StreamReader(Request.InputStream))
            {
                // Get the JSON submitted from Tropo.
                string resultJSON = TropoUtilities.parseJSON(reader);
                Console.WriteLine("resultJSONis:" + resultJSON);
                HttpContext.Current.Trace.Warn(DateTime.Now.ToString() + " I Made It HerresultJSONis" + resultJSON);

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

                try
                {
                    // Create a new Result object and pass in the JSON submitted from Tropo.
                    Result tropoResult = Result.getResult(resultJSON);

                    // Get Actions container and parse.
                    List <TropoCSharp.Tropo.Action> Actions = tropoResult.Actions;

                    tropo.Say("session id is beijing " + tropoResult.SessionId);

                    foreach (TropoCSharp.Tropo.Action item in Actions)
                    {
                        tropo.Say("action Name is: " + item.Name);
                        tropo.Say("attempts is " + item.Attempts);
                        tropo.Say("disposition is " + item.Disposition);
                        tropo.Say("ConnectedDuration is " + item.ConnectedDuration);
                        tropo.Say("Duration is " + item.Duration);
                        tropo.Say("confidence is " + item.Confidence);
                        tropo.Say("interpretation is " + item.Interpretation);
                        tropo.Say("utterance is " + item.Utterance);
                        tropo.Say("value is " + item.Value);
                        tropo.Say("concept is: " + item.Concept);
                        //tropo.Say("xml is " + item.xml);
                        tropo.Say("uploadStatus is " + item.UploadStatus);
                        tropo.Say("inner user type is " + item.UserType);
                    }
                    tropo.Say("user type is " + tropoResult.UserType);
                }

                catch (JsonReaderException)
                {
                    tropo.Say("Sorry, an error occured. I choked on some JSON");
                }

                catch (Exception ex)
                {
                    tropo.Say("Sorry, an error occured. " + ex.Message);
                }

                finally
                {
                    tropo.RenderJSON(Response);
                }
            }
        }
コード例 #18
0
ファイル: TropoUtilities.cs プロジェクト: cfaiette/VoiceModel
        private static string ConvertAsk(global::VoiceModel.Ask model)
        {
            Tropo tmodel = new Tropo();

            tmodel.Ask(3, true, ConvertGrammar(model.grammar), null, "result", null, ConvertPromptList(model.initialPrompt, model.json), null);
            tmodel.On("continue", model.nextUri, null);

            return(tmodel.RenderJSON());
        }
コード例 #19
0
        public void Page_Load(object sender, EventArgs args)
        {
            // Create a new instance of the Tropo object.
            Tropo tropo = new Tropo();

            // Call the say method of the Tropo object and give it a prompt to say.
            tropo.Say("Welcome To Beijing, who are you ");

            tropo.RenderJSON(Response);
        }
コード例 #20
0
ファイル: TropoUtilities.cs プロジェクト: cfaiette/VoiceModel
        private static string ConvertExit(Exit model)
        {
            Tropo tmodel = new Tropo();

            ConvertPromptList(model.ExitPrompt, model.json, ref tmodel);
            tmodel.Hangup();
            //tmodel.On("continue", model.nextUri, null);

            return(tmodel.RenderJSON());
        }
コード例 #21
0
        public void testAsk()
        {
            Say     say     = new Say("Please enter your 5 digit zip code.");
            Choices choices = new Choices("[5 DIGITS]");

            Tropo tropo = new Tropo();

            tropo.Ask(null, null, choices, null, "foo", null, say, null);
            Assert.AreEqual(this.askJson, tropo.RenderJSON());
        }
コード例 #22
0
ファイル: TropoUtilities.cs プロジェクト: cfaiette/VoiceModel
        private static string ConvertRecord(global::VoiceModel.Record model, string recordingUri)
        {
            Tropo  tmodel = new Tropo();
            string next   = model.nextUri;

            model.nextUri = recordingUri;
            ConvertRecord(model, ref tmodel);
            tmodel.On("continue", next, null);
            return(tmodel.RenderJSON());
        }
コード例 #23
0
        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);
                }
            }
        }
コード例 #24
0
        public void testAskFromObject()
        {
            Say     say     = new Say("Please enter your 5 digit zip code.");
            Choices choices = new Choices("[5 DIGITS]");
            Ask     ask     = new Ask(choices, "foo", say);

            Tropo tropo = new Tropo();

            tropo.Ask(ask);
            Assert.AreEqual(this.askJson, tropo.RenderJSON());
        }
コード例 #25
0
        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, tropo.RenderJSON());
        }
コード例 #26
0
        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, tropo.RenderJSON());
        }
コード例 #27
0
        public void Page_Load(object sender, EventArgs args)
        {
            // Create a new instance of the Tropo object.
            Tropo tropo = new Tropo();

            // Call the say method of the Tropo object and give it a prompt to say.
            tropo.Say("Hello World!");

            // Render the JSON for Tropo to consume.
            Response.Write(tropo.RenderJSON());
        }
コード例 #28
0
        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, tropo.RenderJSON());
        }
コード例 #29
0
        public void testAskWithEvents()
        {
            Tropo tropo = new Tropo();

            string[] signals = new string[] { "endCall", "tooLong" };
            Say      say     = new Say("This is an Ask test with events. Please enter 1, 2 or 3.");
            Choices  choices = new Choices("1,2,3");

            tropo.Ask(5, signals, false, null, choices, null, "test", Recognizer.UsEnglish, true, say, 30);
            tropo.Hangup();
            Assert.AreEqual(this.askJsonWithEvents, tropo.RenderJSON());
        }
コード例 #30
0
        protected void Page_Load(object sender, EventArgs e)
        {
            // Create a new instance of the Tropo object.
            Tropo tropo = new Tropo();

            // Play an error message to the caller.
            tropo.Say("I'm sorry, there was an error. Please try you call again later.");

            // End the current session.
            tropo.Hangup();

            tropo.RenderJSON(Response);
        }