[31388f42] Final session polish: Refined UI, improved ingest parsing, and completed documentation
This commit is contained in:
@@ -3,8 +3,9 @@ import json
|
||||
import requests
|
||||
import sqlite3
|
||||
import re
|
||||
import datetime
|
||||
|
||||
# Load API Key
|
||||
# --- Helper: Get Gemini Key ---
|
||||
def get_gemini_key():
|
||||
candidates = [
|
||||
"gemini_api_key.txt", # Current dir
|
||||
@@ -57,34 +58,63 @@ def get_matrix_context(industry_name, persona_name):
|
||||
|
||||
return context
|
||||
|
||||
def get_product_recommendation(area_str):
|
||||
def get_suggested_date():
|
||||
"""Calculates a suggested meeting date (3-4 days in future, avoiding weekends)."""
|
||||
now = datetime.datetime.now()
|
||||
# Jump 3 days ahead
|
||||
suggested = now + datetime.timedelta(days=3)
|
||||
# If weekend, move to Monday
|
||||
if suggested.weekday() == 5: # Saturday
|
||||
suggested += datetime.timedelta(days=2)
|
||||
elif suggested.weekday() == 6: # Sunday
|
||||
suggested += datetime.timedelta(days=1)
|
||||
|
||||
days_de = ["Montag", "Dienstag", "Mittwoch", "Donnerstag", "Freitag", "Samstag", "Sonntag"]
|
||||
return f"{days_de[suggested.weekday()]}, den {suggested.strftime('%d.%m.')} um 10:00 Uhr"
|
||||
|
||||
def clean_company_name(name):
|
||||
"""Removes legal suffixes like GmbH, AG, etc. for a more personal touch."""
|
||||
if not name: return ""
|
||||
# Remove common German legal forms
|
||||
cleaned = re.sub(r'\s+(GmbH|AG|GmbH\s+&\s+Co\.\s+KG|KG|e\.V\.|e\.K\.|Limited|Ltd|Inc)\.?(?:\s|$)', '', name, flags=re.IGNORECASE)
|
||||
return cleaned.strip()
|
||||
|
||||
def get_multi_solution_recommendation(area_str, purpose_str):
|
||||
"""
|
||||
Selects the right robot based on the surface area mentioned in the lead.
|
||||
Selects a range of robots based on surface area AND requested purposes.
|
||||
"""
|
||||
# Naive extraction of first number in the string
|
||||
recommendations = []
|
||||
purpose_lower = purpose_str.lower()
|
||||
|
||||
# 1. Cleaning Logic (Area based)
|
||||
nums = re.findall(r'\d+', area_str.replace('.', '').replace(',', ''))
|
||||
area_val = int(nums[0]) if nums else 0
|
||||
|
||||
if area_val >= 5000 or "über 10.000" in area_str:
|
||||
return {
|
||||
"name": "Scrubber 75",
|
||||
"reason": "als industrielles Kraftpaket für Großflächen ausgelegt",
|
||||
"usp": "höchste Effizienz und Autonomie auf mehreren tausend Quadratmetern"
|
||||
}
|
||||
elif area_val >= 1000:
|
||||
return {
|
||||
"name": "Scrubber 50 oder Phantas",
|
||||
"reason": "die optimale Balance zwischen Reinigungsleistung und Wendigkeit",
|
||||
"usp": "ideal für mittelgroße Fertigungs- und Lagerbereiche"
|
||||
}
|
||||
else:
|
||||
return {
|
||||
"name": "Phantas oder Pudu CC1",
|
||||
"reason": "kompakt und wendig für komplexe Umgebungen",
|
||||
"usp": "perfekt für Büros, Praxen oder engere Verkehrswege"
|
||||
}
|
||||
if "reinigung" in purpose_lower:
|
||||
if area_val >= 5000 or "über 10.000" in area_str:
|
||||
recommendations.append("den Scrubber 75 als industrielles Kraftpaket für Ihre Großflächen")
|
||||
elif area_val >= 1000:
|
||||
recommendations.append("den Scrubber 50 oder Phantas für eine wendige und gründliche Bodenreinigung")
|
||||
else:
|
||||
recommendations.append("den Phantas oder Pudu CC1 für eine effiziente Reinigung Ihrer Räumlichkeiten")
|
||||
|
||||
def generate_email_draft(lead_data, company_data, booking_link="[IHR BUCHUNGSLINK - BITTE IN .ENV EINTRAGEN]"):
|
||||
# 2. Service/Transport Logic
|
||||
if any(word in purpose_lower for word in ["servieren", "abräumen", "speisen", "getränke"]):
|
||||
recommendations.append("den BellaBot zur Entlastung Ihres Teams beim Transport von Speisen und Getränken")
|
||||
|
||||
# 3. Marketing/Interaction Logic
|
||||
if any(word in purpose_lower for word in ["marketing", "gästebetreuung", "kundenansprache"]):
|
||||
recommendations.append("den KettyBot als interaktiven Begleiter für Marketing und Patienteninformation")
|
||||
|
||||
if not recommendations:
|
||||
recommendations.append("unsere wendigen Allrounder wie den Phantas")
|
||||
|
||||
return {
|
||||
"solution_text": " und ".join(recommendations),
|
||||
"has_multi": len(recommendations) > 1
|
||||
}
|
||||
|
||||
def generate_email_draft(lead_data, company_data, booking_link="[IHR BUCHUNGSLINK]"):
|
||||
"""
|
||||
Generates a high-end, personalized sales email using Gemini API and Matrix knowledge.
|
||||
"""
|
||||
@@ -93,7 +123,8 @@ def generate_email_draft(lead_data, company_data, booking_link="[IHR BUCHUNGSLIN
|
||||
return "Error: Gemini API Key not found."
|
||||
|
||||
# Extract Data from Lead Engine
|
||||
company_name = lead_data.get('company_name', 'Interessent')
|
||||
company_raw = lead_data.get('company_name', 'Interessent')
|
||||
company_name = clean_company_name(company_raw)
|
||||
contact_name = lead_data.get('contact_name', 'Damen und Herren')
|
||||
|
||||
# Metadata from Lead
|
||||
@@ -105,14 +136,17 @@ def generate_email_draft(lead_data, company_data, booking_link="[IHR BUCHUNGSLIN
|
||||
area = meta.get('area', 'Unbekannte Fläche')
|
||||
purpose = meta.get('purpose', 'Reinigung')
|
||||
role = meta.get('role', 'Wirtschaftlicher Entscheider')
|
||||
salutation = meta.get('salutation', 'Damen und Herren')
|
||||
cleaning_functions = meta.get('cleaning_functions', '')
|
||||
|
||||
# Data from Company Explorer
|
||||
ce_summary = company_data.get('research_dossier') or company_data.get('summary', '')
|
||||
ce_vertical = company_data.get('industry_ai') or company_data.get('vertical', 'Industry - Manufacturing')
|
||||
ce_vertical = company_data.get('industry_ai') or company_data.get('vertical', 'Healthcare')
|
||||
ce_opener = company_data.get('ai_opener', '')
|
||||
|
||||
# Product logic
|
||||
product = get_product_recommendation(area)
|
||||
# Multi-Solution Logic
|
||||
solution = get_multi_solution_recommendation(area, purpose)
|
||||
suggested_date = get_suggested_date()
|
||||
|
||||
# Fetch "Golden Records" from Matrix
|
||||
matrix = get_matrix_context(ce_vertical, role)
|
||||
@@ -122,46 +156,35 @@ def generate_email_draft(lead_data, company_data, booking_link="[IHR BUCHUNGSLIN
|
||||
Du bist ein Senior Sales Executive bei Robo-Planet. Antworte auf eine Anfrage von Tradingtwins.
|
||||
Schreibe eine E-Mail auf "Human Expert Level".
|
||||
|
||||
WICHTIGE STRATEGIE:
|
||||
- Starte NICHT mit seiner Position (CFO). Starte mit der Wertschätzung für sein UNTERNEHMEN ({company_name}).
|
||||
- Der Empfänger soll durch die Tiefe der Argumente MERKEN, dass wir für einen Entscheider schreiben.
|
||||
- Mappe ihn erst später als "finanziellen/wirtschaftlichen Entscheider".
|
||||
- Erwähne eine ROI-Perspektive (Amortisation).
|
||||
|
||||
KONTEXT (Vom Company Explorer):
|
||||
- Firma: {company_name}
|
||||
- Branche: {ce_vertical}
|
||||
- Branchen-Pains (Nutze diese für die Argumentation): {matrix['industry_pains']}
|
||||
- Branchen-Gains: {matrix['industry_gains']}
|
||||
- Dossier/Business-Profil: {ce_summary}
|
||||
- Strategischer Aufhänger: {ce_opener}
|
||||
|
||||
ANSPRECHPARTNER:
|
||||
WICHTIGE IDENTITÄT:
|
||||
- Anrede-Form: {salutation} (z.B. Herr, Frau)
|
||||
- Name: {contact_name}
|
||||
- Rolle: {role}
|
||||
- Firma: {company_name}
|
||||
|
||||
PRODUKT-EMPFEHLUNG (Basierend auf Fläche {area}):
|
||||
- Modell: {product['name']}
|
||||
- Warum: {product['reason']}
|
||||
- USP: {product['usp']}
|
||||
|
||||
ANFRAGE-DETAILS:
|
||||
- Bedarf: {area}
|
||||
- Zweck: {purpose}
|
||||
STRATEGIE:
|
||||
- STARTE DIREKT mit dem strategischen Aufhänger aus dem Company Explorer ({ce_opener}). Baue daraus den ersten Absatz.
|
||||
- KEIN "mit großem Interesse verfolge ich..." oder ähnliche Phrasen. Das wirkt unnatürlich.
|
||||
- Deine Mail reagiert auf die Anfrage zu: {purpose} auf {area}.
|
||||
- Fasse die vorgeschlagene Lösung ({solution['solution_text']}) KOMPAKT zusammen. Wir bieten ein ganzheitliches Entlastungskonzept an, keine Detail-Auflistung von Datenblättern.
|
||||
|
||||
KONTEXT:
|
||||
- Branche: {ce_vertical}
|
||||
- Pains aus Matrix: {matrix['industry_pains']}
|
||||
- Dossier/Wissen: {ce_summary}
|
||||
- Strategischer Aufhänger (CE-Opener): {ce_opener}
|
||||
|
||||
AUFGABE:
|
||||
Schreibe eine E-Mail mit dieser Struktur:
|
||||
1. EINSTIEG: Fokus auf Klemm Bohrtechnik und deren Marktstellung/Produkte (Bezug auf den 'Strategischen Aufhänger').
|
||||
2. DIE BRÜCKE: Verknüpfe die Präzision ihrer Produkte mit der Notwendigkeit von sauberen Hallenböden (besonders bei {area}). Nutze den Schmerzpunkt "Prozesssicherheit/Sensorik".
|
||||
3. DIE LÖSUNG: Positioniere den {product['name']} als genau die richtige Wahl für diese Größenordnung ({area}).
|
||||
4. ROI-LOGIK: Sprich ihn als wirtschaftlichen Entscheider an. Erwähne, dass wir für solche Projekte ROI-Kalkulationen erstellen, die oft eine Amortisation in unter 18-24 Monaten zeigen.
|
||||
5. CALL TO ACTION: Beratungsgespräch + Buchungslink: {booking_link}
|
||||
1. ANREDE: Persönlich.
|
||||
2. EINSTIEG: Nutze den inhaltlichen Kern von: "{ce_opener}".
|
||||
3. DER ÜBERGANG: Verknüpfe dies mit der Anfrage zu {purpose}. Erkläre, dass manuelle Prozesse bei {area} angesichts der Dokumentationspflichten und des Fachkräftemangels zum Risiko werden.
|
||||
4. DIE LÖSUNG: Schlage die Kombination aus {solution['solution_text']} als integriertes Konzept vor, um das Team in Reinigung, Service und Patientenansprache spürbar zu entlasten.
|
||||
5. ROI: Sprich kurz die Amortisation (18-24 Monate) an – als Argument für den wirtschaftlichen Entscheider.
|
||||
6. CTA: Schlag konkret den {suggested_date} vor. Alternativ: {booking_link}
|
||||
|
||||
STIL:
|
||||
Senior, Augenhöhe, keine Floskeln, extrem fokussiert auf Effizienz und Qualität.
|
||||
STIL: Senior, lösungsorientiert, direkt. Keine unnötigen Füllwörter.
|
||||
|
||||
FORMAT:
|
||||
Betreff: [Relevanter Betreff, der direkt auf Klemm Bohrtechnik / Effizienz zielt]
|
||||
Betreff: [Prägnant, z.B. Automatisierungskonzept für {company_name}]
|
||||
|
||||
[E-Mail Text]
|
||||
"""
|
||||
@@ -190,4 +213,4 @@ if __name__ == "__main__":
|
||||
"vertical": "Healthcare / Krankenhaus",
|
||||
"summary": "Ein großes Klinikum der Maximalversorgung mit Fokus auf Kardiologie."
|
||||
}
|
||||
print(generate_email_draft(mock_lead, mock_company))
|
||||
print(generate_email_draft(mock_lead, mock_company))
|
||||
|
||||
Reference in New Issue
Block a user