Skip to content

Instantly share code, notes, and snippets.

Embed
What would you like to do?
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