//
        // 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));
        }
Пример #2
0
        public async Task <TwilioResponse> SetTimeOut(TwilioRequest request)
        {
            int minutes;
            var response = new TwilioResponse();

            // add prompt for miles
            response.BeginGather(new { timeout = 10, action = GetAction("SetMiles") });
            if (int.TryParse(request.Digits, out minutes))
            {
                using (var db = dbFactory())
                {
                    var signin = await GetMembersLatestSignin(db, this.session.MemberId);

                    signin.TimeOut = signin.TimeOut.Value.AddMinutes(minutes);
                    await db.SaveChangesAsync();

                    this.config.GetPushHub <CallsHub>().updatedRoster(RosterController.GetRosterEntry(signin.Id, db), true);
                    var sayDate = TimeUtils.GetMiltaryTimeVoiceText(signin.TimeOut.Value);
                    response.SayVoice(Speeches.SignedOutTemplate, this.session.MemberName, sayDate);
                }
            }
            response.SayVoice(Speeches.MilesPrompt);
            response.EndGather();

            return(LogResponse(response));
        }
Пример #3
0
    // 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");
    }
Пример #4
0
        private async Task EndMenu(TwilioResponse response, bool isContinuation = false)
        {
            await StartMultiEventMenu(response, GetSignInOutPrompt(), isContinuation);

            response.SayVoice(this.session.HasRecording ? Speeches.PromptRecordReplacementMessageTemplate : Speeches.PromptRecordMessageTemplate, 3);
            response.SayVoice(Speeches.PromptChangeResponder, 8);
            response.SayVoice(Speeches.PromptAdminMenu, 9);
            response.EndGather();
        }
Пример #5
0
        public void Advanced()
        {
            var response = new TwilioResponse();
            response.BeginGather(new { action = "/process_gather.php", method = "GET" });
            response.Say("Enter something, or not");
            response.EndGather();
            response.Redirect("/process_gather.php?Digits=TIMEOUT", "GET");

            Assert.IsTrue(IsValidTwiML(response.ToXDocument()));
        }
Пример #6
0
        public void Example_2()
        {
            var response = new TwilioResponse();
            response.BeginGather(new { action = "/process_gather.php", method = "GET" });
            response.Say("Please enter your account number, followed by the pound sign");
            response.EndGather();
            response.Say("We didn't receive any input. Goodbye!");

            Assert.IsTrue(IsValidTwiML(response.ToXDocument()));
        }
Пример #7
0
        public void Advanced()
        {
            var response = new TwilioResponse();

            response.BeginGather(new { action = "/process_gather.php", method = "GET" });
            response.Say("Enter something, or not");
            response.EndGather();
            response.Redirect("/process_gather.php?Digits=TIMEOUT", "GET");

            Assert.IsTrue(IsValidTwiML(response.ToXDocument()));
        }
        public async Task <TwilioResponse> DoMenu(TwilioRequest request)
        {
            var response = new TwilioResponse();

            if (request.Digits == "1")
            {
                var now      = TimeUtils.GetLocalDateTime(this.config);
                var newEvent = new SarEvent {
                    Name = "New Event at " + TimeUtils.GetMiltaryTimeVoiceText(now), Opened = now
                };
                await this.eventService.Create(newEvent);

                LoadActiveEvents();
                this.session.EventId = newEvent.Id;

                BeginMenu(response);
                response.SayVoice("Created " + newEvent.Name);

                await EndMenu(response);
            }
            else if (request.Digits == "2")
            {
                using (var db = dbFactory())
                {
                    BuildSetEventMenu(response, string.Empty, Url.Content("~/api/VoiceAdmin/Menu"));
                }
            }
            else if (request.Digits == "3")
            {
                response.SayVoice("Record a short description of this event at the tone");
                response.Record(new { maxLength = 120, action = GetAction("SetDescription", controller: "VoiceAdmin") });
                BeginMenu(response);
                await EndMenu(response);
            }
            else if (request.Digits == "9")
            {
                Dictionary <string, string> args = new Dictionary <string, string>();
                args.Add("targetId", this.session.EventId.ToString());
                response.BeginGather(new { numDigits = 1, action = GetAction("ConfirmClose", args, controller: "VoiceAdmin"), timeout = 10 });
                response.SayVoice("Press 9 to confirm close of {0}. Press any other key to return to menu.", GetEventName());
                response.EndGather();
            }
            else if (request.Digits == "0")
            {
                response.Redirect(GetAction("Menu"));
            }
            else
            {
                response.SayVoice("I didn't understand.");
                BeginMenu(response);
                await EndMenu(response);
            }
            return(response);
        }
Пример #9
0
        public void Example_2()
        {
            var response = new TwilioResponse();

            response.BeginGather(new { action = "/process_gather.php", method = "GET" });
            response.Say("Please enter your account number, followed by the pound sign");
            response.EndGather();
            response.Say("We didn't receive any input. Goodbye!");

            Assert.IsTrue(IsValidTwiML(response.ToXDocument()));
        }
 // /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);
 }
        /// <summary>
        ///
        /// </summary>
        /// <param name="response"></param>
        private async Task EndMenu(TwilioResponse response)
        {
            await StartMultiEventMenu(response, "create a new event");

            if (this.session.EventId != null)
            {
                response.SayVoice("Press 3 to record a new greeting");
                response.SayVoice("Press 9 to close this mission");
            }
            response.SayVoice("Press 0 to return to main menu");
            response.EndGather();
        }
Пример #12
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);
        }
Пример #13
0
        public ActionResult PlaceInConference(bool mute)
        {
            Debug.WriteLine("Putting caller into conference: {0}", mute);

            var response = new TwilioResponse();

            response.DialConference("Chapter18Conference", new { muted = mute, beep = false, startConferenceOnEnter = true, endConferenceOnExit = false }, new { hangupOnStar = true });
            response.BeginGather(new { action = Url.ActionAbsolute("ProcessCommand"), numDigits = "1" });
            response.EndGather();
            response.Say("Bye");

            return(TwiML(response));
        }
Пример #14
0
        public void _1_4a()
        {
            var name = "Monkey";

            var response = new TwilioResponse();
            response.Say("Hello " + name);
            response.Play("http://demo.twilio.com/hellomonkey/monkey.mp3");
            response.BeginGather(new { numDigits = 1, action = "hello-monkey-handle-key.php", method = "POST" });
            response.Say("To speak to a real monkey, press 1. Press 2 to record your own monkey howl. Press any other key to start over.");
            response.EndGather();

            Assert.IsTrue(IsValidTwiML(response.ToXDocument()));
        }
Пример #15
0
        private async Task AddLoginPrompt(TwilioResponse response, string next)
        {
            Dictionary <string, string> args = new Dictionary <string, string>();

            args.Add(NextKey, next ?? Url.Content("~/api/Voice/Menu"));

            response.BeginGather(new { timeout = 10, action = GetAction("DoLogin", args) });
            response.SayVoice(Speeches.DEMPrompt);
            response.SayVoice(Speeches.GoBack);
            response.EndGather();
            BeginMenu(response);
            await EndMenu(response);
        }
Пример #16
0
        public void _1_4a()
        {
            var name = "Monkey";

            var response = new TwilioResponse();

            response.Say("Hello " + name);
            response.Play("http://demo.twilio.com/hellomonkey/monkey.mp3");
            response.BeginGather(new { numDigits = 1, action = "hello-monkey-handle-key.php", method = "POST" });
            response.Say("To speak to a real monkey, press 1. Press 2 to record your own monkey howl. Press any other key to start over.");
            response.EndGather();

            Assert.True(IsValidTwiML(response.ToXDocument()));
        }
Пример #17
0
    public TwiMLResult Index(VoiceRequest request)
    {
        var response = new TwilioResponse();

        // Use the <Gather> verb to collect user input
        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");

        return(TwiML(response));
    }
Пример #18
0
 public void EnterNumber(
     string message,
     Dictionary <string, string> urlParameters,
     int amountOfDigis = 1,
     int wait_time     = 10
     )
 {
     response.BeginGather(new
     {
         action    = GetCallbackUrl(TwillioConfig.VoiceCallbackUrl, urlParameters),
         numDigits = amountOfDigis
     });
     response.Say(message);
     response.EndGather();
 }
Пример #19
0
        public TwilioResponse PreConnect(VoiceRequest request, string callingPartyId)
        {
            var response = new TwilioResponse();

            var callingParty = directory.GetContact(callingPartyId);

            response.BeginGather(new { numDigits = 1, action = "/Router/RespondToPreConnect" });
            response.Say(string.Format("You have an incoming call from {0}", callingParty.Name));
            response.Say("Press 1 to be connected");
            response.Say("Press 2 to hangup");
            response.EndGather();
            response.Hangup();

            return(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.BeginGather(
                    new { action = Url.Action("ManageAccount"), timeout = 120, method = "POST", numDigits = 8 });
                response.Say("Please enter your 8 digit account number");
                response.EndGather();
            }
            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));
        }
Пример #21
0
        public ActionResult AdvancedWait(string QueuePosition, string QueueTime, string AvgWaitTime, string CurrentQueueSize)
        {
            var response = new TwilioResponse();

            response.Say(string.Format("Bwahahaha!  Your time in the queue has been {0} seconds.  Enjoy your wait with {1} of your friends!", QueueTime, CurrentQueueSize));

            response.BeginGather(new { action = Url.Action("AdvancedWaitGather", "Queue", null, "http") });

            //TODO: for some reason I have to hit # to get the Gather to work.  Not sure why?
            response.Say("Enter the magic number now to be released from the queue", new { numDigits = "3", timeout = "7" });
            response.EndGather();

            response.Say("Not even brave enough to proffer a guess?  Figures.  You can try again in a bit.");
            response.Pause(10); //TODO: replace this with a play

            return(TwiML(response));
        }
        public async Task <TwilioResponse> Menu()
        {
            var response = new TwilioResponse();

            if (this.session.IsAdmin == false)
            {
                response.BeginGather(new { numDigits = 10, action = GetAction("Login", controller: "VoiceAdmin"), timeout = 10 });
                response.SayVoice("Enter admin password followed by pound");
                response.EndGather();
            }
            else
            {
                BeginMenu(response);
                await EndMenu(response);
            }

            return(response);
        }
Пример #23
0
        public HttpResponseMessage Menu(VoiceRequest request)
        {
            var response = new TwilioResponse();

            response.BeginGather(new { action = "menu_selection" });

            // "For general information about this property, press 1. " +
            // "If you are an agent or a broker, and you would like to schedule a viewing, press 2. "+
            // "If you are not an agent and would like to schedule a viewing, press 3. " +
            // "To request more information about the home or to make an offer, press 4."
            // "For a quicker response, text your question to this number directly."
            response.Play("/audio/menu.mp3");

            response.EndGather();
            response.Pause();
            response.Redirect("menu");

            return(TWiML(response));
        }
Пример #24
0
        public TwilioResponse InitialOptions(VoiceRequest request)
        {
            TwilioResponse response = new TwilioResponse();

            var id = request.Digits;

            if (!directory.ExtensionExists(id))
            {
                response.Say("We couldn't find your I D.");
                response.Hangup();
            }

            response.BeginGather(new { finishOnKey = "#", action = string.Format("/Router/PingInital?callingPartyId={0}", id) });
            response.Say("To contact an individual, enter their 4 digit I D and then press the hash button");
            response.Say("To contact a team, enter star followed by the 4 digit I D and then press the hash button");
            response.EndGather();

            return(response);
        }
        protected void BuildSetEventMenu(TwilioResponse response, string prompt, string thenUrl)
        {
            Dictionary <string, string> args = new Dictionary <string, string>();

            args.Add("evtIds", string.Join(".", this.CurrentEvents.Select(f => f.Id.ToString())));
            args.Add("next", thenUrl);

            response.BeginGather(new { timeout = 10, action = GetAction("SetEvent", args) });
            if (!string.IsNullOrWhiteSpace(prompt))
            {
                response.SayVoice(prompt);
            }
            response.SayVoice(string.Format("There are {0} events in progress. ", this.CurrentEvents.Count));
            for (int i = 0; i < this.CurrentEvents.Count; i++)
            {
                response.SayVoice(string.Format("Press {0} then pound for {1}. ", i + 1, this.CurrentEvents[i].Name));
            }
            response.EndGather();
        }
Пример #26
0
        public ActionResult PlayInvitation(string CallSid)
        {
            var response = new TwilioResponse();

            response.BeginGather(
                new {
                action    = Url.ActionAbsolute("PlayInvitation"),
                method    = "POST",
                numDigits = "1",
                timeout   = "3"
            });

            response.Say("Lets play a game while you wait.");
            response.Say("If you would rather just listen to music, press 1");
            response.EndGather();

            response.Redirect(Url.ActionAbsolute("Introduction"), "GET");

            return(TwiML(response));
        }
Пример #27
0
        public ActionResult ReadQuestion(string CallSid)
        {
            var gameState       = QuizShowState.Load(CallSid);
            var currentQuestion = gameState.Questions[gameState.CurrentQuestionIndex];

            var response = new TwilioResponse();

            response.Say(". OK.  Here is question number " + (gameState.CurrentQuestionIndex + 1).ToString() + ". .");

            response.BeginGather(
                new
            {
                action    = Url.ActionAbsolute("CaptureAnswer"),
                method    = "POST",
                numDigits = "1",
                timeout   = "5"
            });

            response.Say(string.Format("{0}? . . ", currentQuestion.Text));
            response.Say("Is the answer. . ");

            var orderedAnswers = currentQuestion.PossibleAnswers.OrderBy(a => a.Order).ToList();

            for (int i = 0; i < orderedAnswers.Count(); i++)
            {
                if (i == (orderedAnswers.Count() - 1))
                {
                    response.Say(string.Format("Or. {0}. {1}. . ", (i + 1).ToString(), orderedAnswers[i].Text));
                }
                else
                {
                    response.Say(string.Format(". {0}. {1}. . ", (i + 1).ToString(), orderedAnswers[i].Text));
                }
            }

            response.EndGather();
            response.Redirect(Url.ActionAbsolute("NoAnswerProvided"), "GET");

            gameState.Save();
            return(TwiML(response));
        }
Пример #28
0
        public async Task <TwilioResponse> DoSignInOut(TwilioRequest request)
        {
            var response = new TwilioResponse();

            using (var db = dbFactory())
            {
                var signin = await db.SignIns.Where(f => f.MemberId == this.session.MemberId).OrderByDescending(f => f.TimeIn).FirstOrDefaultAsync();

                var call = await db.Calls.SingleAsync(f => f.CallId == request.CallSid);

                DateTimeOffset time    = TimeUtils.GetLocalDateTime(this.config);
                var            sayDate = TimeUtils.GetMiltaryTimeVoiceText(time);

                if (signin == null || signin.TimeOut.HasValue)
                {
                    if (this.session.IsSignedIn)
                    {
                        throw new InvalidOperationException("Tried to sign out when not signed in");
                    }

                    signin = new MemberSignIn
                    {
                        MemberId = this.session.MemberId,
                        isMember = true,
                        Name     = this.session.MemberName,
                        TimeIn   = time,
                        EventId  = (this.CurrentEvents.Count == 1) ? this.CurrentEvents[0].Id : this.session.EventId,
                    };

                    db.SignIns.Add(signin);
                    call.Actions.Add(new CallAction {
                        Call = call, CallId = call.Id, Time = signin.TimeIn, Action = "Signed in " + signin.Name
                    });
                    await db.SaveChangesAsync();

                    this.session.IsSignedIn = true;

                    if (this.CurrentEvents.Count == 0)
                    {
                        await RosterController.AssignInternal(signin, null, db, this.config);

                        BeginMenu(response);
                        response.SayVoice(Speeches.SignedInUnassignedTemplate, this.session.MemberName, sayDate);
                        await EndMenu(response);
                    }
                    else if (this.CurrentEvents.Count == 1)
                    {
                        await RosterController.AssignInternal(signin, this.CurrentEvents[0].Id, db, this.config);

                        BeginMenu(response);
                        response.SayVoice(Speeches.SignedInTemplate, this.CurrentEvents[0].Name, this.session.MemberName, sayDate);
                        await EndMenu(response);
                    }
                    else
                    {
                        await RosterController.AssignInternal(signin, null, db, this.config);

                        BuildSetEventMenu(response, string.Format(Speeches.SignedInUnassignedTemplate, this.session.MemberName, sayDate), Url.Content("~/api/voice/SetSigninEvent"));
                    }
                }
                else
                {
                    signin.TimeOut = time;
                    call.Actions.Add(new CallAction {
                        Call = call, CallId = call.Id, Time = time, Action = "Signed out " + this.session.MemberName
                    });
                    this.session.IsSignedIn = false;
                    await db.SaveChangesAsync();

                    this.config.GetPushHub <CallsHub>().updatedRoster(RosterController.GetRosterEntry(signin.Id, db), true);

                    // add prompt for timeout beyond right now
                    response.BeginGather(new { timeout = 10, action = GetAction("SetTimeOut") });
                    response.SayVoice(Speeches.SignedOutTemplate, this.session.MemberName, sayDate);
                    response.SayVoice(Speeches.TimeoutPrompt);
                    response.EndGather();
                }
            }

            return(LogResponse(response));
        }
Пример #29
0
        public HttpResponseMessage Menu_Selection(VoiceRequest request)
        {
            var response = new TwilioResponse();

            if (request.Digits == "4")
            {
                response.Redirect("/ivr/record/" + CallType.Unknown);
                return(TWiML(response));
            }

            var record = true;
            var type   = CallType.Unknown;

            response.BeginGather(new { action = "record/" + type });

            // "To skip these recordings and leave a message, press 1 at any time. "
            response.Play("/audio/skip.mp3");

            switch (request.Digits)
            {
            case ("1"):
            {
                // "The house sits on the corner of West Ellsworth and Bannock located in the heart of the historic Baker neighborhood. " +
                // "There is over 1700 finished square feet in this classic contemporary town-home, built in the 1890s. " +
                // "The house has been updated with modern finishes, like the walnut cabinets, granite counter-tops and stainless steel appliances. " +
                // "There are two bedrooms upstairs and a non-conforming master bedroom in the basement that could also serve as a theater room, den or man-cave. " +
                // "The kitchen has granite counter-tops and new stainless steel appliances. " +
                // "This location is perfect for urban commuters. It's only a few blocks from the light-rail station, and the zero bus (which runs downtown every 15 minutes). " +
                // "Located two blocks off Broadway, the house is a stone's throw from many great restaurants, boutiques, coffee shops and an ice-cream parlor. " +
                // "Not to mention the thriving nightlife.  " +
                // "There is beautiful hardwood floors, brand-new high-quality carpet, sky lights and two great travertine tiled bathrooms, " +
                // "one with a full tub the other with a two-person shower. " +
                // "The asking price is 375 thousand. "
                response.Play("/audio/description.mp3");

                record = false;

                break;
            }

            case ("2"):
            {
                // "This house is for sale by owner. The owner will work with buyers agents. " +
                // "To gain access to the home, please leave a message with your full name, company name, mobile number, buyers name and the date and time you would like to view the home. " +
                // "When approved, you will receive a text with the lock-box access code. "
                response.Play("/audio/agents.mp3");

                type = CallType.Agent;

                break;
            }

            case ("3"):
            {
                // "To schedule a viewing please leave a message with your full name, drivers license number, cell-phone number and the date and time you would like to view the home. " +
                // "When approved, you will receive a text with the lock-box access code. "+
                // "To speak directly to the owner, press 2. "
                response.Play("/audio/non-agent.mp3");

                type = CallType.NonAgent;

                break;
            }

            case ("4"):
            {
                type = CallType.Request;

                break;
            }
            }

            response.EndGather();

            response.Redirect(record ? "/ivr/record/" + type : "menu");

            return(TWiML(response));
        }