7.0 KiB
7.0 KiB
✅ Session-Zusammenfassung: Auto-Workflow & Kalender
Datum: 2025-11-12 17:00
Status: Auto-Workflow implementiert, Kalender-Integration bereit
✅ WAS WURDE IMPLEMENTIERT
1. Nextcloud CalDAV-Integration
- ✅ CalDAV-Client (
tsdav) installiert - ✅ Service-Klasse:
lib/nextcloud-calendar.ts - ✅ Funktionen:
createBookingEvent()- Erstellt Kalender-EintragupdateBookingEvent()- Aktualisiert EintragdeleteBookingEvent()- Löscht EintragupdateEventStatus()- Ändert Status-Emoji (🟡 → 🟢)
- ✅ ICS-Format-Generierung (kompatibel mit Nextcloud)
- ✅ Credentials in
.envhinterlegt (siehe NEXTCLOUD-SETUP.md)
Nextcloud-Zugangsdaten:
- URL: https://cloud.savethemoment.photos
- Benutzername: SaveTheMoment-Atlas
- Passwort: T.H,Nwq>S"83Vp7
2. Auto-Workflow Cron-Job
Datei: app/api/cron/process-pending-bookings/route.ts
Läuft: Alle 5 Minuten
Was passiert:
- ✅ Findet neue Buchungen (
aiParsed=false) - ✅ KI-Analyse mit GPT-4 (E-Mail-Entwurf)
- ✅ LexOffice Kontakt erstellen
- ✅ LexOffice Angebot-Entwurf erstellen
- ✅ Kalender-Eintrag in Nextcloud erstellen
- ✅ Status:
readyForAssignment=true(Admin kann jetzt prüfen)
3. Cron-Jobs aktualisiert
Datei: vercel.json
{
"crons": [
{
"path": "/api/cron/email-sync",
"schedule": "*/5 * * * *" // Alle 5 Min (vorher 15)
},
{
"path": "/api/cron/process-pending-bookings",
"schedule": "*/5 * * * *" // NEU: Auto-Workflow
},
{
"path": "/api/cron/check-contracts",
"schedule": "*/15 * * * *" // Bleibt bei 15 Min
}
]
}
4. Sidebar erweitert: Weitere Projekte
Datei: components/DashboardSidebar.tsx
Neue Menüpunkte (klappbar unter "Weitere Projekte"):
- 🔵 Die Fotoboxjungs (www.diefotoboxjungs.de)
- 🟢 Die Klönbox (www.die-kloenbox.de)
- 🩷 Hochzeitsbuchstaben (www.hochzeitsbuchstaben.de)
- 🟣 Forte & Friends (www.forte.dj)
- 🟡 Melobox (www.melobox.de)
🔄 WORKFLOW-ABLAUF (Automatisch)
Phase 1: E-Mail-Eingang → Auto-Verarbeitung
Cron-Job läuft alle 5 Min
↓
Prüft IMAP-Postfach (Lübeck)
↓
Neue E-Mail → Erstellt Booking (Status: RESERVED, aiParsed=false)
↓
Cron-Job "process-pending-bookings" findet Buchung
↓
GPT-4 generiert E-Mail-Antwort-Entwurf
↓
LexOffice erstellt Kontakt
↓
LexOffice erstellt Angebot-Entwurf
↓
Nextcloud Kalender: Eintrag erstellt (🟡 Reserviert)
↓
Status: readyForAssignment=true
Phase 2: Admin-Review (UI fehlt noch!)
Dashboard zeigt: "Offene Anfragen" Badge
↓
Admin klickt auf Anfrage
↓
Sieht:
- KI-generierte E-Mail (Entwurf)
- LexOffice Angebot (Link)
- Extrahierte Kundendaten
↓
Admin prüft & klickt:
[✓ Senden] oder [✗ Korrigieren]
Phase 3: Auto-Versand (noch zu implementieren!)
Admin klickt "Senden"
↓
System sendet E-Mail mit:
- Personalisierte Nachricht
- Angebot (PDF-Anhang)
- Mietvertrag (PDF-Anhang)
↓
Kalender-Update: 🟡 → 🟢 (CONFIRMED)
↓
Status: RESERVED
⚙️ SETUP ANLEITUNG
1. Nextcloud-Credentials hinzufügen
Öffne .env und füge hinzu:
NEXTCLOUD_URL="https://cloud.savethemoment.photos"
NEXTCLOUD_USERNAME="SaveTheMoment-Atlas"
NEXTCLOUD_PASSWORD="T.H,Nwq>S\"83Vp7"
2. Server neu starten
npm run dev
3. Kalender-Verbindung testen
# Test-Endpunkt (muss noch erstellt werden):
curl http://localhost:3001/api/calendar/test
4. Cron-Jobs lokal testen
# E-Mail-Sync (manuelle Trigger):
curl -H "Authorization: Bearer your-cron-secret" \
http://localhost:3001/api/cron/email-sync
# Auto-Workflow:
curl -H "Authorization: Bearer your-cron-secret" \
http://localhost:3001/api/cron/process-pending-bookings
📋 NÄCHSTE SCHRITTE (noch zu implementieren)
1. Admin-Review UI (Dashboard-Widget)
- Widget: "Offene Anfragen" auf Dashboard
- Review-Modal mit Tabs:
- E-Mail-Vorschau
- Angebot-Vorschau (LexOffice Link)
- Kundendaten bearbeiten
- Button: "Prüfen & Senden"
2. Auto-Versand API
- API:
/api/bookings/[id]/approve-and-send - E-Mail-Versand mit Anhängen
- Kalender-Update (Status-Change)
3. Datenbank-Erweiterung (neue Felder)
model Booking {
// Workflow-Status
aiDraftReady Boolean @default(false)
adminReviewedAt DateTime?
adminReviewedBy String?
// Kalender-Sync
calendarEventId String?
calendarSynced Boolean @default(false)
calendarSyncedAt DateTime?
// Versand-Status
documentsSentAt DateTime?
documentsSentTo String?
}
4. Kalender-Test-API erstellen
GET /api/calendar/test- Testet Nextcloud-VerbindungPOST /api/calendar/sync- Sync manuell triggern
5. Multi-Projekt-Support
- Projekt-Model im Schema
- Buchungen mit Projekt verknüpfen
- Projekt-spezifische Preise & Settings
- Projekt-Filter im Dashboard
🧪 TESTING
Was du jetzt testen kannst:
-
Tour erstellen (3 CONFIRMED Buchungen vorhanden):
- http://localhost:3001/dashboard/tours
- Wähle 2-3 Buchungen aus
- Routenoptimierung startet automatisch
-
LexOffice-Integration (manuell):
curl -X POST http://localhost:3001/api/bookings/[BOOKING-ID]/create-quotation -
Sidebar: Weitere Projekte
- Klicke auf "Weitere Projekte" (sollte aufklappen)
- 5 neue Projekte sichtbar
Was noch NICHT funktioniert:
- ❌ Nextcloud-Kalender (Credentials müssen in
.enveingetragen werden) - ❌ Auto-Workflow Cron (läuft erst auf Vercel oder mit lokalem Cron-Trigger)
- ❌ Admin-Review UI (Widget fehlt noch)
- ❌ Auto-Versand (E-Mail-Funktion fehlt noch)
🔐 WICHTIGE ERINNERUNGEN
1. Nextcloud-Passwort enthält Sonderzeichen!
# RICHTIG:
NEXTCLOUD_PASSWORD="T.H,Nwq>S\"83Vp7"
# FALSCH (ohne Quotes):
NEXTCLOUD_PASSWORD=T.H,Nwq>S"83Vp7
2. Cron-Jobs funktionieren nur auf Vercel!
Lokal musst du sie manuell triggern:
curl -H "Authorization: Bearer your-cron-secret" \
http://localhost:3001/api/cron/process-pending-bookings
3. SMTP-Settings nur in Lübeck
Für Auto-Versand wird die E-Mail-Config von Location "Lübeck" verwendet.
📊 IMPLEMENTATION STATUS
| Feature | Status | Geschätzte Zeit |
|---|---|---|
| ✅ Nextcloud CalDAV | Komplett | - |
| ✅ Auto-Workflow Cron | Komplett | - |
| ✅ Sidebar: Projekte | Komplett | - |
| ✅ Cron: 5-Min-Intervall | Komplett | - |
| ⏳ Admin-Review UI | Ausstehend | 2-3 Tage |
| ⏳ Auto-Versand API | Ausstehend | 1-2 Tage |
| ⏳ DB-Migration (neue Felder) | Ausstehend | 1 Tag |
| ⏳ Multi-Projekt-Support | Ausstehend | 3-4 Tage |
Gesamt-Fortschritt: ~40% (Basis-Infrastruktur fertig)
Nächster Schritt:
.envmit Nextcloud-Credentials ergänzen- Kalender-Verbindung testen
- Entscheidung: Soll ich mit Admin-Review UI weitermachen?
Erstellt: 2025-11-12 17:05