Adds AI-driven conversation tracking to debt negotiation

Introduces comprehensive conversation history with a new table and UI for tracking all negotiation emails, AI analysis, and financial outcomes. Enhances real-time updates, manages negotiation rounds, and supports new statuses for negotiation lifecycle. Integrates AI-powered extraction and response analysis to automate intent detection and outcome calculations, improving transparency and automation of debt resolution.
This commit is contained in:
2025-06-08 00:32:04 -03:00
parent 0c6f72761d
commit bddc3a344d
14 changed files with 2568 additions and 135 deletions

View File

@@ -27,6 +27,10 @@ export type Debt = {
| "negotiating"
| "approved"
| "sent"
| "awaiting_response"
| "counter_negotiating"
| "accepted"
| "rejected"
| "settled"
| "failed"
| "opted_out";
@@ -35,6 +39,11 @@ export type Debt = {
user_id: string;
description?: string | null;
due_date?: string | null;
conversation_count?: number;
last_message_at?: string;
negotiation_round?: number;
prospected_savings?: number;
actual_savings?: number;
metadata?: Record<string, any> | null;
};
@@ -84,3 +93,24 @@ export type DebtVariable = {
created_at: string;
updated_at: string;
};
export type ConversationMessage = {
id: string;
debt_id: string;
message_type:
| "initial_debt"
| "negotiation_sent"
| "response_received"
| "counter_offer"
| "acceptance"
| "rejection";
direction: "inbound" | "outbound";
subject?: string;
body: string;
from_email?: string;
to_email?: string;
message_id?: string;
ai_analysis?: Record<string, any>;
created_at: string;
updated_at: string;
};