Skip to content

Instantly share code, notes, and snippets.

@rktalusani
Last active October 7, 2020 09:30
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save rktalusani/4d7cfbc3c95a6f45864e35e40ea41c38 to your computer and use it in GitHub Desktop.
Save rktalusani/4d7cfbc3c95a6f45864e35e40ea41c38 to your computer and use it in GitHub Desktop.
app.get("/answer", function (req, res) {
console.log("uuid is:"+req.query.uuid);
var ncco = [
{
action: "conversation",
name: "conf"+req.query.uuid ,
startOnEnter: true,
record: true
}
];
console.log("answer: connecting to conference:conf"+req.query.uuid);
res.status(200).json(ncco);
nexmo.calls.create({
to: [{
type: 'phone',
number: '6591xxx735'
}],
from: {
type: 'phone',
number: '653xxxx154'
},
answer_url: ['https://221d829d9.ngrok.io/agent_answer?caller_uuid=' + req.query.uuid],
event_url: ['https://221829d9.ngrok.io/agent_event']
}, (err, res) => {
if (err) {
console.error(">>> Agent call error:", err);
console.error(err.body.title);
console.error(err.body.invalid_parameters);
}
else {
console.log(">>> Agent call status:", res);
}
});
})
app.get("/agent_answer", function (req, res) {
console.log("#agent_answer: connecting to conference :conf"+req.query.caller_uuid+"#");
var ncco = [
{
action: "conversation",
name: "conf"+req.query.caller_uuid,
startOnEnter: false
}
];
res.status(200).json(ncco);
})
app.post("/agent_event", function (req, res) {
res.status(204).end();
})
app.post("/events", function (req, res) {
res.status(204).end();
})
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment