Ejemplo n.º 1
0
        protected override void Execute(NativeActivityContext context)
        {
            var twilio      = context.GetExtension <ITwilioContext>();
            var timeout     = Timeout.Get(context);
            var finishOnKey = FinishOnKey.Get(context);
            var numDigits   = NumDigits.Get(context);

            var finishUrl = twilio.ResolveBookmarkUrl(context.CreateTwilioBookmark(OnFinish));

            // append gather element
            var element = new XElement("Gather",
                                       new XAttribute("action", finishUrl),
                                       timeout != null ? new XAttribute("timeout", ((TimeSpan)timeout).TotalSeconds) : null,
                                       finishOnKey != null ? new XAttribute("finishOnKey", finishOnKey) : null,
                                       numDigits != null ? new XAttribute("numDigits", numDigits) : null);

            // write gather element
            GetElement(context).Add(
                element,
                new XElement("Redirect", finishUrl));

            if (Body != null)
            {
                SetElement(context, element);
                context.ScheduleActivity(Body);
            }
        }
Ejemplo n.º 2
0
        protected override void Execute(NativeActivityContext context)
        {
            var twilio      = context.GetExtension <ITwilioContext>();
            var timeout     = Timeout.Get(context);
            var finishOnKey = FinishOnKey.Get(context);
            var maxLength   = MaxLength.Get(context);
            var transcribe  = Transcribe.Get(context);
            var playBeep    = PlayBeep.Get(context);

            var actionUrl = twilio.ResolveBookmarkUrl(context.CreateTwilioBookmark(OnAction));

            // append record element
            var element = new XElement("Record",
                                       new XAttribute("action", actionUrl),
                                       timeout != null ? new XAttribute("timeout", ((TimeSpan)timeout).TotalSeconds) : null,
                                       finishOnKey != null ? new XAttribute("finishOnKey", finishOnKey) : null,
                                       maxLength != null ? new XAttribute("maxLength", ((TimeSpan)maxLength).TotalSeconds) : null,
                                       transcribe != null ? new XAttribute("transcribe", (bool)transcribe ? "true" : "false") : null,
                                       playBeep != null ? new XAttribute("playBeep", (bool)playBeep ? "true" : "false") : null);

            // write dial element and catch redirect
            GetElement(context).Add(
                element,
                new XElement("Redirect", actionUrl));
        }