Skip to content

Commit

Permalink
added voice recording to demo
Browse files Browse the repository at this point in the history
  • Loading branch information
Matthias Damm committed Jun 15, 2020
1 parent 38b4721 commit 6eaecb0
Show file tree
Hide file tree
Showing 5 changed files with 60 additions and 18 deletions.
5 changes: 4 additions & 1 deletion configuration.json
Original file line number Diff line number Diff line change
Expand Up @@ -55,6 +55,9 @@
"callerId": null,
"applicationSid": null,
"workflowSid": null,
"facebookPageId": null
"facebookPageId": null,
"voice": {
"recording": false
}
}
}
2 changes: 1 addition & 1 deletion public/callcenter/WorkflowReservationController.js
Original file line number Diff line number Diff line change
Expand Up @@ -85,7 +85,7 @@ function WorkflowReservationController ($scope, $rootScope, $timeout, $interval,
return;
}

}, { 'EndConferenceOnExit': true, 'EndConferenceOnCustomerExit': true });
}, { 'EndConferenceOnExit': true, 'EndConferenceOnCustomerExit': true, 'ConferenceRecord':$scope.configuration.twilio.voice.recording });

}

Expand Down
18 changes: 18 additions & 0 deletions public/scripts/directives/ConvertToBooleanDirective.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
angular.module('convert-to-boolean', [])
.directive('convertToBoolean', ['$parse', '$compile', function($parse, $compile) {

return {
require: 'ngModel',
link: function(scope, element, attrs, ngModel) {

ngModel.$parsers.push(function(value) {
return (value === "true" ? true : false);
});

ngModel.$formatters.push(function(value) {
return value ? '' + value : null;
});
}
};

}])
18 changes: 11 additions & 7 deletions public/setup/SetupController.js
Original file line number Diff line number Diff line change
@@ -1,14 +1,13 @@
var app = angular.module('setupApplication', ['ngMessages', 'phone-number']);
var app = angular.module('setupApplication', ['ngMessages', 'phone-number', 'convert-to-boolean']);

app.controller('SetupController', function ($scope, $http, $timeout, $q) {
$scope.phoneNumber = { isValid: true, message: null, code: null};
$scope.configuration = null;
$scope.workspace = null;
$scope.activities = [];
$scope.error = null;

/* UI */
$scope.UI = { warning: null, isSaving: false };
$scope.UI = { warning: null, isSaving: false, error: null, isSaved: false };

$scope.init = function () {

Expand Down Expand Up @@ -62,6 +61,8 @@ app.controller('SetupController', function ($scope, $http, $timeout, $q) {
$scope.saveConfig = function () {
$scope.phoneNumber.isValid = true;
$scope.UI.isSaving = true;
$scope.UI.isSaved = false;
$scope.UI.warning = null;

var verifyPhoneNumber = function () {
var deferred = $q.defer();
Expand Down Expand Up @@ -104,14 +105,17 @@ app.controller('SetupController', function ($scope, $http, $timeout, $q) {
verifyPhoneNumber().then(function (phoneNumber) {

return setupPhonenumber(phoneNumber.sid).then(function () {
return saveConfiguration(phoneNumber.sid, $scope.configuration);
}).then(function () {
$scope.UI.isSaving = false;
$scope.UI.isSaved = true;

return saveConfiguration(phoneNumber.sid, $scope.configuration).then(function () {
$scope.UI.isSaving = false;
$scope.phoneNumber = { isValid: true, message: null, code: null};
$timeout(function () {
$scope.$apply();
});

}).catch(function (error) {
$scope.error = error.data;
$scope.UI.warning = error.data;
$scope.UI.isSaving = false;
console.log(error);

Expand Down
35 changes: 26 additions & 9 deletions public/setup/index.html
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,11 @@

<body ng-app="setupApplication" ng-controller="SetupController" data-ng-init="init()" >

<div ng-show="UI.warning" class="panel panel-default ui-warning" ng-cloak>{{UI.warning | json}}</div>
<div ng-show="UI.warning" class="panel panel-default ui-warning" ng-cloak>

<strong>Oh snap!</strong><br />

<span></span>{{UI.warning | json}}</div>

<section style="margin: auto; width:750px;">

Expand Down Expand Up @@ -58,17 +62,32 @@ <h6>Worker Unavailable Activity:</h6>

<h4>Phone Number:</h4>

<span class="help-block">This phone number will be configured as your voice inbound and outbound number by this setup script. If you provide a message-capable phone number the demo provides a bridge from SMS to Twiio IP Chat and vice versa.</span>
<span class="help-block">This phone number will be configured as your voice inbound and outbound number by this setup script. If you provide a message-capable phone number the demo provides a bridge from SMS to Twiio Chat and vice versa.</span>

<input style="width:350px" ng-model="configuration.twilio.callerId" data-ng-trim="false" name="callerId" type="text" class="form-control" placeholder="+..." required phone-number>

<br />

<h4>Record Phone Calls:</h4>

<div class="btn-group" uib-dropdown>

<select ng-model="configuration.twilio.voice.recording" class="form-control" required convert-to-boolean>
<option value="true">yes</option>
<option value="false">no</option>
</select>

</div>

<br /><br />

<h4>Facebook Page ID (optional):</h4>

<span class="help-block">Please enable Facebook Messaging in your Twilio account and forward messages to <span style="white-space: nowrap; font-weight:bold">http://&lt;your_application&gt;/api/messaging-adapter/inbound</span> (request method POST)</span>
<span class="help-block">Please enable Facebook Messaging in your Twilio account and forward messages to <span style="white-space: nowrap; font-weight:bold">http://&lt;your_application-url&gt;/api/messaging-adapter/inbound</span> (request method POST)</span>

<input style="width:350px" ng-model="configuration.twilio.facebookPageId" data-ng-trim="true" name="facebookPageId" type="text" class="form-control">
<input style="width:350px" ng-model="configuration.twilio.facebookPageId" data-ng-trim="true" name="facebookPageId" type="text" class="form-control">

<br />

<div ng-messages="setupForm.callerId.$error" role="alert" style="margin-top: 10px; margin-bottom: 0px;">
<div ng-message="required" class="error-message alert alert-danger">Phone number is required</div>
Expand All @@ -94,11 +113,8 @@ <h4>Facebook Page ID (optional):</h4>

</div>

<div style="margin-top:10px" ng-if="error != null" class="alert alert-dismissible alert-danger">
<strong>Oh snap!</strong><br />

<span>{{ error | json}}</span>

<div style="margin-top:10px" ng-if="UI.isSaved == true" class="alert alert-dismissible alert-success">
<strong>Configuration saved.</strong>
</div>

<br>
Expand All @@ -112,6 +128,7 @@ <h4>Facebook Page ID (optional):</h4>
<script src="/scripts/angular.min.js"></script>
<script src="/scripts/angular-messages.min.js"></script>
<script src="/scripts/directives/PhoneNumberDirective.js"></script>
<script src="/scripts/directives/ConvertToBooleanDirective.js"></script>

<script src="SetupController.js"></script>

Expand Down

0 comments on commit 6eaecb0

Please sign in to comment.