更新语音通话回调地址

hotfix/new-conversation
YCC 1 year ago
parent c3274bd31e
commit 7253c03960

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

Loading…
Cancel
Save