mirror of
https://github.com/vitalityAI/therapist.git
synced 2025-04-18 10:30:17 -04:00
feat: completes calls on hangup
This commit is contained in:
parent
297bcb9704
commit
c46d5ac7c2
|
@ -109,4 +109,12 @@ app.post("/summarize", async (req, res) => {
|
||||||
res.send(JSON.stringify({ SessionId: sessionId, summary: summary }));
|
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;
|
export default app;
|
||||||
|
|
|
@ -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) => {
|
export const transferSession = async (callId, operatorPhone) => {
|
||||||
return await db.session.update({
|
return await db.session.update({
|
||||||
where: {
|
where: {
|
||||||
|
|
Loading…
Reference in New Issue
Block a user