Merge branch 'main' of github.com:hainatravel/global-sales

hotfix/new-conversation
Jimmy Liow 1 year ago
commit aab88427e9

@ -18,17 +18,16 @@ const aclPaths = {
}, },
}; };
const app = express(); const app = express();
app.use(express.json()); app.use(express.json());
const vonageNumber = "12052553394"; //用于通话的号码,今后根据前端提交来做号码切换 const vonageNumber = "12052553394"; //用于通话的号码,今后根据前端提交来做号码切换
//设置跨域访问 //设置跨域访问
app.all('*', function(req, res, next) { app.all("*", function (req, res, next) {
res.header("Access-Control-Allow-Origin", "*"); res.header("Access-Control-Allow-Origin", "*");
res.header("Access-Control-Allow-Headers", "*"); res.header("Access-Control-Allow-Headers", "*");
res.header("Access-Control-Allow-Methods","PUT,POST,GET,DELETE,OPTIONS"); res.header("Access-Control-Allow-Methods", "PUT,POST,GET,DELETE,OPTIONS");
res.header("Content-Type", "application/json;charset=utf-8"); res.header("Content-Type", "application/json;charset=utf-8");
next(); next();
}); });
@ -42,6 +41,10 @@ app.get("/voice/answer", (req, res) => {
action: "talk", action: "talk",
text: "Please wait while we connect you.", text: "Please wait while we connect you.",
}, },
{
action: "record",
eventUrl: [`${req.protocol}://${req.get("host")}/vonage-server/voice/recordings`],
},
{ {
action: "connect", action: "connect",
from: vonageNumber, from: vonageNumber,
@ -53,12 +56,12 @@ app.get("/voice/answer", (req, res) => {
app.get("/jwt", (req, res) => { app.get("/jwt", (req, res) => {
console.log("jwt Generate:"); console.log("jwt Generate:");
const exp_time = new Date(Date.now() + 3 * 24 * 3600 * 1000); const exp_time = new Date(Date.now() + 3 * 24 * 3600 * 1000);
const token=tokenGenerate("39f32a2a-e343-4ca0-9d92-5946573af5ea", privateKey, { const token = tokenGenerate("39f32a2a-e343-4ca0-9d92-5946573af5ea", privateKey, {
exp: Math.round(exp_time.getTime()/1000), exp: Math.round(exp_time.getTime() / 1000),
sub: "hainatravel", sub: "hainatravel",
acl: aclPaths, acl: aclPaths,
}) });
console.log(Math.round(exp_time.getTime()/1000)); console.log(Math.round(exp_time.getTime() / 1000));
console.log(token); console.log(token);
console.log("---"); console.log("---");
res.json({ res.json({
@ -82,5 +85,10 @@ app.all("/voice/fallback", (req, res) => {
res.sendStatus(200); res.sendStatus(200);
}); });
app.all("/voice/recordings", (req, res) => {
console.log("recordings:");
console.dir(req.body);
res.sendStatus(200);
});
app.listen(3009); app.listen(3009);

Loading…
Cancel
Save