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)
        {
            // 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());
        }
示例#3
0
        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());
        }
        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);
                }
            }
        }
示例#5
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());
        }
        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);
        }
示例#7
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);

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

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

                    // Parse the Actions object and get the value property.

                    // Get the input submited by the user.
                    // This value can be used to query a database, hit a web service, etc.
                    // In the example, we'll simply read the number back to the caller.

                    foreach (var item in tropoResult.Actions)
                    {
                        string answer = item.Value;
                        tropo.Say("You entered, " + TropoUtilities.addSpaces(answer) + ". Goodbye");
                    }
                }

                // In the event of an error in rendering the page, play an error message to the caller.
                catch (JsonReaderException ex)
                {
                    tropo.Say("An error occured. " + ex.Message);
                }

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

                finally
                {
                    tropo.Hangup();
                    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();

            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.");

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

            // Set up the dialog.
            tropo.Ask(5, signals, false, null, choices, null, "test", Recognizer.UsEnglish, true, say, 30);
            tropo.Hangup();

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