protected override void establish_context()
        {
            this.traceListener = new TestTraceListener();
            Trace.Listeners.Add(this.traceListener);

            this.request = TestData.CreateTestVoiceRequest(InvalidPin);
        }
コード例 #2
0
ファイル: RouterController.cs プロジェクト: kzhen/NHS-HackDay
        public ActionResult RespondToPreConnect(VoiceRequest request)
        {
            var response = connectorRouter.RespondToPreConnect(request);

              Response.ContentType = "text/xml";
              return Content(response.Element.ToString());
        }
コード例 #3
0
  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);
  }
コード例 #4
0
ファイル: RouterController.cs プロジェクト: kzhen/NHS-HackDay
        public ActionResult InitialOptions(VoiceRequest request)
        {
            var response = welcomeRouter.InitialOptions(request);

              Response.ContentType = "text/xml";
              return Content(response.Element.ToString());
        }
コード例 #5
0
        public ActionResult PlayRecordedMessage(VoiceRequest request, int profileId, int? recordingIdx)
        {
            var response = ivrMainLogic.PlayRecordedVoiceMessage(request, profileId, recordingIdx);

              Response.ContentType = "text/xml";
              return Content(response.Element.ToString());
        }
コード例 #6
0
ファイル: RouterController.cs プロジェクト: kzhen/NHS-HackDay
        public ActionResult PreConnect(VoiceRequest request, string callingPartyId)
        {
            var response = connectorRouter.PreConnect(request, callingPartyId);

              Response.ContentType = "text/xml";
              return Content(response.Element.ToString());
        }
コード例 #7
0
        public ActionResult MainMenuSelection(VoiceRequest request)
        {
            var response = ivrMainLogic.GetMenuSelection(request);

              Response.ContentType = "text/xml";
              return Content(response.Element.ToString());
        }
コード例 #8
0
        public TwilioResponse BroadcastResponseSelection(VoiceRequest request, int profileId, int lastBroadcastIdx)
        {
            var response = new TwilioResponse();

              var selection = request.Digits;

              switch (selection)
              {
            case "1":
              response.Redirect(ivrRouteProvider.GetUrlMethod(IVRRoutes.BROADCASTS_REPLY_PRIVATELY, profileId, lastBroadcastIdx));
              return response;
            case "2":
              response.Redirect(ivrRouteProvider.GetUrlMethod(IVRRoutes.BROADCASTS_REPLY_PUBLICLY, profileId, lastBroadcastIdx, null));
              return response;
            case "3":
              response.Redirect(ivrRouteProvider.GetUrlMethod(IVRRoutes.BROADCASTS_LISTEN_TO_ALL_PUBLIC, profileId, ++lastBroadcastIdx));
              return response;
            case "4":
              response.Redirect(ivrRouteProvider.GetUrlMethod(IVRRoutes.BROADCASTS_PLAY_PUBLIC_REPLY, profileId, lastBroadcastIdx, 0));
              return response;
            default:
              response.Redirect(ivrRouteProvider.GetUrlMethod(IVRRoutes.PLAY_MAIN_MENU));
              return response;
              }
        }
コード例 #9
0
 // /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);
 }
コード例 #10
0
            public void Given_A_CorrectPINEntered_Should_RedirectToMainMenu()
            {
                var fromNumber = "+44123456789";
                var pinNumber = "1234";
                var profileManager = new Mock<IProfileManager>();
                var routeProvider = new Mock<IIVRRouteProvider>();

                routeProvider.Setup(m => m.GetUrlMethod(RefUnitedIVRPlatform.Common.IVRRoutes.PLAY_MAIN_MENU, "en")).Returns("/IVRMain/MainMenu");

                profileManager.Setup(m => m.CheckPin(fromNumber, pinNumber)).Returns(true);

                var ivrAuthenticationLogic = new IVRAuthenticateLogic(profileManager.Object, routeProvider.Object);

                var request = new VoiceRequest();
                request.Digits = pinNumber;
                request.Direction = "inbound";
                request.From = fromNumber;

                var response = ivrAuthenticationLogic.GetAuthentication(request, "en");

                Assert.IsNotNull(response);
                Assert.AreEqual(@"<Response>
                  <Redirect method=""POST"">/IVRMain/MainMenu</Redirect>
                </Response>", response.Element.ToString());
            }
コード例 #11
0
 protected static HttpResponseMessage Post(string uri, VoiceRequest request)
 {
     using (var client = CreateHttpClient())
     {
         return client.PostAsJsonAsync(uri, request).Result;
     }
 }
コード例 #12
0
  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);
  }
コード例 #13
0
        //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());
              }
        }
コード例 #14
0
 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);
 }
コード例 #15
0
        public ActionResult PlayRecordedMessage_SaveResponse(VoiceRequest request, int profileId, int recordingIdx, int fromProfileId)
        {
            var response = ivrMainLogic.SaveVoiceMessageReply(request, profileId, recordingIdx, fromProfileId);

              Response.ContentType = "text/xml";
              return Content(response.Element.ToString());
        }
コード例 #16
0
  public TwiMLResult Index(VoiceRequest request)
  {
    var response = new TwilioResponse();

    object conferenceOptions;

    // If the caller is our MODERATOR, then start the conference when they
    // join and end the conference when they leave
    if (request.From == Moderator)
    {
      conferenceOptions = new
      {
        startConferenceOnEnter = true,
        endConferenceOnExit = true
      };
    }
    else
    {
      // Otherwise have the caller join as a regular participant
      conferenceOptions = new {startConferenceOnEnter = false};
    }

    response.DialConference("My conference", conferenceOptions);

    return TwiML(response);
  }
コード例 #17
0
 // /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);
 }
コード例 #18
0
        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);
        }
コード例 #19
0
        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());
        }
コード例 #20
0
        public TwilioResponse GetGreeting(VoiceRequest request)
        {
            string culture = LanguageHelper.GetDefaultCulture();
              var response = new TwilioResponse();

              try
              {
            var lookupPhoneNumber = request.GetOriginatingNumber();

            var knownNumber = profileManager.CheckNumber(lookupPhoneNumber);

            if (knownNumber)
            {
              culture = profileManager.GetCulture(lookupPhoneNumber);
              if (string.IsNullOrEmpty(culture))
              {
            culture = LanguageHelper.GetDefaultCulture();
              }
              else
              {
            culture = LanguageHelper.GetValidCulture(culture);
              }

              IVREntryLang.Culture = new System.Globalization.CultureInfo(culture);
              twiMLHelper = new TwiMLHelper(culture, LanguageHelper.IsImplementedAsMP3(culture));
            }
            else
            {
              twiMLHelper = new TwiMLHelper(LanguageHelper.GetDefaultCulture(), false);
            }

            twiMLHelper.SayOrPlay(response, IVREntryLang.Welcome);

            twiMLHelper.SayOrPlay(response, string.Format(IVREntryLang.PhoneLookup, string.Join(" ", lookupPhoneNumber.ToArray())));

            if (!knownNumber)
            {
              twiMLHelper.SayOrPlay(response, IVREntryLang.PhoneNumberNotFound);
              response.Hangup();
              return response;
            }

            response.BeginGather(new { finishOnKey = "#", action = string.Format("/api/IVRAuthenticate?language={0}", culture) });
            twiMLHelper.SayOrPlay(response, IVREntryLang.EnterPin);
            response.EndGather();

              }
              catch (Exception ex)
              {
            twiMLHelper.SayOrPlay(response, string.Format(IVREntryLang.Error, ex.Message));
            twiMLHelper.SayOrPlay(response, string.Format(IVREntryLang.Error, ex.Message));
            twiMLHelper.SayOrPlay(response, string.Format(IVREntryLang.Error, ex.Message));
            response.Hangup();
              }
              return response;
        }
コード例 #21
0
            public void When_SayIsTheFirstInstruction_Should_ReturnSay()
            {
                IVRLogic logic = new IVRLogic();

                VoiceRequest request = new VoiceRequest();

                var response = logic.EntryPoint(request);

                Assert.IsTrue(response.ToString().Contains("<Say>"));
            }
コード例 #22
0
            public void When_NoInstructionsAreSetup_Should_ReturnDefaultMessage()
            {
                IVRLogic logic = new IVRLogic();

                VoiceRequest request = new VoiceRequest();

                var response = logic.EntryPoint(request);

                Assert.Fail();
            }
コード例 #23
0
ファイル: UserController.cs プロジェクト: jonasrafael/Samples
        public HttpResponseMessage Post(VoiceRequest request, string pin)
        {
            var user = AuthenticationService.GetUser(pin);

            var response = new TwilioResponse();
            response.Say(string.Format("Hello {0}", user.Name));
            response.Pause(2);
            response.Hangup();

            return this.TwiMLResponse(response);
        }
コード例 #24
0
  public TwiMLResult Index(VoiceRequest request)
  {
    // Get information about the incoming call, like the city associated
    // with the phone number (if Twilio can discover it)
    var city = request.FromCity;

    var response = new TwilioResponse();
    response.Say($"Never gonna give you up {city}", new {voice = "alice"});
    response.Play("https://demo.twilio.com/docs/classic.mp3");
    return TwiML(response);
  }
コード例 #25
0
ファイル: WelcomeRouter.cs プロジェクト: kzhen/NHS-HackDay
        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;
        }
コード例 #26
0
 // /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);
 }
コード例 #27
0
            public void ShouldReturnOriginatingNumberForOutboundCall()
            {
                VoiceRequest request = new VoiceRequest()
                {
                  Direction = "outbound-api",
                  To = "+1234567890"
                };

                var originatingNumber = request.GetOriginatingNumber();

                Assert.AreEqual("+1234567890", originatingNumber);
            }
コード例 #28
0
        public HttpResponseMessage IncomingPhone(VoiceRequest call)
        {
            var response = new TwilioResponse();
            response
                .BeginGather(new { action = "http://{{ YOUR URL HERE }}/twilio/response", voice = "woman", numDigits = 1})
                    .Say("Hello there.")
                    .Pause()
                    .Say("Press 1 for customer service.")
                    .Say("Press 2 to hangup")
                .EndGather();

            return Request.CreateResponse(HttpStatusCode.OK, response.Element, new XmlMediaTypeFormatter());
        }
コード例 #29
0
 public ActionResult Complete(VoiceRequest request)
 {
     var response = new TwilioResponse();
     if (request.Digits=="1")
     {
         response.Redirect( Url.Action("Gather"), "GET" );
     }
     else
     {
         response.Redirect( Url.Action("Goodbye"), "GET" );
     }
     return TwiML(response);
 }
コード例 #30
0
 public ActionResult Index(VoiceRequest request)
 {
     var response = new TwilioResponse();
     if (!string.IsNullOrEmpty(request.To))
     {
       response.Dial(new Number(request.To), 
         new {callerId = "+15017250604"});
     }
     else
     {
       response.Say("Thanks for calling!");
     }
     return TwiML(response);
 }