public HttpResponseMessage HandleConferenceCall(TwilioGatherRequest twilioRequest) { var digits = twilioRequest.Digits; var twilioResponse = new TwilioResponse(); var conference = _client.ListConferences().Conferences.FirstOrDefault(name => name.FriendlyName.Equals(digits)); if (digits == "2") { twilioResponse.BeginGather( new { action = Url.Link("ExtendedApi", new { controller = "Phone", action = "CreateOrJoinConferenceCall" }), finishOnKey = "#", timeout = 8 }); twilioResponse.Say("Please enter the number of conference call you want to join, followed by the pound key.", _voicesettings); twilioResponse.EndGather(); } else if (conference == null) { twilioResponse.BeginGather( new { action = Url.Link("ExtendedApi", new {controller = "Phone", action = "HandleConferenceCall"}), numDigits = 1 }); twilioResponse.Say( string.Format( "A conference with number {0} doesn't exist. If you wish to create a conference Press 1, otherwise wait 5 seconds to return to the main menu", digits), _voicesettings); twilioResponse.EndGather(); /* Stop gather and inform falling back to the main menu */ twilioResponse.Say("No conference number was provided. You're returning to the main menu. Thank you.", _voicesettings); /* Fall back to main menu */ twilioResponse.Redirect(Url.Link("ExtendedApi", new {controller = "Phone", action = "AnswerIncomingCall"})); } else if(digits == "1") { twilioResponse.BeginGather( new { action = Url.Link("ExtendedApi", new { controller = "Phone", action = "CreateOrJoinConferenceCall"}), finishOnKey = "#", timeout = 8 }); twilioResponse.Say("Please enter the number of conference call you want to create, followed by the pound key.", _voicesettings); twilioResponse.EndGather(); } return Request.CreateResponse(HttpStatusCode.OK, twilioResponse.Element); }
public HttpResponseMessage CreateOrJoinConferenceCall(TwilioGatherRequest twilioRequest) { var conference = _client.ListConferences().Conferences.FirstOrDefault(name => name.FriendlyName.Equals(twilioRequest.Digits)); var twilioResponse = new TwilioResponse(); var digits = twilioRequest.Digits; twilioResponse.Say(string.Format("You're now joining conference {0}. Thank you.", digits), _voicesettings); if (conference != null) { var participant = _client.GetConferenceParticipant(conference.Sid, twilioRequest.CallSid); var context = GlobalHost.ConnectionManager.GetHubContext<Hubs.ConferenceHub>(); context.Clients.addParticipant(participant.ConferenceSid, participant.CallSid, participant.Muted); } twilioResponse.DialConference(twilioRequest.Digits, new { waitUrl = "http://twimlets.com/holdmusic?Bucket=com.twilio.music.rock", endConferenceOnExit = true }); twilioResponse.Redirect(Url.Link("ExtendedApi", new { controller = "Phone", action = "GoodByeMessage" })); return Request.CreateResponse(HttpStatusCode.OK, twilioResponse.Element); }
public HttpResponseMessage ProcessMenuCall(TwilioGatherRequest twilioRequest) { var twilioResponse = new TwilioResponse(); var digits = twilioRequest.Digits; switch (digits) { case "1": twilioResponse.Redirect(Url.Link("ExtendedApi", new { controller = "Phone", action = "JoinQueue" })); break; case "2": twilioResponse.Say("You're awesome!", _voicesettings); break; case "3": twilioResponse.Redirect(Url.Link("ExtendedApi", new { controller = "Phone", action = "RecordMessage" })); break; case "0": twilioResponse.Redirect(Url.Link("ExtendedApi", new { controller = "Phone", action = "AnswerIncomingCall" })); break; } twilioResponse.Redirect(Url.Link("ExtendedApi", new { controller = "Phone", action = "HandleMenuCall" })); return Request.CreateResponse(HttpStatusCode.OK, twilioResponse.Element); }
public HttpResponseMessage HandleMenuCall(TwilioGatherRequest twilioRequest) { var twilioResponse = new TwilioResponse(); twilioResponse.Say("Welcome to VoxVoi", _voicesettings); twilioResponse.BeginGather( new { action = Url.Link("ExtendedApi", new { controller = "Phone", action = "ProcessMenuCall" }), numDigits = 1 }); twilioResponse.Say("Press 1 to connect with an agent", _voicesettings); twilioResponse.Say("Press 2 to be awesome", _voicesettings); twilioResponse.Say("Press 3 to leave a message", _voicesettings); twilioResponse.Say("Press 0 to return to the main menu", _voicesettings); twilioResponse.EndGather(); twilioResponse.Redirect(Url.Link("ExtendedApi", new {controller = "Phone", action = "HandleMenuCall"})); return Request.CreateResponse(HttpStatusCode.OK, twilioResponse.Element); }