require contactId for contact summary updates

This commit is contained in:
Ruslan Bakiev
2026-02-20 16:26:34 +07:00
parent d7fcff738f
commit b9ba5778f5

View File

@@ -795,13 +795,16 @@ export async function runLangGraphCrmAgentFor(input: {
} }
if (raw.action === "updateContactSummary") { if (raw.action === "updateContactSummary") {
const contactName = (raw.contact ?? "").trim(); const contactId = (raw.contactId ?? "").trim();
const content = (raw.summary ?? raw.content ?? "").trim(); const content = (raw.summary ?? raw.content ?? "").trim();
if (!contactName) throw new Error("contact is required"); if (!contactId) throw new Error("contactId is required");
if (!content) throw new Error("summary is required"); if (!content) throw new Error("summary is required");
const contact = await resolveContact(input.teamId, contactName); const contact = await prisma.contact.findFirst({
if (!contact) throw new Error("contact not found"); where: { id: contactId, teamId: input.teamId },
select: { id: true, name: true },
});
if (!contact) throw new Error("contactId not found");
await prisma.contactNote.upsert({ await prisma.contactNote.upsert({
where: { contactId: contact.id }, where: { contactId: contact.id },
update: { content }, update: { content },