This commit is contained in:
Claeb101 2023-03-05 04:14:15 -05:00
commit 73fc637426
4 changed files with 8 additions and 6 deletions

View File

@ -39,7 +39,7 @@ model Message {
createdAt DateTime @default(now()) createdAt DateTime @default(now())
role Role role Role
content String content String @default("")
session Session @relation(fields: [sessionId], references: [id]) session Session @relation(fields: [sessionId], references: [id])
sessionId String @db.ObjectId sessionId String @db.ObjectId

View File

@ -69,10 +69,6 @@ app.post("/respond", async (req, res) => {
transferSession(req.body.CallSid, operatorPhone); transferSession(req.body.CallSid, operatorPhone);
twiml.say("We're connecting you to a counselor now."); twiml.say("We're connecting you to a counselor now.");
await addMessage(callId, Role.BOT, "");
let summary = await summarize(callId);
console.log(summary);
const dial = twiml.dial({}); const dial = twiml.dial({});
dial.number(operatorPhone); dial.number(operatorPhone);
res.type("text/xml"); res.type("text/xml");

View File

@ -36,7 +36,10 @@ export const chat = async (callId) => {
for (let msg of msgs) { for (let msg of msgs) {
messages.push({ messages.push({
role: convertRole(msg.role), role: convertRole(msg.role),
content: msg.content, content:
msg.content.length > 0
? msg.content
: "This message was not recorded correctly.",
}); });
} }

View File

@ -2,6 +2,9 @@ import { Role } from "@prisma/client";
import { db } from "./db.js"; import { db } from "./db.js";
export const createSession = async (callId, callerPhone) => { export const createSession = async (callId, callerPhone) => {
let session = await findSessionByCallId(callId);
if (session) return session;
return await db.session.create({ return await db.session.create({
data: { data: {
callId: callId, callId: callId,