//
        // 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));
        }
Ejemplo n.º 2
0
        public void Can_Generate_Single_Pause_With_Length()
        {
            var response = new TwilioResponse();
            response.Pause(10);

            Assert.True(IsValidTwiML(response.ToXDocument()));
        }
Ejemplo n.º 3
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()));
            }
        }
Ejemplo n.º 4
0
        public void Example_2()
        {
            var response = new TwilioResponse();
            response.Pause(5);
            response.Say("Hi there.");

            Assert.IsTrue(IsValidTwiML(response.ToXDocument()));
        }
Ejemplo n.º 5
0
        public void Can_Generate_Single_Pause()
        {
            var response = new TwilioResponse();

            response.Pause();

            Assert.IsTrue(IsValidTwiML(response.ToXDocument()));
        }
        //
        // GET: /CallCenter/

        public ActionResult Index()
        {
            var response = new TwilioResponse();

            response.Pause(5);
            response.Say("Thanks for calling the Music Store");
            return(TwiML(response));
        }
Ejemplo n.º 7
0
        public ActionResult BadResponse()
        {
            var response = new TwilioResponse();

            response.Say("This call will self destruct in 5 seconds");
            response.Pause(5);
            response.Redirect(Url.Action("Boom", "Fallback", null, "http"));
            return(TwiML(response));
        }
Ejemplo n.º 8
0
        public void Example_2()
        {
            var response = new TwilioResponse();

            response.Pause(5);
            response.Say("Hi there.");

            Assert.IsTrue(IsValidTwiML(response.ToXDocument()));
        }
Ejemplo n.º 9
0
        public void Example_1()
        {
            var response = new TwilioResponse();
            response.Say("I will pause 10 seconds starting now!");
            response.Pause(10);
            response.Say("I just paused 10 seconds");

            Assert.IsTrue(IsValidTwiML(response.ToXDocument()));
        }
Ejemplo n.º 10
0
        public void Example_1()
        {
            var response = new TwilioResponse();

            response.Say("I will pause 10 seconds starting now!");
            response.Pause(10);
            response.Say("I just paused 10 seconds");

            Assert.IsTrue(IsValidTwiML(response.ToXDocument()));
        }
Ejemplo n.º 11
0
        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));
        }
Ejemplo n.º 12
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));
        }
Ejemplo n.º 13
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));
        }
Ejemplo n.º 14
0
        public HttpResponseMessage Post(VoiceRequest request, string userId)
        {
            var response = new TwilioResponse();

            var usernames = new Dictionary <string, string>
            {
                { "12345", "Tom" },
                { "23456", "Dick" },
                { "34567", "Harry" }
            };

            var username = usernames[userId];

            response.Say(string.Format("Hello {0}", username));
            response.Pause(5);
            response.Hangup();

            return(this.Request.CreateResponse(HttpStatusCode.OK, response.Element, new XmlMediaTypeFormatter()));
        }
Ejemplo n.º 15
0
            //create a default ringing TwiML response
            public static TwilioResponse GetResponseRing(TwilioRequestVoice request, Entity.Client client, Entity.Call call)
            {
                TwilioResponse resp = new TwilioResponse();

                //is client available?
                if (client == null ||
                    client.ClientState != Entity.Client.ClientStateEnum.Available)
                {
                    if (log.IsDebugEnabled) { log.Debug("GetResponseRing.Unavailable.request." + (request == null ? "null" : request.ToJsonString())); }

                    //transfer to unavailable voicemail
                    return GetResponseVoicemail(request, client, call);
                }
                else
                {
                    if (log.IsDebugEnabled) { log.Debug("GetResponseRing.request." + (request == null ? "null" : request.ToJsonString())); }

                    //TODO: find a ring MP3 file to play instead of just pausing with silence
                    //definte the default ringing response
                    resp.Pause(1);
                    resp.Say("Asking the person you are calling what they want to do.");
                    resp.Pause(20);

                    //if the call isn't dealt with after the specified time, then transfer the person to voicemail
                    GetResponseVoicemail(resp, request, client, call);

                    //log the current call state
                    if (call != null)
                    {
                        call.CallResult = "ringing";
                        call.Save();
                    }
                }

                return resp;
            }
Ejemplo n.º 16
0
            //create a TwiML response to transfer the call
            public static TwilioResponse GetResponseTransfer(TwilioRequestVoice request, Entity.Client client, Entity.Call call)
            {
                TwilioResponse resp = new TwilioResponse();

                if (call != null &&
                    !string.IsNullOrEmpty(call.TransferTo))
                {
                    if (log.IsDebugEnabled) { log.Debug("GetResponseTransfer.request." + (request == null ? "null" : request.ToJsonString())); }

                    if (request.CallRecord)
                        GetResponseRecord(resp, request, client, call);

                    resp.Pause(1);
                    resp.Say("You are being transferred now.");

                    //TODO: pull caller id from database
                    //caller ID is required for outbound calls; it must be registered with your twilio account
                    string callerId = ConfigurationManager.AppSettings["DemoCallerId"];

                    Twilio.TwiML.Number number = new Twilio.TwiML.Number(call.TransferTo);
                    resp.Dial(number, new { callerId = callerId });

                    //update call result
                    if (call != null)
                    {
                        call.CallResult = "transfered to " + call.TransferTo;
                        call.Save();
                    }
                }
                else
                {
                    if (log.IsDebugEnabled) { log.Error("GetResponseTransfer.NoTransferNumber.request." + (request == null ? "null" : request.ToJsonString())); }

                    //no transfer number, send to voicemail
                    resp = GetResponseVoicemail(request, client, call);
                }

                return resp;
            }
Ejemplo n.º 17
0
            //create a TwiML response for calls to an unknown client
            public static TwilioResponse GetResponseUnknownClient(TwilioRequestVoice request, Entity.Call call)
            {
                if (log.IsDebugEnabled) { log.Debug("GetResponseUnknownClient.request." + (request == null ? "null" : request.ToJsonString())); }

                TwilioResponse resp = new TwilioResponse();

                resp.Pause(1);
                resp.Say("We're sorry.  The person you are trying to reach could not be found.");
                resp.Pause(1);
                resp.Hangup();

                //log the current call state
                if (call != null)
                {
                    call.CallResult = "unknown client";
                    call.Save();
                }

                return resp;
            }
Ejemplo n.º 18
0
            //create a TwiML response to send the call to voicemail; appends the response to an existing response
            public static TwilioResponse GetResponseVoicemail(TwilioResponse resp, TwilioRequestVoice request, Entity.Client client, Entity.Call call)
            {
                if (log.IsDebugEnabled) { log.Debug("GetResponseVoicemail.request." + (request == null ? "null" : request.ToJsonString())); }

                //TODO: create valid voicemail box dial plan
                resp.Pause(1);
                resp.Say("You are being transferred to voicemail, but it's not setup yet.  Goodbye.");
                resp.Pause(1);
                resp.Hangup();

                //log the current call state
                if (call != null)
                {
                    call.CallResult = "sent to voicemail";
                    call.Save();
                }

                return resp;
            }
Ejemplo n.º 19
0
            //create a TwiML response to answer the call
            public static TwilioResponse GetResponseAnswer(TwilioRequestVoice request, Entity.Client client, Entity.Call call)
            {
                TwilioResponse resp = new TwilioResponse();

                if (client == null ||
                    client.ClientState != Entity.Client.ClientStateEnum.Available)
                {
                    if (log.IsDebugEnabled) { log.Debug("GetResponseAnswer.Unavailable.request." + (request == null ? "null" : request.ToJsonString())); }

                    //transfer to unavailable voicemail
                    return GetResponseVoicemail(request, client, call);
                }
                else
                {
                    if (log.IsDebugEnabled) { log.Debug("GetResponseAnswer.request." + (request == null ? "null" : request.ToJsonString())); }

                    resp.Pause(1);

                    if (request.CallRecord)
                        GetResponseRecord(resp, request, client, call);

                    resp.Say("Your call is being answered now.");

                    //find the number to dial
                    string toNumber = request.To;
                    if (string.IsNullOrEmpty(toNumber))
                        toNumber = call.ToNumber;

                    //TODO: pull caller id from database
                    //caller ID is required for outbound calls; it must be registered with your twilio account
                    string callerId = ConfigurationManager.AppSettings["DemoCallerId"];;

                    if (toNumber.StartsWith("client:"))
                    {
                        //call is being routed to a twilio client
                        Twilio.TwiML.Client clientToCall = new Twilio.TwiML.Client(toNumber.Replace("client:",""));
                        resp.Dial(clientToCall, new { callerId = callerId });
                    }
                    else
                    {
                        //call is being routed to an external number
                        Twilio.TwiML.Number number = new Twilio.TwiML.Number(toNumber);
                        resp.Dial(number, new { callerId = callerId });
                    }

                    //log the current call state
                    if (call != null)
                    {
                        call.CallResult = "answered by " + request.To;
                        call.Save();
                    }
                }

                return resp;
            }
Ejemplo n.º 20
0
            //create a TwiML response to ignore the call
            public static TwilioResponse GetResponseIgnore(TwilioRequestVoice request, Entity.Client client, Entity.Call call)
            {
                if (log.IsDebugEnabled) { log.Debug("GetResponseIgnore.request." + (request == null ? "null" : request.ToJsonString())); }

                TwilioResponse resp = new TwilioResponse();

                //TODO: create an ignored voicemail box to send the call to
                resp.Pause(1);
                resp.Say("Your call was ignored.");
                resp.Pause(1);
                resp.Hangup();

                //log the current call state
                if (call != null)
                {
                    call.CallResult = "call was ignored";
                    call.Save();
                }

                return resp;
            }