var plivo = require('../plivo-node/');
var express = require('express');
var bodyParser = require('body-parser');
var app = express();
app.set('port', (process.env.PORT || 5000));
app.use(express.static(__dirname + '/public'));
app.use(bodyParser.json()); // support json encoded bodies
app.use(bodyParser.urlencoded({ extended: true })); // support encoded bodies
var musicUrl = "https://s3.amazonaws.com/plivocloud/music.mp3"
var client = new plivo.Client("<auth_id>","<auth_token>");
// Add customer to the MPC
app.all('/add/customer/', function (request, response) {
...
...
});
//Add agent to the MPC to talk to the customer
app.all('/add/agent/', function (request, response) {
...
...
});
// Collect status callback events after agent joins the MPC
app.all('/agent/callback/', function (request, response) {
...
...
});
// Agent clicks "Add supervisor to the call" option to add him to the ongoing MPC
app.all('/add_supervisor/:mpcMPCUUID', function (request, response) {
...
...
});
// Supervisor clicks "Join the call" option to add him to the ongoing MPC
app.all('/coach_the_agent/', function (request, response) {
...
...
});
// Supervisor clicks "Join the call" option to be added to the ongoing MPC
app.all('/talk_to_customer/', function (request, response) {
var r = new plivo.Response();
var mpcName = 'test'; // MPC name of the call to which the supervisor wishes to join; you can get this from status_callback_url
var params = {
"role": "Supervisor",
"coach_mode": false, // The supervisor can talk to only the agent
"status_callback_url": "https://<ngrok_identifier>.ngrok.io/supervisor/callback/",
"status_callback_method": "POST",
"enter_sound": "none",
};
r.addMultiPartyCall(mpcName, params);
console.log(r.toXML());
response.set({ 'Content-Type': 'text/xml' });
response.end(r.toXML());
});
app.listen(app.get('port'), function () {
console.log('Node app is running on port', app.get('port'));
});