當前位置: 首頁>>代碼示例>>C#>>正文


C# TwiML.TwilioResponse類代碼示例

本文整理匯總了C#中Twilio.TwiML.TwilioResponse的典型用法代碼示例。如果您正苦於以下問題:C# TwilioResponse類的具體用法?C# TwilioResponse怎麽用?C# TwilioResponse使用的例子?那麽, 這裏精選的類代碼示例或許可以為您提供幫助。


TwilioResponse類屬於Twilio.TwiML命名空間,在下文中一共展示了TwilioResponse類的15個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的C#代碼示例。

示例1: Index

 // /Voice
 public TwiMLResult Index(VoiceRequest request)
 {
     var response = new TwilioResponse();
     response.Say("Hello. It's me.");
     response.Play("http://howtodocs.s3.amazonaws.com/ahoyhoy.mp3");
     return TwiML(response);
 }
開發者ID:TwilioDevEd,項目名稱:api-snippets,代碼行數:8,代碼來源:example-1.4.x.cs

示例2: Can_Generate_Enqueue_With_Name

        public void Can_Generate_Enqueue_With_Name()
        {
            var response = new TwilioResponse();
            response.Enqueue("example");

            Assert.IsTrue(IsValidTwiML(response.ToXDocument()));
        }
開發者ID:HafsaNaveed,項目名稱:twilio-csharp,代碼行數:7,代碼來源:EnqueueTests.cs

示例3: Can_Generate_Enqueue_With_Options_And_TaskAttributes

        public void Can_Generate_Enqueue_With_Options_And_TaskAttributes()
        {
            var response = new TwilioResponse();
            response.Enqueue(new { action = "example.xml", method = "GET", waitUrl = "wait.xml", waitUrlMethod = "GET", workspaceSid = "WSXXXXX" }, "{'task':'attributes'}");

            Assert.IsTrue(IsValidTwiML(response.ToXDocument()));
        }
開發者ID:HafsaNaveed,項目名稱:twilio-csharp,代碼行數:7,代碼來源:EnqueueTests.cs

示例4: Index

  public TwiMLResult Index(VoiceRequest request)
  {
    var response = new TwilioResponse();

    if (!string.IsNullOrEmpty(request.Digits))
    {
      switch (request.Digits)
      {
        case "1":
          response.Say("You selected sales. Good for you!");
          break;
        case "2":
          response.Say("You need support. We will help!");
          break;
        default:
          response.Say("Sorry, I don't understand that choice.").Pause();
          RenderMainMenu(response);
          break;
      }
    }
    else
    {
      // If no input was sent, use the <Gather> verb to collect user input
      RenderMainMenu(response);
    }

    return TwiML(response);
  }
開發者ID:TwilioDevEd,項目名稱:api-snippets,代碼行數:28,代碼來源:example.4.x.cs

示例5: RedirectWelcome

        private TwiMLResult RedirectWelcome()
        {
            var response = new TwilioResponse();
            response.Redirect(Url.Action("Welcome", "IVR"));

            return TwiML(response);
        }
開發者ID:TwilioDevEd,項目名稱:ivr-recording-csharp,代碼行數:7,代碼來源:MenuController.cs

示例6: ResponseToSms

        public TwilioResponse ResponseToSms(SmsRequest request)
        {
            var response = new TwilioResponse();

              try
              {
            string outboundPhoneNumber = request.From;

            var client = new TwilioRestClient(accountSid, authToken);

            var call = client.InitiateOutboundCall(
              twilioPhoneNumber,
              outboundPhoneNumber,
              "http://refuniteivr.azurewebsites.net/api/IVREntry");

            if (call.RestException == null)
            {
              response.Sms("starting call to " + outboundPhoneNumber);
            }
            else
            {
              response.Sms("failed call to " + outboundPhoneNumber + " " + call.RestException.Message);
            }

            return response;
              }
              catch (Exception ex)
              {
            response.Sms("exception: " + ex.Message);
            return response;
              }
        }
開發者ID:kzhen,項目名稱:RefUnited-IVR-Platform,代碼行數:32,代碼來源:SMSReceiverLogic.cs

示例7: Dial

        private static TwiMLResult Dial(string phoneNumber)
        {
            var response = new TwilioResponse();
            response.Dial(phoneNumber);

            return new TwiMLResult(response);
        }
開發者ID:TwilioDevEd,項目名稱:ivr-phone-tree-csharp,代碼行數:7,代碼來源:PhoneExchangeController.cs

示例8: BroadcastReplyMenuSelection

        public TwilioResponse BroadcastReplyMenuSelection(VoiceRequest request, int profileId, int lastBroadcastIdx, int subBroadcastIdx)
        {
            var response = new TwilioResponse();

              var selection = request.Digits;

              switch (selection)
              {
            case "1":
              response.Redirect(ivrRouteProvider.GetUrlMethod(IVRRoutes.BROADCASTS_REPLY_PRIVATELY, profileId, lastBroadcastIdx, subBroadcastIdx));
              return response;
            case "2":
              response.Redirect(ivrRouteProvider.GetUrlMethod(IVRRoutes.BROADCASTS_REPLY_PUBLICLY, profileId, lastBroadcastIdx, subBroadcastIdx));
              return response;
            case "3":
              response.Redirect(ivrRouteProvider.GetUrlMethod(IVRRoutes.BROADCASTS_PLAY_PUBLIC_REPLY, profileId, lastBroadcastIdx, ++subBroadcastIdx));
              return response;
            case "4":
              response.Redirect(ivrRouteProvider.GetUrlMethod(IVRRoutes.BROADCASTS_LISTEN_TO_ALL_PUBLIC, profileId, ++lastBroadcastIdx));
              return response;
            case "5":
              response.Redirect(ivrRouteProvider.GetUrlMethod(IVRRoutes.BROADCASTS_ADD_REPLIER_AS_FAVOURITE, profileId, lastBroadcastIdx, subBroadcastIdx));
              return response;
            default:
              response.Redirect(ivrRouteProvider.GetUrlMethod(IVRRoutes.PLAY_MAIN_MENU));
              return response;
              }
        }
開發者ID:kzhen,項目名稱:RefUnited-IVR-Platform,代碼行數:28,代碼來源:IVRBroadcastLogic.cs

示例9: Connect

        public ActionResult Connect()
        {
            var response = new TwilioResponse();
            response.Say("Connecting you to an agent");

            return TwiML(response);
        }
開發者ID:devinrader,項目名稱:Queue-Demo,代碼行數:7,代碼來源:CallController.cs

示例10: Post

        //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());
              }
        }
開發者ID:kzhen,項目名稱:TwilioMonitoring,代碼行數:54,代碼來源:VoiceAppController.cs

示例11: Hello

 public ActionResult Hello()
 {
     var response = new TwilioResponse();
     response.Say("Hello there! Your Twilio environment has been configured.");
     response.Say("Good luck during the workshop!", new { Voice = "woman" });
     return TwiML(response);
 }
開發者ID:kwhinnery,項目名稱:jumpstart,代碼行數:7,代碼來源:HomeController.cs

示例12: TwilioResponseResult

 public TwilioResponseResult(Action<TwilioResponse> buildResponse)
 {
     var response = new TwilioResponse();
     buildResponse(response);
     Content = response.Element.ToString();
     ContentType = new MediaTypeHeaderValue("text/xml");
 }
開發者ID:OlsonAndrewD,項目名稱:the-phone-bible,代碼行數:7,代碼來源:TwilioResponseResult.cs

示例13: Index

 public ActionResult Index(VoiceRequest request)
 {
     var response = new TwilioResponse();
     response.Say("Hello! You will get an SMS message soon.");
     response.Sms("This is the ship that made the Kessel Run in fourteen parsecs?");
     return TwiML(response);
 }
開發者ID:TwilioDevEd,項目名稱:api-snippets,代碼行數:7,代碼來源:example-1.4.x.cs

示例14: Can_Generate_Enqueue_With_Options_And_TaskAttributes_And_Priority_And_Timeout

        public void Can_Generate_Enqueue_With_Options_And_TaskAttributes_And_Priority_And_Timeout()
        {
            var response = new TwilioResponse();
            response.Enqueue(new { action = "example.xml", method = "GET", waitUrl = "wait.xml", waitUrlMethod = "GET", workflowSid = "WFXXXXX" }, "{'task':'attributes'}", new {priority="10", timeout="30"});

            Assert.IsTrue(IsValidTwiML(response.ToXDocument()));
        }
開發者ID:nkerkin,項目名稱:twilio-csharp,代碼行數:7,代碼來源:EnqueueTests.cs

示例15: Dial

        /// <summary>
        /// Action Method that returns the TwiML needed to connect an 'Agent' to the first call in the Queue
        /// </summary>
        /// <remarks>This method also includes the 'url' parameter in the generated TwiML.  This allows you to provide a URL that can return TwiML that will be executed to the dequeued caller as a Whisper</remarks>
        /// <returns></returns>
        public ActionResult Dial()
        {
            var response = new TwilioResponse();
            response.DialQueue("Demo Queue", new { url = Url.Action("Connect") }, new { });

            return TwiML(response);
        }
開發者ID:devinrader,項目名稱:Queue-Demo,代碼行數:12,代碼來源:CallController.cs


注:本文中的Twilio.TwiML.TwilioResponse類示例由純淨天空整理自Github/MSDocs等開源代碼及文檔管理平台,相關代碼片段篩選自各路編程大神貢獻的開源項目,源碼版權歸原作者所有,傳播和使用請參考對應項目的License;未經允許,請勿轉載。