feat: implement gemini async nlp extraction, contact auto-creation, data enrichment & clean notes
All checks were successful
Build & Push Friends Image to Gitea Registry / build-and-push (push) Successful in 9s
All checks were successful
Build & Push Friends Image to Gitea Registry / build-and-push (push) Successful in 9s
This commit is contained in:
45
telegram.js
45
telegram.js
@@ -1,5 +1,5 @@
|
||||
import {
|
||||
analyzeText,
|
||||
analyzeTextAI,
|
||||
writeToMonica,
|
||||
appendLocalRecord,
|
||||
monicaFetch,
|
||||
@@ -270,7 +270,7 @@ async function handleUpdate(update) {
|
||||
// 3. Match contacts and run NLP engine
|
||||
await sendChatAction(chatId, "typing");
|
||||
const contacts = await fetchMonicaContacts();
|
||||
const analysis = analyzeText(processedText, "auto", contacts);
|
||||
const analysis = await analyzeTextAI(processedText, "auto", contacts);
|
||||
|
||||
// 4. Save entry locally and sync to Monica CRM
|
||||
const entry = {
|
||||
@@ -305,9 +305,14 @@ async function handleUpdate(update) {
|
||||
responseText += `🎤 <b>Transkription (Gemini):</b>\n<i>"${escapeHtml(processedText)}"</i>\n\n`;
|
||||
}
|
||||
|
||||
if (analysis.contact) {
|
||||
const contactUrl = `${getMonicaBaseUrl()}/people/${analysis.contact.id}`;
|
||||
responseText += `👤 <b>Kontakt:</b> <a href="${contactUrl}">${escapeHtml(analysis.contact.name)}</a>\n`;
|
||||
if (entry.contact) {
|
||||
if (entry.contact.id) {
|
||||
const contactUrl = `${getMonicaBaseUrl()}/people/${entry.contact.id}`;
|
||||
const nameStr = entry.contact.is_new ? `${entry.contact.name} (neu erstellt)` : entry.contact.name;
|
||||
responseText += `👤 <b>Kontakt:</b> <a href="${contactUrl}">${escapeHtml(nameStr)}</a>\n`;
|
||||
} else {
|
||||
responseText += `👤 <b>Kontakt:</b> <i>Fehler bei Erstellung (${escapeHtml(entry.contact.name)})</i>\n`;
|
||||
}
|
||||
} else {
|
||||
responseText += `👤 <b>Kontakt:</b> <i>Keine Zuordnung</i>\n`;
|
||||
}
|
||||
@@ -329,9 +334,35 @@ async function handleUpdate(update) {
|
||||
responseText += `\n<b>Monica CRM Synchronisation:</b>\n`;
|
||||
if (localRecord.monicaResults && localRecord.monicaResults.length > 0) {
|
||||
for (const res of localRecord.monicaResults) {
|
||||
const typeLabel = res.type === "journal" ? "📖 Tagebuch" : res.type === "note" ? "📝 Notiz" : "📅 Erinnerung";
|
||||
let typeLabel = "⚙️ CRM";
|
||||
switch (res.type) {
|
||||
case "journal":
|
||||
typeLabel = "📖 Tagebuch";
|
||||
break;
|
||||
case "note":
|
||||
typeLabel = "📝 Notiz";
|
||||
break;
|
||||
case "reminder":
|
||||
typeLabel = "📅 Erinnerung";
|
||||
break;
|
||||
case "contact_create":
|
||||
typeLabel = "👤 Kontakt erstellt";
|
||||
break;
|
||||
case "contact_birthdate":
|
||||
typeLabel = "📅 Geburtstag aktualisiert";
|
||||
break;
|
||||
case "contact_email":
|
||||
typeLabel = "📧 E-Mail hinzugefügt";
|
||||
break;
|
||||
case "contact_phone":
|
||||
typeLabel = "📞 Telefon hinzugefügt";
|
||||
break;
|
||||
case "contact_address":
|
||||
typeLabel = "🏠 Adresse hinzugefügt";
|
||||
break;
|
||||
}
|
||||
if (res.ok) {
|
||||
responseText += `- ${typeLabel}: ✅ Erfolgreich (ID: ${res.id})\n`;
|
||||
responseText += `- ${typeLabel}: ✅ Erfolgreich\n`;
|
||||
} else {
|
||||
responseText += `- ${typeLabel}: ❌ Fehler: <code>${escapeHtml(res.error)}</code>\n`;
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user