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); }
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()); }
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)); }
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); }
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 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); } } }
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, renderJSONToText(tropo)); }
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); }
/// <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()); }
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 class. Tropo tropo = new Tropo(); // Create a new Session object and pass in the JSON submitted from Tropo. Session tropoSession = new Session(sessionJSON); string smsReceived = tropoSession.InitialText; // yu can do your business logic with smsReceived.... //.... //.... // Create an XML doc to hold the response from the Tropo Session API. XmlDocument doc = new XmlDocument(); string token = "6c48697670656858594b62704c62715358444e5a72744a794156715872656a66627a72464b7158626d58374"; // the app's voice token (app's url is SMSBusineessLogic.aspx) // A collection to hold the parameters we want to send to the Tropo Session API. IDictionary <string, string> parameters = new Dictionary <String, String>(); parameters.Add("numberToDial", "+8613466549249"); parameters.Add("textMessageBody", smsReceived); // Inintialized another application, here I just say the smsReceived to numberToDial doc.Load(tropo.CreateSession(token, parameters)); } }
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()); }
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); }
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()); }
private static NotificationResult SendSms(IEnumerable <string> to, string message) { // Create an XML doc to hold the response from the Tropo Session API. XmlDocument doc = new XmlDocument(); // send foreach (var num in to) { // configure parameters Dictionary <string, string> map = new Dictionary <string, string> (); map.Add("sendToNumber", CommonUtils.ParseNumericString(num)); map.Add("sendFromNumber", CommonUtils.ParseNumericString(Configuration.TropoFromNumber)); map.Add("channel", Channel.Text); map.Add("network", Network.SMS); map.Add("msg", HttpUtility.UrlEncode(String.Join("", CommonUtils.RemoveAccentuation(message)))); // create tropo instance var tropo = new Tropo(); // Load the XML document with the return value of the CreateSession() method call. doc.Load(tropo.CreateSession(Configuration.TropoSmsToken, map)); } // treat result if (String.IsNullOrEmpty(doc.InnerXml)) { throw new Exception("Tropo operation failed"); } return(new NotificationResult(true, doc.InnerXml)); }
public void testStartRecordingAsyncUpload() { Tropo tropo = new Tropo(); tropo.StartRecording(true, AudioFormat.Mp3, Method.Post, "http://blah.com/recordings/1234.wav", "jose", "password", "", "plain", ""); Assert.AreEqual(this.startRecordingAsyncUploadJson, renderJSONToText(tropo)); }
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, renderJSONToText(tropo)); }
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()); }
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()); }
private static string ConversionError() { Tropo tmodel = new Tropo(); tmodel.Say("Error translating VoiceModel to Tropo object."); return(tmodel.RenderJSON()); }
public void testRedirect() { Tropo tropo = new Tropo(); tropo.Redirect("sip:[email protected]:5678", "redirectTest", true); Assert.AreEqual(this.redirectJson, renderJSONToText(tropo)); }
public void testSay() { Tropo tropo = new Tropo(); tropo.Say("hello Moscow", null, null, "shname", null, null, "suppress"); Assert.AreEqual(this.sayJson, renderJSONToText(tropo)); }
public void testAskMethodWithLogArguements2() { Tropo tropo = new Tropo(); // Create an array of signals - used to interupt the Ask. string[] signals = new string[] { "endCall", "tooLong" }; tropo.Ask(5, signals, false, null, new Choices("[5 DIGITS]"), 30, "foo", Recognizer.UsEnglish, true, new Say("Please enter your 5 digit zip code."), 2, 3.0f, 4.0f, 30, "suppress", "mask", "XXDD-"); Assert.AreEqual(this.askJsonWithLogArguements2, renderJSONToText(tropo)); }
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()); }
public void testNewRecord() { Say say = new Say("Please say your account number"); Choices choices = new Choices("[5 DIGITS]", null, "#"); Tropo tropo = new Tropo(); tropo.Record(null, null, null, choices, AudioFormat.Wav, null, null, Method.Post, null, null, say, null, null, null); }
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); } } }
private string renderJSONToText(Tropo tropo) { tropo.Language = null; tropo.Voice = null; JsonSerializerSettings settings = new JsonSerializerSettings { DefaultValueHandling = DefaultValueHandling.Ignore }; return(JsonConvert.SerializeObject(tropo, Formatting.None, settings).Replace("\\", "").Replace("\"{", "{").Replace("}\"", "}")); }
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()); }
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()); }
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()); }
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); }