Пример #1
0
        public void GetDigitsPromptsTest()
        {
            GetDigits getDigits = new GetDigits("http://foo.com");

            Say say = new Say();

            say.setLanguage(ELanguage.EnglishUS);
            say.setText("hello");

            getDigits.setPrompts(say);

            Pause pause = new Pause(1000);

            getDigits.setPrompts(pause);

            say = new Say();
            say.setLanguage(ELanguage.EnglishUS);
            say.setText("goodbye");

            getDigits.setPrompts(say);

            string json = getDigits.toJson();

            Assert.IsNotNull(json);
            Assert.AreEqual(json, "{\"GetDigits\":{\"actionUrl\":\"http://foo.com\",\"prompts\":[{\"Say\":{\"text\":\"hello\",\"language\":\"en-US\"}},{\"Pause\":{\"length\":1000}},{\"Say\":{\"text\":\"goodbye\",\"language\":\"en-US\"}}]}}");
        }
        public ActionResult CallDequeueSelect(GetDigitsActionCallback getDigitsStatusCallback)
        {
            // Create an empty PerCL script container
            PerCLScript script = new PerCLScript();

            if ((getDigitsStatusCallback.getDigits != null) &&
                (getDigitsStatusCallback.getDigits.Length > 0))
            {
                // Create PerCL dequeue script and add to PerCL container
                script.Add(new Dequeue());
            }
            else
            {
                // Create PerCL getdigits script
                GetDigits digits = new GetDigits(getAppUrl() + "/voice/CallDequeueSelect");

                // Create PerCL say script with US English as the language
                Say say = new Say();
                say.setLanguage(ELanguage.EnglishUS);
                // Add prompt to for queue exit
                say.setText("Press any key to exit queue.");

                // Add say script as a prompt to getdigits
                digits.setPrompts(say);

                // Add PerCL getdigits script to PerCL container
                script.Add(digits);
            }
            // Convert PerCL container to JSON and append to response
            return(Content(script.toJson(), "application/json"));
        }
Пример #3
0
        [HttpPost("InboundCall")] //POST /voice/InboundCall
        public ActionResult InboundCall(CallStatusCallback callStatus)
        {
            PerCLScript script             = new PerCLScript();
            var         getDigitsActionUrl = getAppUrl() + "/voice/GetDigitsDone";
            GetDigits   getDigits          = new GetDigits(getDigitsActionUrl);

            getDigits.setMaxDigits(1);
            Say say = new Say();

            say.setText("Hello. Welcome to the conferences tutorial, please enter your access code.");
            getDigits.setPrompts(say);
            script.Add(getDigits);
            return(Content(script.toJson(), "application/json"));
        }
        [HttpPost("InboundCall")] // POST voice/InboundCall
        public ActionResult InboundCall(CallStatusCallback freeClimbRequest)
        {
            // Create an empty PerCL script container
            PerCLScript script = new PerCLScript();

            // Verify inbund call is in proper state
            if (freeClimbRequest.getCallStatus == ECallStatus.Ringing)
            {
                // Create PerCL say script with US English as the language
                Say say = new Say();
                say.setLanguage(ELanguage.EnglishUS);
                // Set greeting prompt
                say.setText("Hello");

                // Add PerCL say script to PerCL container
                script.Add(say);

                // Create PerCL pause script with a 100 millisecond pause
                Pause pause = new Pause(100);

                // Add PerCL pause script to PerCL container
                script.Add(pause);

                // Create PerCL getdigits script
                string getDigitsUrl = AppUrl + "/voice/ColorSelectionDone";

                GetDigits getDigits = new GetDigits(getDigitsUrl);
                // Set the max and min number of expected digits to 1
                getDigits.setMaxDigits(1);
                getDigits.setMinDigits(1);
                // Set the DTMF buffer flush to false
                getDigits.setFlushBuffer(EBool.False);

                // Create PerCL say script with US English as the language
                say = new Say();
                say.setLanguage(ELanguage.EnglishUS);
                // Set color selection menu prompt
                say.setText("Please select a color. Enter one for green, two for red or three for yellow.");

                // Add main selection menu prompt to the getdigits script
                getDigits.setPrompts(say);

                // Add PerCL getdigits script to PerCL container
                script.Add(getDigits);
            }

            // Convert PerCL container to JSON and append to response
            return(Content(script.toJson(), "application/json"));
        }
        public ActionResult InboundCallWait(QueueWaitCallback queueWaitStatusCallback)
        {
            // Create an empty PerCL script container
            PerCLScript script = new PerCLScript();
            // Create PerCL getdigits script
            string    getDigitsUrl = Url.Action(getAppUrl() + "/voice/CallDequeueSelect");
            GetDigits digits       = new GetDigits(getDigitsUrl); // actionUrl

            // Create PerCL say script with US English as the language
            Say say = new Say();

            say.setLanguage(ELanguage.EnglishUS);
            // Add prompt to for queue exit
            say.setText("Press any key to exit queue.");

            // Add say script as a prompt to getdigits
            digits.setPrompts(say);

            // Add PerCL getdigits script to PerCL container
            script.Add(digits);

            // Convert PerCL container to JSON and append to response
            return(Content(script.toJson(), "application/json"));
        }