public void CreateAndVerifyGetDigitsActionCallbackTest()
        {
            GetDigitsActionCallback getDigitsStatusCallback = GetDigitsActionCallback.fromJson("{\"accountId\":\"ACabe7063197551fe51671f9ac3a9708e9dad51c4d\",\"callId\":\"CAfd4a3989da31cc8a640524f8e0d44bfb0fba9761\",\"callStatus\":\"inProgress\",\"conferenceId\":null,\"digits\":\"1234567890\",\"direction\":\"inbound\",\"from\":\"1000000060\",\"parentCallId\":null,\"queueId\":null,\"reason\":\"finishKey\",\"requestId\":\"RQd0db15f753ab816348d55ed501a443d66e2018bb\",\"requestType\":\"getDigits\",\"to\":\"+11112223333\"}");

            Assert.AreEqual(getDigitsStatusCallback.getDigits, "1234567890");
            Assert.AreEqual(getDigitsStatusCallback.getReason, EDigitTermReason.FinishKey);
        }
        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"));
        }
Beispiel #3
0
        [HttpPost("GetDigitsDone")] // POST /voice/GetDigitsDone
        public ActionResult GetDigitsDone(GetDigitsActionCallback request)
        {
            // Make OutDial request once conference has been created
            PerCLScript    script = new PerCLScript();
            string         callId = request.getCallId;
            string         digits = request.getDigits;
            ConferenceRoom room   = conferenceRooms[digits];

            if (room == null)
            {
                // Handle case where no room with the given code exists
            }

            // if participants can't be added yet (actionUrl callback has not been called) notify caller and hang up
            if (room.isConferencePending)
            {
                Say say = new Say();
                say.setText("We are sorry, you cannot be added to the conference at this time. Please try again later.");
                script.Add(say);
                script.Add(new Hangup());
            }
            else
            {
                Say say = new Say();
                say.setText("You will be added to the conference momentarily.");
                script.Add(say);
                script.Add(makeOrAddToConference(room, digits, callId));
            }
            return(Content(script.toJson(), "application/json"));
        }
Beispiel #4
0
        [HttpPost("GetDigits")] // /voice/GetDigits
        public ActionResult GetDigits(GetDigitsActionCallback getDigitsStatusCallback)
        {
            // Create an empty PerCL script container
            PerCLScript script = new PerCLScript();

            // Verify the getdigits contains a single digit response
            if ((getDigitsStatusCallback.getDigits != null) && (getDigitsStatusCallback.getDigits.Length == 10))
            {
                // create properly formatted phone num
                string phoneNum = "+1" + getDigitsStatusCallback.getDigits;
                // create and add PerCL sms script to PerCL container
                Sms sms = new Sms(FromPhoneNumber, phoneNum, "Hello from FreeClimb SMS");
                // add a notification URL so we can track status of the message
                sms.setNotificationUrl(AppUrl + "MessageStatusCallback");
                script.Add(sms);
                // Create PerCL say script with US English as the language
                Say say = new Say();
                say.setLanguage(ELanguage.EnglishUS);
                // Set color selected prompt
                say.setText("We'll send the text message now. Goodbye.");
                // Add PerCL say script to PerCL container
                script.Add(say);

                // Create PerCL hangup script and add to the container
                script.Add(new Hangup());
            }
            // unexpected getdigit response
            else
            {
                // Create PerCL say script with US English as the language
                Say say = new Say();
                say.setLanguage(ELanguage.EnglishUS);
                // Set error selection prompt
                say.setText("There was an error retrieving your selection. Goodbye.");
                // Add PerCL say script to PerCL container
                script.Add(say);
                // Create PerCL hangup script and add to the container
                script.Add(new Hangup());
            }
            // Convert PerCL container to JSON and append to response
            return(Content(script.toJson(), "application/json"));
        }
        [HttpPost("ColorSelectionDone")] // POST voice/ColorSelectionDone
        public ActionResult ColorSelectionDone(GetDigitsActionCallback getDigitsStatusCallback)
        {
            // Create an empty PerCL script container
            PerCLScript script = new PerCLScript();

            // Verify the getdigits contains a single digit response
            if ((getDigitsStatusCallback.getDigits != null) && (getDigitsStatusCallback.getDigits.Length == 1))
            {
                // Verify digit one selected
                if (string.Equals(getDigitsStatusCallback.getDigits, "1") == true)
                {
                    // Create PerCL say script with US English as the language
                    Say say = new Say();
                    say.setLanguage(ELanguage.EnglishUS);
                    // Set color selected prompt
                    say.setText("You selected green. Goodbye.");

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

                    // Create PerCL hangup script and add to the container
                    script.Add(new Hangup());
                }
                // Verify digit two selected
                else if (string.Equals(getDigitsStatusCallback.getDigits, "2") == true)
                {
                    // Create PerCL say script with US English as the language
                    Say say = new Say();
                    say.setLanguage(ELanguage.EnglishUS);
                    // Set color selected prompt
                    say.setText("You selected red. Goodbye.");

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

                    // Create PerCL hangup script and add to the container
                    script.Add(new Hangup());
                }
                // Verify digit three selected
                else if (string.Equals(getDigitsStatusCallback.getDigits, "3") == true)
                {
                    // Create PerCL say script with US English as the language
                    Say say = new Say();
                    say.setLanguage(ELanguage.EnglishUS);
                    // Set color selected prompt
                    say.setText("You selected yellow. Goodbye.");

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

                    // Create PerCL hangup script and add to the container
                    script.Add(new Hangup());
                }
                // Invalid selection
                else
                {
                    // Create PerCL say script with US English as the language
                    Say say = new Say();
                    say.setLanguage(ELanguage.EnglishUS);
                    // Set invalid selection prompt
                    say.setText("Invalid selection. Goodbye.");

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

                    // Create PerCL hangup script and add to the container
                    script.Add(new Hangup());
                }
            }
            // unexpected getdigit response
            else
            {
                // Create PerCL say script with US English as the language
                Say say = new Say();
                say.setLanguage(ELanguage.EnglishUS);
                // Set error selection prompt
                say.setText("There was an error retrieving your selection. Goodbye.");

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

                // Create PerCL hangup script and add to the container
                script.Add(new Hangup());
            }

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