コード例 #1
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"));
        }
コード例 #2
0
        public void CreateAndVerifyRecordingUtteranceActionCallbackTest()
        {
            RecordingUtteranceActionCallback ru = RecordingUtteranceActionCallback.fromJson("{\"accountId\":\"AC736ca2078721a9a41fb47f07bf40d9e21cb304da\",\"callId\":\"CA7d00ca83adccbdf9d3f502176dbdd09fa5b886aa\",\"callStatus\":\"inProgress\",\"conferenceId\":null,\"direction\":\"outboundAPI\",\"from\":\"+12248806205\",\"parentCallId\":null,\"queueId\":null,\"recordingDurationSec\":4,\"recordingFormat\":\"audio/wav\",\"recordingId\":\"RE480dd877f1e9bb161fe4ce5f7af265433d8f5200\",\"recordingSize\":19884,\"recordingUrl\":\"/Accounts/AC736ca2078721a9a41fb47f07bf40d9e21cb304da/Recordings/RE480dd877f1e9bb161fe4ce5f7af265433d8f5200/Download\",\"requestId\":\"RQ36e2885c0baeb78da51f27269440e62862898f4c\",\"requestType\":\"record\",\"termReason\":\"finishKey\",\"to\":\"+18475978014\"}");

            Assert.AreEqual(ru.getAccountId, "AC736ca2078721a9a41fb47f07bf40d9e21cb304da");
            Assert.AreEqual(ru.getCallId, "CA7d00ca83adccbdf9d3f502176dbdd09fa5b886aa");
            Assert.AreEqual(ru.getCallStatus, ECallStatus.InProgress);
            Assert.AreEqual(ru.getRecordingDurationSec, 4);
            Assert.AreEqual(ru.getRecordingFormat, "audio/wav");
            Assert.AreEqual(ru.getRecordingId, "RE480dd877f1e9bb161fe4ce5f7af265433d8f5200");
            Assert.AreEqual(ru.getRecordingSize, 19884);
            Assert.AreEqual(ru.getRecordingUrl, "/Accounts/AC736ca2078721a9a41fb47f07bf40d9e21cb304da/Recordings/RE480dd877f1e9bb161fe4ce5f7af265433d8f5200/Download");
            Assert.AreEqual(ru.getTermReason, ERecordTermReason.FinishKey);
            Assert.IsNull(ru.getConferenceId);
            Assert.AreEqual(ru.getDirection, EDirection.OutboundAPI);
            Assert.AreEqual(ru.getFrom, "+12248806205");
            Assert.IsNull(ru.getParentCallId);
            Assert.IsNull(ru.getQueueId);
            Assert.AreEqual(ru.getRequestId, "RQ36e2885c0baeb78da51f27269440e62862898f4c");
            Assert.AreEqual(ru.getRequestType, ERequestType.Record);
            Assert.AreEqual(ru.getTo, "+18475978014");
        }