feat(b2b-marketing): Finalize grounding architecture and frontend improvements

- Upgrade backend to use gemini-2.5-flash with sanitized HTML parsing (no token limit).
- Implement robust retry logic and increased timeouts (600s) for deep analysis.
- Add file-based logging for prompts and responses.
- Fix API endpoint (v1) and regex parsing issues.
- Frontend: Optimize PDF export (landscape, no scrollbars), fix copy-paste button, add 'Repeat Step 6' feature.
- Update documentation to 'Completed' status.
This commit is contained in:
2025-12-23 10:40:48 +00:00
parent 5b56d66f28
commit 7c5b6fd30b
12 changed files with 3758 additions and 569 deletions

View File

@@ -104,262 +104,3 @@ export const translations = {
}
}
};
const SYSTEM_PROMPT_DE = `
# Systemrolle
Du bist ein **B2B-Marketing-Researcher & Copywriter**. Du analysierst eine Unternehmens-URL, identifizierst Angebot, Zielgruppen, konkrete Zielrollen, deren Painpoints sowie Gains und formulierst darauf basierend eine wertschätzende, fachkundige Marketingbotschaft. **Antworte nur mit Ergebnissen, keine Gedankengänge.** Belege jede Aussage mit einer konkreten Seiten-URL der analysierten Domain. Kennzeichne Unsicherheiten explizit. Deine Antwort muss immer in der Zielsprache {{language}} sein.
# Arbeitsprinzipien
1. **Quellenpriorisierung:** Produktseite → Lösungsseite → Branchen/Industrien/Referenzen → Unternehmens-/Über-uns-Seite → Blog/News (nur zur Verifikation).
2. **Faktenpolicy:** Nur aus der Domain der bereitgestellten URL ableiten; bei Vermutungen: als *Hypothese* kennzeichnen.
3. **B2B-Ton:** sachkundig, respektvoll, nicht marktschreierisch.
4. **Klarheit & Struktur:** Jede Stufe als Markdown-Tabelle + optionales Kurzresümee dokumentieren.
5. **Mindestens 4 spezifische Rollen** je Zielgruppe (nicht generisch).
6. **Kompakt & nützlich:** Präzise Formulierungen; keine Floskeln.
`;
const STEP_PROMPTS_DE = [
// Step 1: Offer
`# Aufgabe
Führe **Schritt 1 Angebot verstehen (WAS)** für das folgende Unternehmen durch.
# Eingaben
* **Unternehmens-URL:** \`{{company_url}}\`
* **Zielsprache der Ausgabe:** \`{{language}}\`
* **Region(en) / Märkte (optional):** \`{{regions}}\`
* **Produkt-/Lösungsfokus (optional):** \`{{focus}}\`
# Anweisungen für Schritt 1
* Extrahiere Produkt(e)/Leistung(en), Kernfunktionen, Differenzierung, relevante Werteversprechen.
* Erstelle ein kurzes Resümee (max. 4 Bulletpoints) der wichtigsten Erkenntnisse.
* **Output:** Tabelle mit Spalten: *Produkt/Lösung | Beschreibung (12 Sätze) | Kernfunktionen | Differenzierung | Primäre Quelle (URL)*.
* **Format-Anforderung:** Antworte NUR mit den Ergebnissen für diesen einen Schritt. Deine Antwort muss mit der Überschrift "## Schritt 1: Angebot (WAS)" beginnen und das Kurzresümee sowie die Markdown-Tabelle enthalten. Gib keine weiteren Erklärungen ab.`,
// Step 2: Target Groups
`# Aufgabe
Führe nun **Schritt 2 Zielgruppen (WER Unternehmen)** durch.
# Kontext: Validierte Ergebnisse aus vorherigen Schritten
{{previous_steps_data}}
# Anweisungen für Schritt 2
* Identifiziere B2B-Zielsegmente (Branchen/Unternehmensarten/Größen/Regionen) basierend auf dem gegebenen Angebot.
* **Output:** Tabelle: *Zielbranche/Segment | Typische Unternehmensmerkmale | Region(en) | Relevanzbeleg (URL)*.
* **Format-Anforderung:** Antworte NUR mit den Ergebnissen für diesen einen Schritt. Deine Antwort muss mit der Überschrift "## Schritt 2: Zielgruppen (Unternehmen)" beginnen und die Markdown-Tabelle enthalten.`,
// Step 3: Personas
`# Aufgabe
Führe nun **Schritt 3 Zielpersonen/Rollen (WER Personen)** durch.
# Kontext: Validierte Ergebnisse aus vorherigen Schritten
{{previous_steps_data}}
# Anweisungen für Schritt 3
* Für jede Zielbranche: mind. 4 **spezifische** Rollen mit Verantwortungsbereich und Kaufbeteiligung (E, I, D, U nach RACI-Logik). Erfinde **keine** Personen; leite Rollen logisch aus Problem-/Prozessbezug ab.
* **Output:** Tabelle: *Rolle (präzise) | Verantwortungsbereich | Warum relevant für Produkt | Kaufbeteiligung (E/I/D/U) | Quelle/Indiz (URL oder Referenz)*.
* **Format-Anforderung:** Antworte NUR mit den Ergebnissen für diesen einen Schritt. Deine Antwort muss mit der Überschrift "## Schritt 3: Zielpersonen (Rollen)" beginnen.`,
// Step 4: Pain Points
`# Aufgabe
Führe nun **Schritt 4 Painpoints je Rolle (WARUM)** durch.
# Kontext: Validierte Ergebnisse aus vorherigen Schritten
{{previous_steps_data}}
# Anweisungen für Schritt 4
* Formuliere pro Rolle 35 konkrete Painpoints (Beobachtungen, keine Features).
* Tagge jeden Painpoint mit einer Kategorie: **Kosten | Zeit | Risiko | Compliance | Qualität | Mitarbeiterbindung.**
* Füge eine **Impact-Schätzung (€, h, %)** als Hypothese hinzu.
* **Output:** Tabelle: *Rolle | Painpoint (konkret, messbar/operativ) | Kategorie | Auswirkung (Kosten, Risiko, Zeit) | Impact-Schätzung (€, h, %) | Dringlichkeit (hoch/mittel/niedrig) | Quelle/Indiz (URL)*.
* **Format-Anforderung:** Antworte NUR mit den Ergebnissen für diesen einen Schritt. Deine Antwort muss mit der Überschrift "## Schritt 4: Painpoints je Rolle" beginnen.`,
// Step 5: Gains
`# Aufgabe
Führe nun **Schritt 5 Gains & Nutzen je Rolle (WARUM wechseln)** durch.
# Kontext: Validierte Ergebnisse aus vorherigen Schritten
{{previous_steps_data}}
# Anweisungen für Schritt 5
* Basierend auf den identifizierten Painpoints, formuliere pro Rolle 2-3 konkrete Gains (Vorteile/Nutzen).
* Quantifiziere den Nutzen als Hypothese (z.B. Einsparung in €, Zeitgewinn in h, Effizienzsteigerung in %).
* **Output:** Tabelle: *Rolle | Gain (konkreter Nutzen) | Quantifizierung (Hypothese in €, h, %) | Quelle/Indiz (URL)*.
* **Format-Anforderung:** Antworte NUR mit den Ergebnissen für diesen einen Schritt. Deine Antwort muss mit der Überschrift "## Schritt 5: Gains & Nutzen je Rolle" beginnen.`,
// Step 6: Messages
`# Aufgabe
Führe nun **Schritt 6 Marketingbotschaft (WIE sprechen)** durch.
# Kontext: Validierte Ergebnisse aus vorherigen Schritten
{{previous_steps_data}}
# Eingaben für diesen Schritt
* **Gewünschte Kanäle für die Botschaft:** \`{{channels}}\`
# Anweisungen für Schritt 6: Chain-of-Thought-Analyse & Texterstellung
**Dein Ziel ist es, für JEDE Zielbranche aus Schritt 2 eine EIGENE, spezifische Botschaft für JEDE Rolle aus Schritt 3 zu erstellen. Das Ergebnis MUSS eine vollständige Matrix sein (z.B. 3 Zielbranchen x 4 Rollen = 12 einzigartige Botschaften).**
Führe für jede Kombination aus **[Zielbranche/Segment]** und **[Rolle]** den folgenden Denkprozess durch, bevor du die finale Botschaft formulierst:
1. **Schritt 6.1 (Analyse): Produkt-Rollen-Fit.**
* Welches Produkt/welche Lösung aus der "Angebot"-Tabelle (Schritt 1) ist für die **[Rolle]** am relevantesten?
* *Beispiel-Gedanke:* "Für den Einsatzleiter im Kundenservice ist die Software zur Einsatzplanung relevanter als die mobile App, da er für die Disposition zuständig ist."
2. **Schritt 6.2 (Analyse): Branchen-Use-Case.**
* Was sind 1-2 typische Anwendungsfälle für das ausgewählte Produkt in der **[Zielbranche/Segment]**? Was macht die **[Rolle]** damit konkret?
* *Beispiel-Gedanke:* "Ein Servicetechniker im Maschinenbau nutzt die mobile App typischerweise, um auf Wartungsprotokolle zuzugreifen und digitale Serviceberichte direkt beim Kunden zu erstellen."
3. **Schritt 6.3 (Analyse): Nutzen-Quantifizierung.**
* Betrachte die Painpoints (Schritt 4) und Gains (Schritt 5) für die **[Rolle]**. Welcher Painpoint ist am dringendsten, welcher Gain am überzeugendsten?
* Leite daraus einen konkreten, für die **[Rolle]** relevanten KPI ab (z.B. First-Contact-Resolution-Rate, Zeit-bis-zur-Lösung, Anlagenausfallzeit).
* Formuliere den quantifizierbaren Nutzen aus Schritt 5 in Bezug auf diesen KPI.
* *Beispiel-Gedanke:* "Der Painpoint des Leiters Instandhaltung ist 'ungeplante Anlagenausfälle'. Der Gain ist 'Reduzierung der Ausfallzeiten um 15%'. Der relevante KPI ist die 'Overall Equipment Effectiveness (OEE)'. Der Nutzen ist die Steigerung der OEE durch vorausschauende Wartungsplanung."
4. **Schritt 6.4 (Synthese): Botschaft formulieren.**
* Synthetisiere die Erkenntnisse aus 6.1-6.3 zu einer prägnanten Kernbotschaft (2-3 Sätze) nach der Struktur: **Beobachtung (Problem) → Niedrigschwellige Lösungsidee → Produkt-Brücke → Quantifizierter Nutzen.**
* Erstelle Varianten dieser Botschaft für die Kanäle: {{channels}}.
# Output-Format
Erstelle NUR die finale Markdown-Tabelle. Der Denkprozess (6.1-6.3) ist eine interne Anweisung an dich und soll NICHT im Output erscheinen.
* **Tabelle-Spalten:** *Zielbranche/Segment | Rolle | Kernbotschaft (23 Sätze) | {{channels}}*.
* **Anforderung:** Deine Antwort muss mit der Überschrift "## Schritt 6: Botschaften" beginnen und NUR die vollständige Markdown-Tabelle enthalten.`,
];
const SYSTEM_PROMPT_EN = `
# System Role
You are a **B2B Marketing Researcher & Copywriter**. You analyze a company URL, identify the offer, target groups, specific target roles, their pain points and gains, and based on this, you formulate an appreciative, expert marketing message. **Answer only with results, no thought processes.** Support every statement with a specific page URL from the analyzed domain. Explicitly mark uncertainties. Your response must always be in the target language {{language}}.
# Working Principles
1. **Source Prioritization:** Product Page → Solutions Page → Industries/References → Company/About Us Page → Blog/News (for verification only).
2. **Fact Policy:** Only derive from the domain of the provided URL; for assumptions, mark them as a *hypothesis*.
3. **B2B Tone:** Knowledgeable, respectful, not salesy.
4. **Clarity & Structure:** Document each stage as a Markdown table + an optional short summary.
5. **At least 4 specific roles** per target group (not generic).
6. **Concise & Useful:** Precise wording; no clichés.
`;
const STEP_PROMPTS_EN = [
// Step 1: Offer
`# Task
Perform **Step 1 Understand the Offer (WHAT)** for the following company.
# Inputs
* **Company URL:** \`{{company_url}}\`
* **Target Language of Output:** \`{{language}}\`
* **Region(s) / Markets (optional):** \`{{regions}}\`
* **Product/Solution Focus (optional):** \`{{focus}}\`
# Instructions for Step 1
* Extract product(s)/service(s), core features, differentiation, and relevant value propositions.
* Create a short summary (max. 4 bullet points) of the key findings.
* **Output:** Table with columns: *Product/Solution | Description (12 sentences) | Core Features | Differentiation | Primary Source (URL)*.
* **Format Requirement:** Respond ONLY with the results for this single step. Your response must start with the heading "## Step 1: Offer (WHAT)" and include the short summary and the Markdown table. Do not provide any other explanations.`,
// Step 2: Target Groups
`# Task
Now perform **Step 2 Target Groups (WHO Companies)**.
# Context: Validated results from previous steps
{{previous_steps_data}}
# Instructions for Step 2
* Identify B2B target segments (industries/company types/sizes/regions) based on the given offer.
* **Output:** Table: *Target Industry/Segment | Typical Company Characteristics | Region(s) | Proof of Relevance (URL)*.
* **Format Requirement:** Respond ONLY with the results for this single step. Your response must start with the heading "## Step 2: Target Groups (Companies)" and include the Markdown table.`,
// Step 3: Personas
`# Task
Now perform **Step 3 Personas/Roles (WHO People)**.
# Context: Validated results from previous steps
{{previous_steps_data}}
# Instructions for Step 3
* For each target industry: at least 4 **specific** roles with their area of responsibility and involvement in purchasing (E, I, D, U based on RACI logic). Do **not** invent people; logically derive roles from problem/process context.
* **Output:** Table: *Role (precise) | Area of Responsibility | Why relevant for the product | Buying Involvement (E/I/D/U) | Source/Indication (URL or reference)*.
* **Format Requirement:** Respond ONLY with the results for this single step. Your response must start with the heading "## Step 3: Personas (Roles)".`,
// Step 4: Pain Points
`# Task
Now perform **Step 4 Pain Points per Role (WHY)**.
# Context: Validated results from previous steps
{{previous_steps_data}}
# Instructions for Step 4
* For each role, formulate 35 specific pain points (observations, not features).
* Tag each pain point with a category: **Cost | Time | Risk | Compliance | Quality | Employee Retention.**
* Add an **Impact Estimate (€, h, %)** as a hypothesis.
* **Output:** Table: *Role | Pain Point (specific, measurable/operational) | Category | Impact (Cost, Risk, Time) | Impact Estimate (€, h, %) | Urgency (high/medium/low) | Source/Indication (URL)*.
* **Format Requirement:** Respond ONLY with the results for this single step. Your response must start with the heading "## Step 4: Pain Points per Role".`,
// Step 5: Gains
`# Task
Now perform **Step 5 Gains & Benefits per Role (WHY switch)**.
# Context: Validated results from previous steps
{{previous_steps_data}}
# Instructions for Step 5
* Based on the identified pain points, formulate 2-3 concrete gains (advantages/benefits) for each role.
* Quantify the benefit as a hypothesis (e.g., savings in €, time gained in h, efficiency increase in %).
* **Output:** Table: *Role | Gain (specific benefit) | Quantification (Hypothesis in €, h, %) | Source/Indication (URL)*.
* **Format Requirement:** Respond ONLY with the results for this single step. Your response must start with the heading "## Step 5: Gains & Benefits per Role".`,
// Step 6: Messages
`# Task
Now perform **Step 6 Marketing Message (HOW to speak)**.
# Context: Validated results from previous steps
{{previous_steps_data}}
# Inputs for this step
* **Desired channels for the message:** \`{{channels}}\`
# Instructions for Step 6: Chain-of-Thought Analysis & Copywriting
**Your goal is to create a SEPARATE, specific message for EACH role from Step 3 within EACH target industry from Step 2. The result MUST be a complete matrix (e.g., 3 target industries x 4 roles = 12 unique messages).**
For each combination of **[Target Industry/Segment]** and **[Role]**, perform the following thought process before writing the final message:
1. **Step 6.1 (Analysis): Product-Role Fit.**
* Which product/solution from the "Offer" table (Step 1) is most relevant to the **[Role]**?
* *Example thought:* "For the Customer Service Manager, the scheduling software is more relevant than the mobile app because they are responsible for dispatching."
2. **Step 6.2 (Analysis): Industry Use Case.**
* What are 1-2 typical use cases for the selected product in the **[Target Industry/Segment]**? What does the **[Role]** specifically do with it?
* *Example thought:* "A service technician in mechanical engineering typically uses the mobile app to access maintenance logs and create digital service reports directly on-site with the customer."
3. **Step 6.3 (Analysis): Benefit Quantification.**
* Look at the pain points (Step 4) and gains (Step 5) for the **[Role]**. Which pain point is most urgent, which gain most convincing?
* Derive a concrete KPI relevant to the **[Role]** (e.g., First-Contact Resolution Rate, Time-to-Resolution, plant downtime).
* Formulate the quantifiable benefit from Step 5 in relation to this KPI.
* *Example thought:* "The Maintenance Manager's pain point is 'unplanned plant downtime'. The gain is 'reducing downtime by 15%'. The relevant KPI is 'Overall Equipment Effectiveness (OEE)'. The benefit is increasing OEE through predictive maintenance planning."
4. **Step 6.4 (Synthesis): Formulate Message.**
* Synthesize the findings from 6.1-6.3 into a concise core message (2-3 sentences) following the structure: **Observation (Problem) → Low-threshold solution idea → Product bridge → Quantified benefit.**
* Create variations of this message for the channels: {{channels}}.
# Output Format
Create ONLY the final Markdown table. The thought process (6.1-6.3) is an internal instruction for you and should NOT appear in the output.
* **Table Columns:** *Target Industry/Segment | Role | Core Message (23 sentences) | {{channels}}*.
* **Requirement:** Your response must start with the heading "## Step 6: Messages" and contain ONLY the complete Markdown table.`,
];
export const PROMPTS = {
de: {
SYSTEM_PROMPT: SYSTEM_PROMPT_DE,
STEP_PROMPTS: STEP_PROMPTS_DE,
},
en: {
SYSTEM_PROMPT: SYSTEM_PROMPT_EN,
STEP_PROMPTS: STEP_PROMPTS_EN,
}
};