public TwiMLResult Gather(VoiceRequest request)
  {
    var response = new TwilioResponse();

    // If the user entered digits, process their request
    if (!string.IsNullOrEmpty(request.Digits))
    {
      switch (request.Digits)
      {
        case "1":
          response.Say("You selected sales. Good for you!");
          break;
        case "2":
          response.Say("You need support. We will help!");
          break;
        default:
          response.Say("Sorry, I don't understand that choice.").Pause();
          response.Redirect("/voice");
          break;
      }
    }
    else
    {
      // If no input was sent, redirect to the /voice route
      response.Redirect("/voice");
    }

    return TwiML(response);
  }
Exemple #2
0
        public TwilioResponse PingTeamMember(string teamId, string callingPartyId, int idx)
        {
            var response = new TwilioResponse();

              Contact contact = directory.GetTeamMember(teamId, idx);
              Team team = directory.GetTeam(teamId);

              if (contact != null)
              {
            if (idx == 0)
            {
              response.Say(string.Format("Now attempting to connect you to {0}", team.Name));
            }
            else
            {
              response.Say("Trying next team member...");
            }

            response.Say("We are now contacting " + contact.Name + ", please hold the line");
            response.Dial(new Number(contact.MobileNumber, new { url = string.Format("/Router/PreConnect?callingPartyId={0}", callingPartyId) }),
              new { callerId = "+442033229301", timeLimit = 5, action = string.Format("/Router/NextTeamMember?callingPartyId={0}&TeamId={1}&Idx={2}", callingPartyId, teamId, idx) });
              }
              else
              {
            response.Say("Couldn't find a team member...");
            response.Hangup();
              }

              return response;
        }
        //
        // GET: /Phone/
        public ActionResult IncomingCall(string CallSid, string FromCity, string FromState, string FromZip, string FromCountry)
        {
            LocationalCall call = (LocationalCall)GetCall(CallSid);
            StateManager.AddNewCall(call);
            StateManager.AddToLog(CallSid, "Incoming call...");
            call.City = FromCity;
            call.Country = FromCountry;
            call.ZipCode = FromZip;
            call.State = FromState;

            TwilioResponse response = new TwilioResponse();
            response.BeginGather(new
            {
                action = Url.Action("ServiceRequest"),
                timeout = 120,
                method = "POST",
                numDigits = 1
            });
            response.Say("Welcome to the Bank of Griff.");
            response.Pause();
            response.Say("Press 1 to manage your account.");
            response.Say("Press 2 to take out a loan.");
            response.Say("Press 3 to talk to a representative.");
            response.Pause();
            response.EndGather();

            return SendTwilioResult(response);
        }
  public TwiMLResult Index(VoiceRequest request)
  {
    var response = new TwilioResponse();

    if (!string.IsNullOrEmpty(request.Digits))
    {
      switch (request.Digits)
      {
        case "1":
          response.Say("You selected sales. Good for you!");
          break;
        case "2":
          response.Say("You need support. We will help!");
          break;
        default:
          response.Say("Sorry, I don't understand that choice.").Pause();
          RenderMainMenu(response);
          break;
      }
    }
    else
    {
      // If no input was sent, use the <Gather> verb to collect user input
      RenderMainMenu(response);
    }

    return TwiML(response);
  }
 public ActionResult Hello()
 {
     var response = new TwilioResponse();
     response.Say("Hello there! Your Twilio environment has been configured.");
     response.Say("Good luck during the workshop!", new { Voice = "woman" });
     return TwiML(response);
 }
        //public HttpResponseMessage Get(VoiceRequest request)
        //{
        //  try
        //  {
        //    if (request != null)
        //    {
        //      repo.AddMessage(string.Format("unknown,\"{0}\",\"{1}\",starting", request.From, request.To));
        //    }
        //    else
        //    {
        //      repo.AddMessage("unknown,unknown,unknown,starting");
        //    }
        //    var response = new TwilioResponse();
        //    response.Say("G'day and welcome to the twilio monitoring thing...you should see your call appear on the web now...");
        //    //return response;
        //    return this.Request.CreateResponse(HttpStatusCode.OK, response.Element, new XmlMediaTypeFormatter());
        //  }
        //  catch (Exception ex)
        //  {
        //    var response = new TwilioResponse();
        //    response.Say(ex.Message);
        //    response.Say(ex.StackTrace);
        //    return this.Request.CreateResponse(HttpStatusCode.OK, response.Element, new XmlMediaTypeFormatter());
        //  }
        //}
        public HttpResponseMessage Post(VoiceRequest request)
        {
            try
              {
            if (request != null)
            {
              repo.AddMessage(string.Format("unknown,{0},{1},starting", request.From, request.To));
            }
            else
            {
              repo.AddMessage("unknown,unknown,unknown,starting");
            }

            var response = new TwilioResponse();

            response.Say("G'day and welcome to the twilio monitoring thing...you should see your call appear on the web now...");
            response.Pause(5);
            response.Say("Good bye...");
            //return response;
            return this.Request.CreateResponse(HttpStatusCode.OK, response.Element, new XmlMediaTypeFormatter());
              }
              catch (Exception ex)
              {
            var response = new TwilioResponse();
            response.Say(ex.Message);
            response.Say(ex.StackTrace);
            return this.Request.CreateResponse(HttpStatusCode.OK, response.Element, new XmlMediaTypeFormatter());
              }
        }
 // /Voice/HandleRecord
 public TwiMLResult HandleRecord(VoiceRequest request)
 {
     var response = new TwilioResponse();
     response.Say("Listen to your recorded message.");
     response.Play(request.RecordingUrl);
     response.Say("Goodbye.");
     return TwiML(response);
 }
        /// <summary>
        /// Builds an instance.
        /// </summary>
        /// <returns>A new instance of the TwilioResponse</returns>
        public TwilioResponse Build()
        {
            var response = new TwilioResponse();
            response.Say(_question.Body);
            response.Say(QuestionTypeToMessage[_question.Type]);
            AddRecordOrGatherCommands(response);

            return response;
        }
Exemple #9
0
        public void ProcessRequest(HttpContext context)
        {
            context.Response.ContentType = "application/xml";

            var response = new TwilioResponse();
            response.Say("Hello there! Your Twilio environment has been configured.");
            response.Say("Good luck during the workshop!", new { Voice = "woman" });

            context.Response.Write(response.ToString());
        }
        public void ProcessRequest(HttpContext context)
        {
            context.Response.ContentType = "application/xml";

            var response = new TwilioResponse();
            response.Say("Hello there! You have successfully configured a web hook.");
            response.Say("Have fun with your Twilio development!", new { Voice = "woman" });

            context.Response.Write(response.ToString());
        }
Exemple #11
0
        public TwilioResponse Greet(VoiceRequest request)
        {
            TwilioResponse response = new TwilioResponse();

              response.Say("Welcome to Saint Georges Hospital Directory.");

              response.BeginGather(new { finishOnKey = "#", action = "/Router/InitialOptions" });
              response.Say("Please enter your four digit I D then press the hash button");
              response.EndGather();

              return response;
        }
 // /Voice
 public TwiMLResult Index(VoiceRequest request)
 {
     var response = new TwilioResponse();
     response.Say("Hello. It's me.", new {voice = "alice", language = "en-GB"});
     response.Play("http://howtodocs.s3.amazonaws.com/ahoyhoy.mp3");
     response.BeginGather(new {numDigits = "1", action = "/Voice/HandleGather"});
     response.Say("To speak to a real person, press 1.\n" +
       "Press 2 to record a message for a Twilio educator.\n" +
       "Press any other key to start over.");
     response.EndGather();
     return TwiML(response);
 }
 public ActionResult Index(VoiceRequest request)
 {
     var response = new TwilioResponse();
     response.Say("Hello! You will get an SMS message soon.");
     response.Sms("This is the ship that made the Kessel Run in fourteen parsecs?");
     return TwiML(response);
 }
 // /Voice
 public TwiMLResult Index(VoiceRequest request)
 {
     var response = new TwilioResponse();
     response.Say("Hello. It's me.");
     response.Play("http://howtodocs.s3.amazonaws.com/ahoyhoy.mp3");
     return TwiML(response);
 }
        private TwiMLResult ReturnInstructions()
        {
            var response = new TwilioResponse();
            response.Say("To get to your extraction point, get on your bike and go down " +
                         "the street. Then Left down an alley. Avoid the police cars. Turn left " +
                         "into an unfinished housing development. Fly over the roadblock. Go " +
                         "passed the moon. Soon after you will see your mother ship.",
                         new {voice = "alice", language = "en-GB"});

            response.Say("Thank you for calling the ET Phone Home Service - the " +
                         "adventurous alien's first choice in intergalactic travel");

            response.Hangup();

            return TwiML(response);
        }
        public ActionResult Connect()
        {
            var response = new TwilioResponse();
            response.Say("Connecting you to an agent");

            return TwiML(response);
        }
 //
 // GET: /CallCenter/
 public ActionResult Index()
 {
     var response = new TwilioResponse();
     response.Pause(5);
     response.Say("Thanks for calling the Music Store");
     return TwiML(response);
 }
 public TwiMLResult HandleSms(string Sid, string From, string To, string Body, string Status)
 {
     _db.Log.Insert(Text: String.Format("From: {0}, To: {1}, Body: {2}", From, To, Body));
     var response = new TwilioResponse();
     response.Say("Received");
     return TwiML(response);
 }
        public TwilioResponse GetMenuSelection(VoiceRequest request)
        {
            var response = new TwilioResponse();

              try
              {
            string lookupPhoneNumber = request.GetOriginatingNumber();

            int profileId = profileManager.GetProfileId(lookupPhoneNumber);

            var selection = int.Parse(request.Digits);

            switch (selection)
            {
              case 1:
            response.Say("Looking up unread messages.");
            var unreadCount = refUnitedAcctManager.GetUnreadMessageCount(profileId);
            response.Say(string.Format("You have {0} message{1}", unreadCount, (unreadCount == 1) ? "" : "s"));
            break;
              case 2:
            response.Say("Looking up messages");
            response.Redirect(routeProvider.GetUrlMethod(IVRRoutes.READ_PLATFORM_MESSAGES, profileId));
            break;
              case 3:
            response.Redirect(routeProvider.GetUrlMethod(IVRRoutes.SEND_MESSAGE_TO_FAVOURITE, profileId));
            break;
              case 4:
            response.Redirect(routeProvider.GetUrlMethod(IVRRoutes.PLAY_RECORDED_MESSAGES, profileId));
            break;
              case 5:
            response.Redirect(routeProvider.GetUrlMethod(IVRRoutes.BROADCAST_RECORD, profileId));
            break;
              case 6:
            response.Redirect(routeProvider.GetUrlMethod(IVRRoutes.BROADCAST_MENU, profileId));
            break;
              default:
            response.Redirect(routeProvider.GetUrlMethod(IVRRoutes.PLAY_MAIN_MENU));
            break;
            }
              }
              catch (Exception ex)
              {
            response.Say("an error has occured. " + ex.Message);
              }

              return response;
        }
        public HttpResponseMessage Post(VoiceRequest request)
        {
            var response = new TwilioResponse();
            response.Say("Welcome to this Twilio demo app. Please enter your 3 digit pin code.");
            response.Gather(new { numDigits = 3, action = string.Format("/api/Authenticate") });

            return this.TwiMLResponse(response);
        }
Exemple #21
0
        public void ProcessRequest(HttpContext context)
        {
            var twiml = new  TwilioResponse();
            if (context.Request["message"] != null)
            {
                var message = HttpContext.Current.Server.UrlDecode(context.Request["message"].ToString());

                twiml.Say(message);
            }

            else
                twiml.Say("Good Morning, I am ready");
            context.Response.Clear();
            context.Response.ContentType = "text/xml";
            context.Response.Write(twiml.ToString());
            context.Response.End();
        }
Exemple #22
0
        public TwilioResponse EntryPoint(Twilio.Mvc.VoiceRequest request)
        {
            TwilioResponse response = new TwilioResponse();

              response.Say("Welcome to the IVR");

              return response;
        }
        public TwiMLResult RedirectWelcome()
        {
            var response = new TwilioResponse();
            response.Say("Returning to the main menu",
                new {voice = "alice", language = "en-GB"});
            response.Redirect(Url.Action("Welcome", "IVR"));

            return new TwiMLResult(response);
        }
        public HttpResponseMessage Post(VoiceRequest request)
        {
            var response = new TwilioResponse();

            response.Say("Welcome to this Twilio demo app. Please enter your 5 digit ID.");
            response.Gather(new { numDigits = 5, action = string.Format("/api/Authenticate") });

            return this.Request.CreateResponse(HttpStatusCode.OK, response.Element, new XmlMediaTypeFormatter());
        }
        public HttpResponseMessage GoodByeMessage(TwilioVoiceRequest twilioVoiceRequest)
        {
            var twilioResponse = new TwilioResponse();

            twilioResponse.Say("Thank you for using VoxVoi. Goodbye!", _voicesettings);
            twilioResponse.Hangup();

            return Request.CreateResponse(HttpStatusCode.OK, twilioResponse.Element);
        }
        public ActionResult ManageAccount(string CallSid, string Digits)
        {
            var call = GetCall(CallSid);
            TwilioResponse response = new TwilioResponse();
            response.Say("Sorry.  Account management is currently down for repairs.  Please try again in 6 to 8 weeks.");
            response.Hangup();

            return SendTwilioResult(response);
        }
  // helper function to set up a <Gather>
  private static void RenderMainMenu(TwilioResponse response)
  {
    response.BeginGather(new { numDigits = 1 });
    response.Say("For sales, press 1. For support, press 2.");
    response.EndGather();

    // If the user doesn't enter input, loop
    response.Redirect("/voice");
  }
        public ActionResult Hangup()
        {
            var response = new TwilioResponse();
            response.Say(
                "Your recording has been saved. Good bye");
            response.Hangup();

            return TwiML(response);
        }
        public ActionResult ServiceRequest(string CallSid, string Digits)
        {
            var call = GetCall(CallSid);
            TwilioResponse response = new TwilioResponse();

            switch (Digits)
            {
                case "0":
                    {
                        StateManager.AddToLog(CallSid, string.Format("User selected option {0} from service selection.", "Return to Menu"));
                        response.Say("Returning to the main menu.");
                        response.Redirect(Url.Action("IncomingCall"));
                    }
                    break;
                case "1":
                    {
                        StateManager.AddToLog(CallSid, string.Format("User selected option {0} from service selection.", "Manage Account"));
                        response.Say("Please enter your 8 digit account number");
                        response.Gather(
                            new { action = Url.Action("ManageAccount"), timeout = 120, method = "POST", numDigits = 8 });
                    }
                    break;
                case "2":
                    {
                        StateManager.AddToLog(CallSid, string.Format("User selected option {0} from service selection.", "Take a Loan"));
                        response.Say(
                            "All of our loan officers are currently giving money away to people less deserving than you.");
                    }
                    break;
                case "3":
                    {
                        StateManager.AddToLog(CallSid, string.Format("User selected option {0} from service selection.", "Talk to a Representative"));
                    }
                    break;
                default:
                    {
                        response.Say("Oy vey.");
                        response.Redirect(Url.Action("IncomingCall"));
                    } break;
            }

            return SendTwilioResult(response);
        }
 // /Voice/HandleGather
 public TwiMLResult HandleGather(VoiceRequest request)
 {
     var response = new TwilioResponse();
     switch (request.Digits)
     {
       case "1":
     response.Dial("+13105551212");
     response.Say("The call failed or the remote party hung up.  Goodbye.");
     break;
       case "2":
     response.Say("Record your message after the tone.");
     response.Record(new {maxLength = "30", action = "/Voice/HandleRecord"});
     break;
       default:
     response.Redirect("/Voice");
     break;
     }
     return TwiML(response);
 }