public ActionResult OutboundCallConnected([FromQuery(Name = "conferenceId")] string conferenceId, CallStatusCallback request)
        {
            PerCLScript script = new PerCLScript();

            if (request.getDialCallStatus != com.freeclimb.ECallStatus.InProgress)
            {
                terminateConference(conferenceId);
                return(Content(script.toJson(), "application/json"));
            }
            // note context of this callback is the new call (agent). Add them to conference
            script.Add(new AddToConference(conferenceId, request.getCallId));
            return(Content(script.toJson(), "application/json"));
        }
示例#2
0
        public ActionResult PlayRecordingCallStatus(CallStatusCallback callStatusCallback)
        {
            // Create an empty PerCL script container
            PerCLScript script = new PerCLScript();

            return(Content(script.toJson(), "application/json"));
        }
        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"));
        }
示例#4
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"));
        }
示例#5
0
        public ActionResult Post(CallStatusCallback callStatusCallback)
        {
            PerCLScript script = new PerCLScript();

            // Verify call is in the InProgress state
            if (callStatusCallback.getDialCallStatus == ECallStatus.InProgress)
            {
                // Create PerCL say script with US English as the language
                Say say = new Say();
                say.setLanguage(ELanguage.EnglishUS);
                // Set prompt to record message
                say.setText("Hello. Please leave a message after the beep, then press one or hangup");
                // Add PerCL say script to PerCL container
                script.Add(say);
                // Create PerCL record utterance script
                string          messageDoneUrl  = AppUrl + "/voice/MakeRecordMessageDone";
                RecordUtterance recordUtterance = new RecordUtterance(messageDoneUrl);
                // Set indication that audible 'beep' should be used to signal start of recording
                recordUtterance.setPlayBeep(EBool.True);
                // Set indication that end of recording is touch tone key 0ne
                recordUtterance.setFinishOnKey(EFinishOnKey.One);

                // Add PerCL record utterance script to PerCL container
                script.Add(recordUtterance);
            }
            // Convert PerCL container to JSON and append to response
            return(Content(script.toJson(), "application/json"));
        }
示例#6
0
        [HttpPost] // POST /voice
        public ActionResult SelectColorCallAnswered(CallStatusCallback callStatusCallback)
        {
            // Create an empty PerCL script container
            PerCLScript script = new PerCLScript();

            // Verify call is in the InProgress state
            if (callStatusCallback.getDialCallStatus == ECallStatus.InProgress)
            {
                // Create PerCL get speech script (see grammar file content below)
                string    actionUrl   = AppUrl + "/voice/SelectColorDone";
                string    grammarFile = AppUrl + "/grammars/FreeClimbColor.xml";
                GetSpeech getSpeech   = new GetSpeech(actionUrl, grammarFile);
                // Set location and type of grammar as well as the grammar rule
                getSpeech.setGrammarType(EGrammarType.Url);
                getSpeech.setGrammarRule("FreeClimbColor");

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

                // Add PerCL say script to PerCL get speech prompt list
                getSpeech.setPrompts(say);

                // Add PerCL get speech script to PerCL container
                script.Add(getSpeech);
            }

            // Convert PerCL container to JSON and append to response
            return(Content(script.toJson(), "application/json"));
        }
示例#7
0
        public ActionResult ConferenceStatus([FromQuery(Name = "roomCode")] string roomCode, ConferenceStatusCallback request)
        {
            PerCLScript       script       = new PerCLScript();
            EConferenceStatus status       = request.getStatus;
            String            conferenceId = request.getConferenceId;
            // find which conference room the conference belongs to
            ConferenceRoom room = conferenceRooms[roomCode];

            if (room == null)
            {
                // Handle case where callback is called for a room that does not exist
            }
            if (status == EConferenceStatus.Empty && room.canConferenceTerminate)
            {
                try {
                    terminateConference(conferenceId);
                    room.conferenceId = null;
                } catch (FreeClimbException pe) {
                    // Handle error when terminateConference fails
                }
            }
            // after first EMPTY status update conference can be terminated
            room.canConferenceTerminate = true;
            return(Content(script.toJson(), "application/json"));
        }
示例#8
0
        public ActionResult MakeRecordMessageDone(RecordingUtteranceActionCallback recordingUtteranceStatusCallback)
        {
            // Create an empty PerCL script container
            PerCLScript script = new PerCLScript();

            if (Request != null)
            {
                // Check if recording was successful by checking if a recording identifier was provided
                if (recordingUtteranceStatusCallback.getRecordingId != null)
                {
                    // Recording was successful as recording identifier present in response

                    // Create PerCL say script with US English as the language
                    Say say = new Say();
                    say.setLanguage(ELanguage.EnglishUS);
                    // Set prompt to indicate message has been recorded
                    say.setText("Thanks. The message has been recorded.");

                    // Add PerCL say script to PerCL container
                    script.Add(say);
                }
                else
                {
                    // Recording was failed as there is no recording identifier present in response

                    // Create PerCL say script with US English as the language
                    Say say = new Say();
                    say.setLanguage(ELanguage.EnglishUS);
                    // Set prompt to indicate message recording failed
                    say.setText("Sorry we weren't able to record the message.");

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

                // Create PerCL pause script with a duration of 100 milliseconds
                Pause pause = new Pause(100);

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

                // Create PerCL say script with US English as the language
                Say sayGoodbye = new Say();
                sayGoodbye.setLanguage(ELanguage.EnglishUS);
                // Set prompt sayGoodbye.setText("Goodbye");

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

                // Create PerCL hangup script
                Hangup hangup = new Hangup();

                // Add PerCL hangup script to PerCL container
                script.Add(new Hangup());
            }

            // Convert PerCL container to JSON and append to response
            return(Content(script.toJson(), "application/json"));
        }
        public ActionResult LeftConference(LeaveConferenceUrlCallback request)
        {
            PerCLScript script = new PerCLScript();

            // just terminate conference sonce one party left
            terminateConference(request.getConferenceId);
            return(Content(script.toJson(), "application/json"));
        }
        public ActionResult InboundCall(CallStatusCallback callStatus)
        {
            PerCLScript      script = new PerCLScript();
            var              conferenceActionUrl = AppUrl + "/voice/ConferenceCreated";
            CreateConference cc = new CreateConference(conferenceActionUrl);

            script.Add(cc);
            return(Content(script.toJson(), "application/json"));
        }
        public ActionResult OutboundCallMade([FromQuery(Name = "conferenceId")] string conferenceId, OutDialActionCallback request)
        {
            PerCLScript script = new PerCLScript();
            // note the context of the request is the original call, not the newly created via OutDial
            AddToConference addToConference    = new AddToConference(conferenceId, request.getCallId);
            var             leaveConferenceUrl = AppUrl + "/voice/LeftConference";

            // set the leaveConferenceUrl for the inbound caller, so that we can terminate the conference when they hang up
            addToConference.setLeaveConferenceUrl(leaveConferenceUrl);
            script.Add(addToConference);
            return(Content(script.toJson(), "application/json"));
        }
示例#12
0
        public ActionResult SelectColorDone(GetSpeechActionCallback getSpeechStatusCallback)
        {
            // Create an empty PerCL script container
            PerCLScript script = new PerCLScript();

            // Check if recognition was successful
            if (getSpeechStatusCallback.getReason == ESpeechTermReason.Recognition)
            {
                // Create PerCL say script with US English as the language
                Say say = new Say();
                say.setLanguage(ELanguage.EnglishUS);
                // Set prompt to speak the selected color
                say.setText(string.Format("Selected color was {0}", (getSpeechStatusCallback.getRecognitionResult).ToLower()));

                // Add PerCL say script to PerCL container
                script.Add(say);
            }
            else
            {
                // Create PerCL say script with US English as the language
                Say say = new Say();
                say.setLanguage(ELanguage.EnglishUS);
                // Set prompt to indicated selection error
                say.setText("There was an error in selecting a color.");

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

            // Create PerCL pause script with a duration of 100 milliseconds
            Pause pause = new Pause(100);

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

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

            sayGoodbye.setLanguage(ELanguage.EnglishUS);
            // Set prompt
            sayGoodbye.setText("Goodbye");
            // Add PerCL say script to PerCL container
            script.Add(sayGoodbye);

            // Create PerCL hangup script
            Hangup hangup = new Hangup();

            // Add PerCL hangup script to PerCL container
            script.Add(new Hangup());

            // Convert PerCL container to JSON and append to response
            return(Content(script.toJson(), "application/json"));
        }
示例#13
0
        public void MakeAddACommandToTheScriptAndConvertToJsonTest()
        {
            PerCLScript script = new PerCLScript();

            script.Add(new TestCommand("COMMAND::SIMPLE::COMMAND"));
            script.Add(new TestCommand("COMMAND::SIMPLE::COMMAND"));
            script.Add(new TestCommand("COMMAND::SIMPLE::COMMAND"));
            script.Add(new TestCommand("COMMAND::SIMPLE::COMMAND"));

            string json = script.toJson();

            Assert.AreEqual(json, "[{\"TestCommand\":{\"testField\":\"COMMAND::SIMPLE::COMMAND\"}},{\"TestCommand\":{\"testField\":\"COMMAND::SIMPLE::COMMAND\"}},{\"TestCommand\":{\"testField\":\"COMMAND::SIMPLE::COMMAND\"}},{\"TestCommand\":{\"testField\":\"COMMAND::SIMPLE::COMMAND\"}}]");
        }
示例#14
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 string Post(CallStatusCallback request)
        {
            // Create a PerCl script
            PerCLScript helloScript = new PerCLScript();

            // Create a Say Command
            Say sayHello = new Say();

            sayHello.setText("Hello, FreeClimb!");

            // Add the command
            helloScript.Add(sayHello);

            // Respond to FreeClimb with your script
            return(helloScript.toJson());
        }
示例#17
0
        public ActionResult PlayRecordingCallAnswered(CallStatusCallback callStatusCallback)
        {
            // Create an empty PerCL script container
            PerCLScript script = new PerCLScript();

            // Verify call is in the InProgress state
            if (callStatusCallback.getDialCallStatus == ECallStatus.InProgress)
            {
                // Create PerCL play script with US English as the language
                Play play = new Play(GetRecordingUrl());

                // Add PerCL play script to PerCL container
                script.Add(play);
            }

            // Convert PerCL container to JSON and append to response
            return(Content(script.toJson(), "application/json"));
        }
示例#18
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"));
        }
        public ActionResult InboundCall(CallStatusCallback freeClimbRequest)
        {
            // Create an empty PerCL script container
            PerCLScript script = new PerCLScript();

            // Verify inbound 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. Your call will be queued.");

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

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

                // Create queue options with an alias
                QueueOptions options = new QueueOptions();
                options.setAlias("InboundCallQueue");

                // Create FreeClimbClient object
                FreeClimbClient client = new FreeClimbClient(getFreeClimbAccountId(), getFreeClimbApiKeys());

                // Create a queue with an alias
                Queue queue = client.getQueuesRequester.create(options);

                // Create PerCL say to enqueue the call into the newly created queue with an actionUrl
                Enqueue enqueue = new Enqueue(queue.getQueueId, getAppUrl() + "/voice/InboundCallAction");
                // Add waitUrl
                enqueue.setWaitUrl(getAppUrl() + "/voice/InboundCallWait");

                // Add PerCL enqueue script to PerCL container
                script.Add(enqueue);
            }

            // Convert PerCL container to JSON and append to response
            return(Content(script.toJson(), "application/json"));
        }
        public ActionResult InboundCall(CallStatusCallback freeClimbRequest)
        {
            // Create an empty PerCL script container
            PerCLScript script = new PerCLScript();

            // Verify inbound 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 prompt to record message
                say.setText("Hello. Thank you for invoking the accept incoming call tutorial.");

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

                // Create PerCL pause script with a duration of 100 milliseconds
                Pause pause = new Pause(100);

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

                // Create PerCL say script with US English as the language
                Say sayGoodbye = new Say();
                sayGoodbye.setLanguage(ELanguage.EnglishUS);
                // Set prompt
                sayGoodbye.setText("Goodbye.");

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

                // Create PerCL hangup script
                Hangup hangup = new Hangup();

                // Add PerCL hangup script to PerCL container
                script.Add(new Hangup());
            }
            // Convert PerCL container to JSON and append to response
            return(Content(script.toJson(), "application/json"));
        }
        public ActionResult InboundCallAction(QueueActionCallback queueActionStatusCallback)
        {
            // Create an empty PerCL script container
            PerCLScript script = new PerCLScript();

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

            say.setLanguage(ELanguage.EnglishUS);
            // Add prompt for queue exit
            say.setText("Call exited queue.");

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

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

            // Convert PerCL container to JSON and append to response
            return(Content(script.toJson(), "application/json"));
        }
        public ActionResult ConferenceCreated(ConferenceStatusCallback request)
        {
            // Make OutDial request once conference has been created
            PerCLScript script = new PerCLScript();
            Say         say    = new Say();

            say.setText("Please wait while we attempt to connect you to an agent.");
            script.Add(say);
            string confId = request.getConferenceId;
            // implementation of lookupAgentPhoneNumber() is left up to the developer
            string agentPhoneNumber = lookupAgentPhoneNumber();
            // Make OutDial request once conference has been created
            var     outdialActionUrl    = AppUrl + $"/voice/OutboundCallMade?conferenceId={confId}";
            var     outdialConnectedUrl = AppUrl + $"/voice/OutboundCallConnected?conferenceId={confId}";
            OutDial outDial             = new OutDial(agentPhoneNumber, outdialConnectedUrl);

            outDial.setCallingNumber(request.getFrom);
            outDial.setActionUrl(outdialActionUrl);
            outDial.setIfMachine(com.freeclimb.EIfMachine.Hangup);
            script.Add(outDial);
            return(Content(script.toJson(), "application/json"));
        }
示例#23
0
        [HttpPost("ConferenceCreated")] // POST /voice/ConferenceCreated
        public ActionResult ConferenceCreated([FromQuery(Name = "roomCode")] string roomCode, ConferenceCreateActionCallback request)
        {
            PerCLScript script       = new PerCLScript();
            string      conferenceId = request.getConferenceId;
            string      callId       = request.getCallId;
            // find which conference room the newly created conference belongs to
            ConferenceRoom room = conferenceRooms[roomCode];

            if (room == null)
            {
                // Handle case where callback is called for a room that does not exist
            }
            room.conferenceId        = conferenceId;
            room.isConferencePending = false;

            Say welcomeToConference = new Say();

            welcomeToConference.setText("You are now being added to the conference");
            script.Add(welcomeToConference);
            // Add initial caller to conference
            script.Add(new AddToConference(conferenceId, request.getCallId));
            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"));
        }
        [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"));
        }