Skip to content
This repository was archived by the owner on Aug 15, 2024. It is now read-only.
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -3,20 +3,22 @@

using System.Web.Mvc;
using Twilio.AspNet.Mvc;
using Twilio.AspNet.Common;
using Twilio.TwiML;
using System;

public class VoiceController : TwilioController
{
[HttpPost]
public ActionResult Index()
public TwiMLResult Index()
{
var response = new VoiceResponse();

// Use the <Gather> verb to collect user input
response.Gather(new Gather(numDigits: 1)
.Say("For sales, press 1. For support, press 2."));
response.Gather(numDigits: 1)
.Say("For sales, press 1. For support, press 2.");
// If the user doesn't enter input, loop
response.Redirect("/voice");
response.Redirect(new Uri("/voice", UriKind.Relative));

return TwiML(response);
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -3,18 +3,20 @@

using System.Web.Mvc;
using Twilio.AspNet.Mvc;
using Twilio.AspNet.Common;
using Twilio.TwiML;
using System;

public class VoiceController : TwilioController
{
[HttpPost]
public ActionResult Index(string digits)
public TwiMLResult Index(VoiceRequest request)
{
var response = new VoiceResponse();

if (!string.IsNullOrEmpty(digits))
if (!string.IsNullOrEmpty(request.Digits))
{
switch (digits)
switch (request.Digits)
{
case "1":
response.Say("You selected sales. Good for you!");
Expand All @@ -39,11 +41,10 @@ public ActionResult Index(string digits)

private static void RenderMainMenu(VoiceResponse response)
{
response.Gather(
new Gather(numDigits: 1)
.Say("For sales, press 1. For support, press 2."));
response.Gather(numDigits: 1)
.Say("For sales, press 1. For support, press 2.");

// If the user doesn't enter input, loop
response.Redirect("/voice");
response.Redirect(new Uri("/voice", UriKind.Relative));
}
}
Original file line number Diff line number Diff line change
@@ -1,21 +1,24 @@
// In Package Manager, run:
// Install-Package Twilio.AspNet.Mvc -DependencyVersion HighestMinor


using System.Web.Mvc;
using Twilio.AspNet.Mvc;
using Twilio.AspNet.Common;
using Twilio.TwiML;
using System;

public class VoiceController : TwilioController
{
[HttpPost]
public ActionResult Gather(string digits)
public TwiMLResult Gather(VoiceRequest request)
{
var response = new VoiceResponse();

// If the user entered digits, process their request
if (!string.IsNullOrEmpty(digits))
if (!string.IsNullOrEmpty(request.Digits))
{
switch (digits)
switch (request.Digits)
{
case "1":
response.Say("You selected sales. Good for you!");
Expand All @@ -25,14 +28,14 @@ public ActionResult Gather(string digits)
break;
default:
response.Say("Sorry, I don't understand that choice.").Pause();
response.Redirect("/voice");
response.Redirect(new Uri("/voice", UriKind.Relative));
break;
}
}
else
{
// If no input was sent, redirect to the /voice route
response.Redirect("/voice");
response.Redirect(new Uri("/voice", UriKind.Relative));
}

return TwiML(response);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -3,34 +3,35 @@

using System.Web.Mvc;
using Twilio.AspNet.Mvc;
using Twilio.AspNet.Common;
using Twilio.TwiML;
using System;

public class VoiceController : TwilioController
{
[HttpPost]
public ActionResult Index()
public TwiMLResult Index()
{
var response = new VoiceResponse();
response.Gather(
new Gather(numDigits: 1, action: "/voice/gather")
.Say("For sales, press 1. For support, press 2."));
response.Gather(numDigits: 1, action: new Uri("/voice/gather", UriKind.Relative))
.Say("For sales, press 1. For support, press 2.");

// If the user doesn't enter input, loop
response.Redirect("/voice");
response.Redirect(new Uri("/voice", UriKind.Relative));

return Content(response.ToString(), "text/xml");
return TwiML(response);
}


[HttpPost]
public ActionResult Gather(string digits)
public TwiMLResult Gather(VoiceRequest request)
{
var response = new VoiceResponse();

// If the user entered digits, process their request
if (!string.IsNullOrEmpty(digits))
if (!string.IsNullOrEmpty(request.Digits))
{
switch (digits)
switch (request.Digits)
{
case "1":
response.Say("You selected sales. Good for you!");
Expand All @@ -40,14 +41,14 @@ public ActionResult Gather(string digits)
break;
default:
response.Say("Sorry, I don't understand that choice.").Pause();
response.Redirect("/voice");
response.Redirect(new Uri("/voice", UriKind.Relative));
break;
}
}
else
{
// If no input was sent, redirect to the /voice route
response.Redirect("/voice");
response.Redirect(new Uri("/voice", UriKind.Relative));
}

return TwiML(response);
Expand Down