feat: completes calls on hangup

This commit is contained in:
Rushil Umaretiya 2023-03-05 04:49:59 -05:00
parent 297bcb9704
commit c46d5ac7c2
2 changed files with 19 additions and 0 deletions

View File

@ -109,4 +109,12 @@ app.post("/summarize", async (req, res) => {
res.send(JSON.stringify({ SessionId: sessionId, summary: summary }));
});
app.post("/status", async (req, res) => {
let callId = req.body.CallSid;
let callStatus = req.body.CallStatus;
if (callStatus === "completed") {
await completeCall(callId);
}
});
export default app;

View File

@ -21,6 +21,17 @@ export const findSessionByCallId = async (callId) => {
});
};
export const completeCall = async (callId) => {
return await db.session.update({
where: {
callId: callId,
},
data: {
endedAt: new Date(),
},
});
};
export const transferSession = async (callId, operatorPhone) => {
return await db.session.update({
where: {