Add automatic VoIP call summaries and sync progress checklist.

When a PBX webhook includes recordingUrl or transcript, queue STT and AI to create a call_result note; mark API, bulk SMS, WooCommerce, and VoIP as done and defer online payments.

Co-authored-by: Cursor <cursoragent@cursor.com>
This commit is contained in:
2026-09-27 15:06:41 +03:30
co-authored by Cursor
parent c06c92b333
commit c5c903d4b4
13 changed files with 615 additions and 22 deletions
+38
View File
@@ -61,6 +61,44 @@ Rules:
return this.normalizeExtract(raw);
}
async summarizeCallTranscript(input: {
transcript: string;
personName?: string | null;
direction?: string | null;
}): Promise<{ summary: string; nextAction: string | null }> {
const system = `You summarize phone call transcripts for a Persian CRM.
Return ONLY valid JSON:
{
"summary": string,
"nextAction": string | null
}
Rules:
- summary: 3–8 concise Persian sentences covering purpose, customer needs, outcomes, and commitments.
- nextAction: one short Persian follow-up if needed; otherwise null.
- Do not invent facts not in the transcript.
- Keep names, numbers, and amounts accurate.`;
const userParts = [
input.personName ? `Customer: ${input.personName}` : null,
input.direction ? `Direction: ${input.direction}` : null,
`Transcript:\n${input.transcript.trim().slice(0, 12000)}`,
].filter(Boolean);
const raw = await this.completeJson<{
summary?: string;
nextAction?: string | null;
}>(system, userParts.join('\n'));
const summary = String(raw.summary ?? '').trim().slice(0, 4000);
if (!summary) {
throw new BadRequestException('خلاصه تماس خالی بود');
}
const nextAction = raw.nextAction
? String(raw.nextAction).trim().slice(0, 500) || null
: null;
return { summary, nextAction };
}
async completeJson<T>(system: string, user: string): Promise<T> {
if (!this.isEnabled()) {
throw new ServiceUnavailableException('هوش مصنوعی فعال نیست');