0

I am using twilio to make the calls.I am using ASP.NET MVC to create the response and gather inputs

Q1: How can i specify the attributes like lang, voice, loop, pause attributes for verb

 public ActionResult Welcome(string msg) {
  var response = new TwilioResponse();
  response.Say("This is a Sample Message");
  return TwiML(response);
 }

Q2: I am using Gather input for options like a)press 1 to repeat the message. b)press 2 to confirm. c)press 3 to repeat the menu options I am not able to find a way to forward my message parameter (msg) to the Gather action.

 public ActionResult WelcomeCall(string msg)      
 {
     var response = new TwilioResponse();
     response.BeginGather(new
        {
            action = "http://testurl.azurewebsites.net/Gather",
            Digits = "1"
        });
     response.Say(msg);
     response.Say("To repeat the message, press one");
     response.Say("To confirm, press two");
     response.Say("To repeat the menu options, press three");
     response.EndGather();
     return TwiML(response);
  }

  public ActionResult Gather(string Digits) 
  {
      var response = new TwilioResponse();
      if(Digits==1) 
      {
         response.Say(msg);
      }
      return TwiML(response);
   }

Could you please provide a way to handle this case.

1 Answers1

1

Twilio evangelist here.

The Say method (and most of the TwiML methods) have a second parameter that takes an anonymous type allowing you to specify verb attributes:

response.Say("This is a Sample Message", new { voice="alice", loop="2" } );

To pass the message to the Gather handler, you could just append it to the action URL:

response.BeginGather(new
{
    action = "http://testurl.azurewebsites.net/Gather?msg=" + msg,
    Digits = "1"
});
response.EndGather();

Hope that helps.

Devin Rader
  • 10,260
  • 1
  • 20
  • 32
  • Thanks for the response.To pass the message to gather handler you said /Gather?msg="+msg then in the public ActionResult Gather(string msg, string Digits) as parameters.Please confirm.I am not able to receive the msg data in Gather Action – user3311016 Jan 13 '15 at 19:59
  • when i am passing like above.I am getting "we are sorry an application error occurred" or "Gather End" error is occurring.Could you help me on solving this issue. – user3311016 Jan 15 '15 at 19:46