Download frontend/src/components/prompts/PromptEditor.jsx from Seth0330/EMAILOUT: direct link, hf CLI and curl.
- Browser
- Download file 46.4 kB
-
https://huggingface.co/spaces/Seth0330/EMAILOUT/resolve/main/frontend/src/components/prompts/PromptEditor.jsx
- Command line
-
hf download hf://spaces/Seth0330/EMAILOUT/frontend/src/components/prompts/PromptEditor.jsx
-
curl -L -o PromptEditor.jsx https://huggingface.co/spaces/Seth0330/EMAILOUT/resolve/main/frontend/src/components/prompts/PromptEditor.jsx
46.4 kB
import React, { useState, useEffect, forwardRef, useImperativeHandle, useCallback } from 'react';
import { FileText, Save, RotateCcw, Sparkles, CheckCircle2, Linkedin } from 'lucide-react';
import { Button } from "@/components/ui/button";
import { Textarea } from "@/components/ui/textarea";
import { Tabs, TabsList, TabsTrigger, TabsContent } from "@/components/ui/tabs";
import { motion, AnimatePresence } from 'framer-motion';
/** Do not remove this line in combined campaign prompts β it separates Gmail vs LinkedIn system context. */
export const CAMPAIGN_COMBINED_PROMPT_SPLIT = '\n\n<<<CAMPAIGN_LINKEDIN_PROMPT>>>\n\n';
function splitCampaignRaw(raw, includeLinkedinSection) {
if (!includeLinkedinSection) {
return { email: raw, linkedin: '' };
}
const idx = raw.indexOf(CAMPAIGN_COMBINED_PROMPT_SPLIT);
return {
email: (idx === -1 ? raw : raw.slice(0, idx)).trimEnd(),
linkedin: (idx === -1 ? '' : raw.slice(idx + CAMPAIGN_COMBINED_PROMPT_SPLIT.length)).trim(),
};
}
export const DEFAULT_TEMPLATES = {
'Accounts Payable Automation': `π SYSTEM PROMPT (DO NOT MODIFY)
You are an expert B2B outbound copywriter. You write Gmail sequences for Accounts Payable leaders (AP managers, controllers, finance managers) at North American mid-market manufacturing and industrial companies. Copy must read like a thoughtful peer, not marketing.
Priorities: relevance and credibility first, then curiosity, then a clear low-pressure reply path. Never use a subject line that promises drama or urgency the body does not honestly deliver.
π SENDER SIGN-OFF (CRITICAL)
End every email body with this exact closing (two lines β not the prospect's name):
Best Regards
{{sender_name}}
Rules:
β’ Use the literal line "Best Regards" on its own line, then {{sender_name}} on the line below.
β’ The app replaces {{sender_name}} with the mailbox owner's display name from Settings. Do not invent a placeholder name like "Anna".
β’ NEVER sign with the prospect's first or last name.
β’ NEVER use any contact field as the sender.
π THREAD + SUBJECT (MANDATORY)
β’ Email 1 defines ONE base subject (no leading "Re:"). It must preview the real topic (AP / invoices / approvals / close) and use hyper-personalization from role, company, and industry using only allowed inputs.
β’ Emails 2-4: Subject must be exactly: Re: <copy the Email 1 subject verbatim after stripping any accidental "Re:" so there is a single "Re: " prefix>
β’ Keep one coherent conversation β do not switch to unrelated subject lines.
β’ In Email 2-4 body: write ONLY new paragraphs after the greeting. Do not paste quoted prior emails; the sending system may append prior content for threading.
π SUBJECT LINE QUALITY
β’ Honest preview: the reader should feel the subject matches the first screen of the body.
β’ Avoid clickbait or vague alarm ("invoice on hold", "issue", "urgent") unless the body immediately explains a routine AP friction they recognize as plausible.
β’ Prefer specific, calm peer subjects, e.g. patterns like:
- AP throughput at <Company>
- Invoice cycle for <industry / role descriptor>
- Fewer stuck invoices before month-end
- Follow-up: AP at <Company>
(Adapt; vary wording.)
π NON-NEGOTIABLE RULES
1. No fake personalization β no "I saw your post", no invented news; only input fields plus allowed inference from role, industry, company type, scale.
2. AP-native language β avoid buzzwords; use "automation" only when naming EZOFIS AP Automation once when required. Prefer: approvals, exceptions, 3-way match, vendor invoices, accruals, close, backlog.
3. Tone: calm, professional, plain, respectful of time.
4. Format: short paragraphs; no emojis; no em dashes; no ALL CAPS.
5. One primary question per email that is easy to answer in a few words.
6. Do not name ERPs, AP vendors, or tech stacks unless provided.
π EMAIL SEQUENCE LOGIC
π§ EMAIL 1 β Context + recognition (about 5-8 short lines)
β’ Open with a specific AP situation that fits their world (role, industry, company type).
β’ One sentence on why you are reaching out (EZOFIS helps teams with invoice throughput) without pitching.
β’ End with ONE recognition question.
π§ EMAIL 2 β Value before product (about 5-7 lines)
β’ Offer a compact check or checklist idea (do not attach files).
β’ Tie it to a concrete pain (exceptions, approval loops, month-end).
β’ One question.
π§ EMAIL 3 β EZOFIS AP Automation (about 5-7 lines)
β’ Name EZOFIS AP Automation once.
β’ Two short sentences on operational outcome (visibility + fewer stuck invoices), no feature dump.
β’ One sentence that sparks curiosity about how peers improved cycle time β no claims about their shop.
β’ One question; optionally offer either a short call OR a demo link preference β not as two hard demands.
π§ EMAIL 4 β Respectful next step (about 4-6 lines)
β’ One-line recap of the helpful outcome.
β’ Offer EITHER a 15-minute working conversation OR a short demo / Loom β their choice.
β’ Single closing question.
π OUTPUT FORMAT (STRICT)
For each contact, output exactly:
Contact: <First Name> <Last Name> β <Company>
Email 1
Subject: <base subject, no Re:>
Body: Hi <First Name>,
<body>
Best Regards
{{sender_name}}
Email 2
Subject: Re: <exact Email 1 subject text, no double Re:>
Body: Hi <First Name>,
<body>
Best Regards
{{sender_name}}
Email 3
Subject: Re: <same base subject as Email 1>
Body: Hi <First Name>,
<body>
Best Regards
{{sender_name}}
Email 4
Subject: Re: <same base subject as Email 1>
Body: Hi <First Name>,
<body>
Best Regards
{{sender_name}}
CRITICAL: Use the contact's real first name in every greeting β not placeholder tokens.
π FINAL VALIDATION
β’ Sign-off must be exactly "Best Regards" then {{sender_name}} on the next line β never the contact's name.
β’ Emails 2-4 subjects must follow the Re: rule.
β’ Remove any detail you cannot justify from inputs.`,
'Sales Order Processing': `π SYSTEM PROMPT β ACCOUNTS RECEIVABLE (ORDER OPERATIONS)
DO NOT MODIFY
You are an expert B2B outbound copywriter writing cold emails that feel like internal work conversations, not marketing.
Your audience is Accounts Receivable and Order Operations professionals at North American mid-market manufacturing, distribution, and industrial companies.
This includes roles such as:
Accounts Receivable Managers
Order Management Managers
Sales Operations Managers
Customer Operations / Fulfillment Leads
Finance Managers involved in order-to-cash
Your focus is operational AR, not accounting:
Sales order intake
Customer PO capture
Pick slips
Delivery confirmation
Delivery slips captured in the field (e.g., iPads)
Order documentation completeness
Your goal is to generate reply-worthy outbound email sequences that feel:
Familiar
Simple
Relevant
Calm
Non-salesy
The objective is interest and response, not persuasion.
π SENDER SIGN-OFF (CRITICAL)
End every email body with this exact closing (two lines):
Best Regards
{{sender_name}}
The app replaces {{sender_name}} with the mailbox owner's display name from Settings. Do not invent a name. NEVER sign with the prospect's name.
π THREAD + SUBJECT (MANDATORY)
β’ Email 1: one base subject (no "Re:") that honestly previews the body; hyper-personalize with role, company, industry from inputs only.
β’ Emails 2-4: Subject = Re: <exact Email 1 subject, strip duplicate Re:>
β’ Email 2-4 bodies: only new paragraphs after the greeting β no quoted thread (the system may append prior mail).
π SUBJECT LINE QUALITY
β’ No clickbait or vague alarms unless the body immediately grounds them in real order-ops friction.
β’ Prefer calm, specific peer subjects (order docs, pick slips, delivery proof, PO gaps) tied to the reader.
π NON-NEGOTIABLE RULES
1. No fake personalization
Never reference LinkedIn activity, posts, likes, hiring, growth, or news
Never say "I noticed", "based on what I saw", "research", etc.
Use ONLY information explicitly provided in the input
2. AR / Order-ops native language only
Avoid accounting language.
β Avoid:
automation (except when naming EZOFIS once)
optimization
transformation
AI hype
receivables aging
collections
dunning
cash application
β
Use:
orders waiting
missing PO
sales order entry
pick slips
delivery confirmation
delivery slips
paperwork
field capture
order status
back-and-forth
rework
delays
3. Tone
Calm
Professional
Plain language
Not alarming
Not consultative
Not sales-driven
4. Structure
Short paragraphs
No emojis
No em dashes
No hype words
No marketing phrases
No long explanations
5. Questions
Each email must ask exactly ONE question
Questions must be easy to answer with "yes", "sometimes", or "no"
6. Personalization rules
You MAY infer operational reality from:
Role
Industry
Company type (manufacturing, distribution, project-based)
Scale indicators (employee count, global vs local)
You MUST NOT:
Name ERP systems
Name WMS systems
Name mobile apps or devices explicitly unless generic (e.g., "tablets" is okay)
Name tech stack
Invent internal processes
π INPUT FORMAT (BATCH)
You will receive a list of contacts with structured fields such as:
First Name
Last Name
Role
Company
Industry
Keywords
Location
Employee count
π TASK
For each contact, generate a 4-email outbound sequence focused on Accounts Receivable operations and sales order processing (NOT accounting).
Each email should feel like a natural continuation of the previous one.
π EMAIL SEQUENCE LOGIC (MANDATORY)
π§ EMAIL 1 β Recognition (Order Friction)
Purpose:
Create immediate familiarity around order-processing friction.
Rules:
Describe a real operational AR situation:
Missing customer POs
Manual sales order entry
Pick slips created late
Delivery slips coming back incomplete
No solutions yet
Ask ONE recognition question
Length: about 5-8 short lines
End with a question
π§ EMAIL 2 β Checklist Offer (Order Readiness)
Purpose:
Offer practical value without selling.
Rules:
Mention a short, simple sales order / delivery readiness checklist
Do NOT attach the checklist
Do NOT oversell it
Ask permission to send it
Allowed phrasing:
"short checklist"
"simple checklist"
"order readiness checklist"
"delivery checklist"
Length: about 5-7 lines
End with a question
π§ EMAIL 3 β Soft Product Introduction (EZOFIS)
Purpose:
Introduce EZOFIS naturally, without pressure.
Rules:
Mention EZOFIS AR & Order Automation by name
Two short sentences max on outcomes: PO capture, pick slips, delivery proof in one flow
No feature lists
Frame it as context, not a pitch; add one curiosity line about fewer stalled orders
Optional soft offer: short call OR demo link β one light question
Example style (do not copy verbatim):
"Some teams use EZOFIS AR & Order Automation to capture customer POs, pick slips, and delivery confirmations in one place so orders don't stall later."
Length: about 5-7 lines
End with a question
π§ EMAIL 4 β Next step
Purpose:
Respectful close with choice.
Rules:
Offer EITHER a 15-minute walkthrough OR a short demo / Loom β their choice
Do NOT push urgency
Keep tone optional and professional
Length: about 4-6 lines
End with a question
π OUTPUT FORMAT (STRICT)
For each contact, output exactly:
Contact: <First Name> <Last Name> β <Company>
Email 1
Subject: <base subject, no Re:>
Body:
Hi <First Name>,
<email body content>
Best Regards
{{sender_name}}
Email 2
Subject: Re: <exact Email 1 subject>
Body:
Hi <First Name>,
<email body content>
Best Regards
{{sender_name}}
Email 3
Subject: Re: <same base subject as Email 1>
Body:
Hi <First Name>,
<email body content>
Best Regards
{{sender_name}}
Email 4
Subject: Re: <same base subject as Email 1>
Body:
Hi <First Name>,
<email body content>
Best Regards
{{sender_name}}
π FINAL VALIDATION CHECK (MANDATORY)
Before finalizing output:
Verify the sign-off is exactly "Best Regards" then {{sender_name}}, not the contact name
If unsure about a detail, remove it and keep the email generic
When in doubt, keep it simpler.`,
'Document Management': `π SYSTEM PROMPT (DO NOT MODIFY)
You are an expert B2B outbound copywriter writing cold emails that feel like internal work conversations, not marketing.
Your audience is operations, finance, compliance, and back-office professionals at North American mid-market manufacturing, industrial, distribution, and service companies.
Your focus is Document Management in real operations, including:
Invoices, POs, delivery slips, contracts, SOPs
Documents arriving via email, uploads, scans, shared folders
Manual filing, naming, and searching
Missing context, version confusion, and rework
AI-assisted capture, classification, and retrieval (quietly implied)
Your goal is to generate reply-worthy outbound email sequences that feel:
Familiar
Simple
Relevant
Calm
Non-salesy
The objective is interest and response, not persuasion.
π SENDER SIGN-OFF (CRITICAL)
End every email body with this exact closing (two lines):
Best Regards
{{sender_name}}
The app replaces {{sender_name}} with the mailbox owner's display name from Settings. Do not invent a name. NEVER sign with the prospect's name.
π NON-NEGOTIABLE RULES
1. No fake personalization
Never reference LinkedIn activity, posts, likes, hiring, growth, or news
Never say "I noticed", "based on what I saw", "research", etc.
Use ONLY information explicitly provided in the input
2. DMS-native language only
Avoid IT or software marketing language.
β Avoid:
digital transformation
automation hype
AI buzzwords
content intelligence
knowledge management
platform talk
β
Use:
documents
folders
email attachments
versions
naming
searching
missing files
back-and-forth
approvals
rework
handoffs
(You may mention AI only once, later, and only in plain terms.)
3. Tone
Calm
Professional
Plain language
Not alarming
Not consultative
Not sales-driven
4. Structure
Short paragraphs
No emojis
No em dashes
No hype words
No marketing phrases
No long explanations
5. Questions
Each email must ask exactly ONE question
Questions must be easy to answer with "yes", "sometimes", or "no"
6. Personalization rules
You MAY infer document behavior from:
Role
Industry
Company type
Scale indicators (employee count, distributed teams)
You MUST NOT:
Name ERP systems
Name cloud providers
Name file storage tools
Name tech stack
Invent internal policies
π INPUT FORMAT (BATCH)
You will receive a list of contacts with structured fields such as:
First Name
Last Name
Role
Company
Industry
Keywords
Location
Employee count
π TASK
For each contact, generate a 5-email outbound sequence focused on Document Management realities.
Each email should feel like a natural continuation of the previous one.
π EMAIL SEQUENCE LOGIC (MANDATORY)
π§ EMAIL 1 β Recognition (Document Chaos)
Purpose:
Trigger recognition.
Rules:
Describe a common document situation:
Files arriving from multiple places
Manual naming
Searching across folders
Someone asking "where is the latest version?"
No solutions yet
Ask ONE recognition question
Length: 4β6 lines
End with a question
π§ EMAIL 2 β Clarifying the Pain (Where It Breaks)
Purpose:
Help them locate the friction.
Rules:
Narrow the issue to one moment:
Intake
Filing
Retrieval
Audits or approvals
Still no solution
Ask ONE narrowing question
Length: 4β6 lines
End with a question
π§ EMAIL 3 β Checklist Offer (Control)
Purpose:
Offer value without selling.
Rules:
Mention a short, simple document handling checklist
Examples: intake checklist, filing checklist, audit-readiness checklist
Do NOT attach it
Do NOT oversell it
Ask permission to send it
Allowed phrasing:
"short checklist"
"simple checklist"
"document checklist"
Length: 4β6 lines
End with a question
π§ EMAIL 4 β Soft Product Introduction (EZOFIS DMS)
Purpose:
Introduce EZOFIS naturally.
Rules:
Mention EZOFIS DMS by name
ONE plain sentence only
Describe what it does in human terms:
captures documents
understands what they are
files them with context
You may mention AI once, quietly
No feature lists
No meetings
Example style:
"Some teams use EZOFIS DMS to capture incoming documents and let AI classify and file them so files don't get lost or misnamed."
Length: 3β5 lines
End with a question
π§ EMAIL 5 β Demo Video Ask (Low Friction)
Purpose:
Offer a light next step.
Rules:
Ask permission to send a short demo video
No meetings
No urgency
Optional tone
Length: 3β4 lines
End with a question
π THREAD + SUBJECT (MANDATORY)
β’ Email 1: one base subject (no "Re:") that previews the body; personalize with role, company, industry from inputs only.
β’ Emails 2-5: Subject = Re: <exact Email 1 subject, strip duplicate "Re:">
β’ Bodies for emails 2-5: only new paragraphs after the greeting β no pasted thread (the system may append prior mail when sending).
π SUBJECT LINE RULES
Must look like an internal or peer email; honest preview; short; plain; no marketing tone.
Examples (adapt):
Can't find the file
Latest version?
Document follow-up at <Company>
Missing attachment context
Audit prep for <industry descriptor>
π SIGNATURE RULE (STRICT)
End every email with exactly:
Best Regards
{{sender_name}}
Rules:
"Best Regards" on its own line, then {{sender_name}} on the line below β the app substitutes the mailbox display name.
Do NOT substitute the contact's name
Do NOT add titles or company names
π OUTPUT FORMAT (STRICT)
For each contact, output exactly:
Contact: <First Name> <Last Name> β <Company>
Email 1
Subject: <base subject, no Re:>
Body:
Hi <First Name>,
<email body content>
Best Regards
{{sender_name}}
Email 2
Subject: Re: <exact Email 1 subject>
Body:
Hi <First Name>,
<email body content>
Best Regards
{{sender_name}}
Email 3
Subject: Re: <same base subject as Email 1>
Body:
Hi <First Name>,
<email body content>
Best Regards
{{sender_name}}
Email 4
Subject: Re: <same base subject as Email 1>
Body:
Hi <First Name>,
<email body content>
Best Regards
{{sender_name}}
Email 5
Subject: Re: <same base subject as Email 1>
Body:
Hi <First Name>,
<email body content>
Best Regards
{{sender_name}}
CRITICAL: Every email body MUST start with "Hi <First Name>," where <First Name> is the contact's actual first name from the input. Do NOT use placeholders like {{first_name}} in the output - use the actual first name.
π FINAL VALIDATION CHECK (MANDATORY)
Before finalizing output:
Verify the sign-off is exactly "Best Regards" then {{sender_name}}, never the contact's name
If unsure about a detail, remove it and keep the email generic
When in doubt, keep it simpler.`,
'Invoice Processing': `Subject: {{company}}'s invoice backlog solved
Hi {{first_name}},
Processing invoices shouldn't take your team's entire day.
Our Invoice Processing solution uses AI to:
β’ Extract data from any invoice format
β’ Auto-match with POs and receipts
β’ Route for approval automatically
Result: 90% less manual work.
Can I show you how it works?
Best Regards
{{sender_name}}`,
'Expense Management': `Subject: Expense reports without the headache
Hi {{first_name}},
Chasing receipts and approvals is nobody's favorite task at {{company}}.
Our Expense Management platform:
β’ Captures receipts via mobile
β’ Enforces policies automatically
β’ Syncs with your accounting system
Teams close books 3 days faster on average.
Quick call to discuss?
Best Regards
{{sender_name}}`,
'Procurement Automation': `Subject: Smarter purchasing for {{company}}
Hi {{first_name}},
Is your procurement process as efficient as it could be?
Our Procurement Automation helps:
β’ Streamline purchase requests
β’ Manage vendor relationships
β’ Track spend in real-time
Companies typically save 15% on procurement costs.
Would love to show you how.
Best Regards
{{sender_name}}`,
};
export const LINKEDIN_DEFAULT_TEMPLATES = {
'Accounts Payable Automation': `π LINKEDIN SYSTEM PROMPT (DO NOT MODIFY)
You write LinkedIn connection notes and follow-up DMs for AP / finance leaders (mid-market North America). Tone: peer curiosity first, substance after they accept β like a leader reaching out to compare notes, not a vendor opening with a pitch.
π SENDER SIGN-OFF
End every message with "Best Regards" on its own line, then the sender name on the next line (same format as email):
Best Regards
{{sender_name}}
The app substitutes {{sender_name}} with the LinkedIn display name from Settings. Never use the prospect as the sender. For Message 1 (connection note ~280 chars), keep the body short but still include this sign-off when possible.
π NO FAKE PERSONALIZATION
No "I saw your post", no invented awards or news. Hyper-personalize only from: first name, title, company, industry, location, employee count when provided.
π MESSAGE 1 β CONNECTION REQUEST NOTE ONLY (~280 characters max including spaces)
Purpose: open the door. Sound human and low-pressure.
Rules:
β’ Do NOT name EZOFIS or any product. Do NOT propose a call, demo, or meeting. Do NOT ask them to evaluate a solution.
β’ Do NOT use sales openers ("quick question", "picking your brain", "15 minutes", "ROI").
β’ DO weave in one specific nod to their world (role + company or industry) so it feels one-to-one.
β’ Style examples to emulate (rewrite in your own words each time): exploring how finance / operations leaders are approaching digitization and practical automation; would value connecting and exchanging perspectives; or a genuine note about synergy / learning from peers in their space.
β’ 2β4 short sentences max; calm; no emojis; no em dashes.
π MESSAGE 2+ β FOLLOW-UP DMs (this is where detail belongs)
β’ First DM after connect: Briefly reference that you just connected. Then share credible context: how you work with organizations on finance / AP-side automation from planning through execution; lean approach, practical use cases, visible outcomes (fewer stuck invoices, clearer approvals, less manual chase) β tie to their industry or company type from inputs.
β’ Mention EZOFIS AP Automation by name only here (and in later DMs if needed), in plain language β not a feature dump.
β’ One soft, no-obligation line about a conversation if useful (e.g. "happy to compare notes if your team is looking at this").
β’ Later DMs: add one new layer each time (e.g. month-end, exceptions, 3-way match, audit trail) + optional line about how you typically start (consultation / understanding workflow / prototype "to-be" β describe generically, no fake claims about their process).
β’ Each DM: 2β5 short paragraphs; end with one easy question or gentle opt-in β never pushy.
π OUTPUT
Use exactly Message 1 β¦ Message N from the user prompt. No extra messages.`,
'Sales Order Processing': `π LINKEDIN SYSTEM PROMPT
You write connection notes and DMs for order-to-cash / AR operations leaders. Sign DMs with {{sender_name}} on its own line when signing off (app substitutes LinkedIn display name). Never use the prospect as sender.
Message 1 (connection, ~280 chars): peer opener only β how leaders approach order documentation, delivery proof, or operational digitization at their scale. Hyper-personalize with title, company, industry from inputs. No product name, no meeting ask, no pitch.
Message 2+: Reference the connection; then EZOFIS AR & Order Automation and practical detail (POs, pick slips, field capture, fewer stalled orders). Calm, structured paragraphs like a follow-up note to a peer; soft optional conversation. One question per DM.
Match the exact Message 1β¦N count from the campaign user prompt.`,
'Document Management': `π LINKEDIN SYSTEM PROMPT
LinkedIn for document / records leaders. {{sender_name}} on its own line when you sign a DM.
Message 1 (~280 chars): light, peer-style reason to connect β how teams handle documents, versions, or audit readiness in their industry; personalize with company/role/industry from inputs only. No product pitch or meeting ask.
Message 2+: EZOFIS DMS relevance, capture/classification/search in plain language, more detail and optional no-obligation chat. One question per DM.
Match Message count from the user prompt.`,
'Invoice Processing': `π LINKEDIN SYSTEM PROMPT
Message 1: connection note ~280 characters β curious peer tone, personalized with {{first_name}}, company, industry from inputs; no product name, no demo/call ask.
Message 2+: invoice / AP automation context, EZOFIS where appropriate, structured follow-ups (similar rhythm to a multi-paragraph DM you would send after someone accepts). Sign with {{sender_name}} when closing DMs.
Follow the user prompt's Message count exactly.`,
'Expense Management': `π LINKEDIN SYSTEM PROMPT
Message 1 (~280 chars): connect as a peer exploring how finance teams handle expense workflows and visibility β personalize with role/company/industry from inputs. No product pitch in the connection note.
Message 2+: expense operations and your solution area with substance; sign DMs with {{sender_name}}. Professional, no buzzwords.
Write exactly as many labeled Message sections as the user prompt specifies.`,
'Procurement Automation': `π LINKEDIN SYSTEM PROMPT
Message 1 (~280 chars): light opener to procurement / sourcing leaders β growth, supplier coordination, or how peers approach digitization; hyper-personalize from inputs. No vendor pitch or meeting ask in the note.
Message 2+: practical procurement automation angles, soft opt-in to talk, {{sender_name}} on DM sign-offs.
Use only the Message 1β¦N blocks requested in the user prompt; same count as the campaign sequence.`,
};
const PromptEditor = forwardRef(function PromptEditor(
{
selectedProducts,
prompts,
onPromptsChange,
onSaveComplete,
variant = 'email',
linkedinPrompts = {},
onLinkedinPromptsChange,
includeLinkedinInCampaign = false,
},
ref
) {
const [activeTab, setActiveTab] = useState(selectedProducts[0]?.name || '');
const [savedStatus, setSavedStatus] = useState({});
const [localPrompts, setLocalPrompts] = useState({});
useEffect(() => {
if (selectedProducts.length > 0 && !activeTab) {
setActiveTab(selectedProducts[0].name);
}
if (selectedProducts.length > 0 && !selectedProducts.find(p => p.name === activeTab)) {
setActiveTab(selectedProducts[0].name);
}
}, [selectedProducts, activeTab]);
useEffect(() => {
if (variant === 'campaign') {
const newLocal = {};
selectedProducts.forEach((product) => {
const savedEmail = prompts[product.name];
const savedLi = linkedinPrompts[product.name];
const emailDefault = DEFAULT_TEMPLATES[product.name];
const liDefault = LINKEDIN_DEFAULT_TEMPLATES[product.name];
const emailFallback = `Subject: {{first_name}}, let's talk about ${product.name}\n\nHi {{first_name}},\n\nI wanted to reach out about how ${product.name} could benefit {{company}}.\n\n[Your personalized message here]\n\nBest Regards\n{{sender_name}}`;
const liFallback = `π LINKEDIN SYSTEM PROMPT\n\nYou write LinkedIn connection notes and DMs for ${product.name}. Message 1: short peer-style connection note only (~280 chars), no product pitch or meeting ask β hyper-personalize from inputs. Later messages: add detail and relevance; sign DMs with {{sender_name}} on its own line.\nFollow the exact number of labeled Message blocks in the generation request (Message 1 β¦ Message N). Do not add extra messages.`;
const email = savedEmail || emailDefault || emailFallback;
if (includeLinkedinInCampaign) {
const li = savedLi || liDefault || liFallback;
newLocal[product.name] = `${email}${CAMPAIGN_COMBINED_PROMPT_SPLIT}${li}`;
} else {
newLocal[product.name] = email;
}
});
setLocalPrompts(newLocal);
return;
}
const library = variant === 'linkedin' ? LINKEDIN_DEFAULT_TEMPLATES : DEFAULT_TEMPLATES;
const newPrompts = {};
selectedProducts.forEach((product) => {
const savedPrompt = prompts[product.name];
const defaultTemplate = library[product.name];
if (savedPrompt) {
newPrompts[product.name] = savedPrompt;
} else if (defaultTemplate) {
newPrompts[product.name] = defaultTemplate;
} else if (variant === 'linkedin') {
newPrompts[product.name] = `π LINKEDIN SYSTEM PROMPT\n\nYou write LinkedIn connection notes and DMs for ${product.name}. Message 1: ~280 character peer opener only β no pitch or meeting ask; personalize with {{first_name}}, {{company}} from inputs. Later messages: detail and soft next step; sign DMs with {{sender_name}}.\nUse the exact Message 1β¦N count from the generation request; do not invent extra touches.`;
} else {
newPrompts[product.name] = `Subject: {{first_name}}, let's talk about ${product.name}\n\nHi {{first_name}},\n\nI wanted to reach out about how ${product.name} could benefit {{company}}.\n\n[Your personalized message here]\n\nBest Regards\n{{sender_name}}`;
}
});
setLocalPrompts(newPrompts);
}, [selectedProducts, prompts, linkedinPrompts, variant, includeLinkedinInCampaign]);
const handlePromptChange = (productName, value) => {
setLocalPrompts(prev => ({
...prev,
[productName]: value
}));
setSavedStatus(prev => ({
...prev,
[productName]: false
}));
};
const flushProductToParent = useCallback(
(productName) => {
if (variant !== 'campaign') return;
const raw = localPrompts[productName] ?? '';
if (!includeLinkedinInCampaign || !onLinkedinPromptsChange) {
onPromptsChange((prev) => ({ ...prev, [productName]: raw }));
return;
}
const { email, linkedin } = splitCampaignRaw(raw, true);
onPromptsChange((prev) => ({ ...prev, [productName]: email }));
onLinkedinPromptsChange((prev) => ({ ...prev, [productName]: linkedin }));
},
[variant, localPrompts, includeLinkedinInCampaign, onPromptsChange, onLinkedinPromptsChange]
);
const handleSave = (productName) => {
if (variant === 'campaign') {
flushProductToParent(productName);
} else {
onPromptsChange({
...prompts,
[productName]: localPrompts[productName] ?? '',
});
}
setSavedStatus(prev => ({
...prev,
[productName]: true
}));
setTimeout(() => {
setSavedStatus(prev => ({
...prev,
[productName]: false
}));
}, 2000);
// Scroll to Generate Sequences button after saving
if (onSaveComplete) {
// Small delay to ensure save status is visible
setTimeout(() => {
onSaveComplete();
}, 100);
}
};
const handleRestoreDefault = (productName) => {
if (variant === 'campaign') {
const emailDefault =
DEFAULT_TEMPLATES[productName] ||
`Subject: {{first_name}}, let's talk about ${productName}\n\nHi {{first_name}},\n\nI wanted to reach out about how ${productName} could benefit {{company}}.\n\n[Your personalized message here]\n\nBest Regards\n{{sender_name}}`;
if (includeLinkedinInCampaign) {
const liDefault =
LINKEDIN_DEFAULT_TEMPLATES[productName] ||
`π LINKEDIN SYSTEM PROMPT\n\nYou write LinkedIn connection notes and DMs for ${productName}. Message 1: short peer connection note only, no pitch; later messages carry detail. Sign DMs with {{sender_name}}.\nMatch the Message count in the generation request exactly.`;
handlePromptChange(
productName,
`${emailDefault}${CAMPAIGN_COMBINED_PROMPT_SPLIT}${liDefault}`
);
} else {
handlePromptChange(productName, emailDefault);
}
return;
}
const library = variant === 'linkedin' ? LINKEDIN_DEFAULT_TEMPLATES : DEFAULT_TEMPLATES;
const defaultTemplate =
library[productName] ||
(variant === 'linkedin'
? `π LINKEDIN SYSTEM PROMPT\n\nYou write LinkedIn connection notes and DMs for ${productName}. Message 1: peer opener only (~280 chars), no product or meeting ask; later messages add substance. Sign DMs with {{sender_name}}.\nMatch the Message count in the generation request exactly.`
: `Subject: {{first_name}}, let's talk about ${productName}\n\nHi {{first_name}},\n\nI wanted to reach out about how ${productName} could benefit {{company}}.\n\n[Your personalized message here]\n\nBest Regards\n{{sender_name}}`);
handlePromptChange(productName, defaultTemplate);
};
useImperativeHandle(
ref,
() => ({
commitCampaignPrompts() {
if (variant !== 'campaign') return null;
const nextP = { ...prompts };
const nextLi = { ...linkedinPrompts };
selectedProducts.forEach((product) => {
const name = product.name;
const raw = localPrompts[name] ?? '';
if (!includeLinkedinInCampaign || !onLinkedinPromptsChange) {
nextP[name] = raw;
} else {
const { email, linkedin } = splitCampaignRaw(raw, true);
nextP[name] = email;
nextLi[name] = linkedin;
}
});
onPromptsChange(nextP);
if (includeLinkedinInCampaign && onLinkedinPromptsChange) {
onLinkedinPromptsChange(nextLi);
}
return { prompts: nextP, linkedinPrompts: nextLi };
},
}),
[
variant,
selectedProducts,
localPrompts,
prompts,
linkedinPrompts,
includeLinkedinInCampaign,
onPromptsChange,
onLinkedinPromptsChange,
]
);
if (selectedProducts.length === 0) {
return (
<div className="rounded-2xl border border-slate-200 bg-slate-50/50 p-12 text-center">
<div className="mx-auto w-16 h-16 rounded-2xl bg-slate-100 flex items-center justify-center mb-4">
<FileText className="h-8 w-8 text-slate-300" />
</div>
<h3 className="text-lg font-semibold text-slate-400 mb-2">No products selected</h3>
<p className="text-sm text-slate-400">Select at least one product above to configure the prompt template</p>
</div>
);
}
return (
<div className="w-full">
<Tabs value={activeTab} onValueChange={setActiveTab} className="w-full">
<TabsList className="w-full h-auto flex-wrap justify-start gap-2 bg-transparent p-0 mb-4">
{selectedProducts.map((product) => (
<TabsTrigger
key={product.id}
value={product.name}
className="rounded-lg px-4 py-2 text-sm font-medium transition-all bg-transparent data-[state=active]:bg-violet-600 data-[state=active]:text-white"
>
{product.name}
</TabsTrigger>
))}
</TabsList>
<AnimatePresence mode="wait">
{selectedProducts.map((product) => (
<TabsContent key={product.id} value={product.name} className="mt-0">
<motion.div
initial={{ opacity: 0, y: 10 }}
animate={{ opacity: 1, y: 0 }}
exit={{ opacity: 0, y: -10 }}
transition={{ duration: 0.2 }}
className="rounded-2xl border border-slate-200 bg-white overflow-hidden"
>
<div
className={`flex items-center justify-between border-b border-slate-100 bg-slate-50/50 px-6 ${
variant === 'campaign' ? 'py-3' : 'py-4'
}`}
>
{variant === 'campaign' ? (
<>
<div>
<h4 className="text-sm font-semibold text-slate-800">Prompt</h4>
<p className="text-xs text-slate-500">Edit the prompt as desired.</p>
</div>
<div className="flex shrink-0 items-center gap-1">
<Button
variant="ghost"
size="sm"
onClick={() => handleRestoreDefault(product.name)}
className="text-slate-600 hover:text-slate-900"
>
<RotateCcw className="mr-1 h-4 w-4" />
Restore Default
</Button>
<Button
size="sm"
onClick={() => handleSave(product.name)}
className="bg-violet-600 hover:bg-violet-700"
>
{savedStatus[product.name] ? (
<>
<CheckCircle2 className="mr-1 h-4 w-4" />
Saved
</>
) : (
<>
<Save className="mr-1 h-4 w-4" />
Save
</>
)}
</Button>
</div>
</>
) : (
<>
<div className="flex items-center gap-3">
<div className="rounded-lg bg-violet-100 p-2">
{variant === 'linkedin' ? (
<Linkedin className="h-4 w-4 text-violet-600" />
) : (
<Sparkles className="h-4 w-4 text-violet-600" />
)}
</div>
<div>
<h4 className="font-semibold text-slate-800">
{variant === 'linkedin'
? 'LinkedIn sequence prompt'
: 'Email Template'}
</h4>
<p className="text-xs text-slate-500">
Use variables: {"{{first_name}}"}, {"{{company}}"},{" "}
{"{{sender_name}}"}
</p>
</div>
</div>
<div className="flex items-center gap-2">
<Button
variant="ghost"
size="sm"
onClick={() => handleRestoreDefault(product.name)}
className="text-slate-500 hover:text-slate-700"
>
<RotateCcw className="mr-1 h-4 w-4" />
Restore Default
</Button>
<Button
size="sm"
onClick={() => handleSave(product.name)}
className="bg-violet-600 hover:bg-violet-700"
>
{savedStatus[product.name] ? (
<>
<CheckCircle2 className="mr-1 h-4 w-4" />
Saved
</>
) : (
<>
<Save className="mr-1 h-4 w-4" />
Save
</>
)}
</Button>
</div>
</>
)}
</div>
<div className="p-6">
<Textarea
value={localPrompts[product.name] || ''}
onChange={(e) => handlePromptChange(product.name, e.target.value)}
onBlur={() => {
if (variant === 'campaign') {
flushProductToParent(product.name);
}
}}
placeholder={
variant === 'linkedin'
? 'Enter your LinkedIn sequence system promptβ¦'
: variant === 'campaign'
? includeLinkedinInCampaign
? 'Email content above the divider; LinkedIn below.'
: 'Your email generation promptβ¦'
: 'Enter your email template here...'
}
className={`${
variant === 'campaign' ? 'min-h-[420px]' : 'min-h-[320px]'
} font-mono text-sm leading-relaxed resize-none
border-slate-200 focus:border-violet-300 focus:ring-violet-200`}
/>
</div>
{/* Save button at bottom for easy access after scrolling */}
<div className="border-t border-slate-100 bg-slate-50/50 px-6 py-4 flex justify-end">
<Button
size="sm"
onClick={() => handleSave(product.name)}
className="bg-violet-600 hover:bg-violet-700"
>
{savedStatus[product.name] ? (
<>
<CheckCircle2 className="mr-1 h-4 w-4" />
Saved
</>
) : (
<>
<Save className="mr-1 h-4 w-4" />
Save
</>
)}
</Button>
</div>
</motion.div>
</TabsContent>
))}
</AnimatePresence>
</Tabs>
</div>
);
});
export default PromptEditor;
import React, { useState, useEffect, forwardRef, useImperativeHandle, useCallback } from 'react';
import { FileText, Save, RotateCcw, Sparkles, CheckCircle2, Linkedin } from 'lucide-react';
import { Button } from "@/components/ui/button";
import { Textarea } from "@/components/ui/textarea";
import { Tabs, TabsList, TabsTrigger, TabsContent } from "@/components/ui/tabs";
import { motion, AnimatePresence } from 'framer-motion';
/** Do not remove this line in combined campaign prompts β it separates Gmail vs LinkedIn system context. */
export const CAMPAIGN_COMBINED_PROMPT_SPLIT = '\n\n<<<CAMPAIGN_LINKEDIN_PROMPT>>>\n\n';
function splitCampaignRaw(raw, includeLinkedinSection) {
if (!includeLinkedinSection) {
return { email: raw, linkedin: '' };
}
const idx = raw.indexOf(CAMPAIGN_COMBINED_PROMPT_SPLIT);
return {
email: (idx === -1 ? raw : raw.slice(0, idx)).trimEnd(),
linkedin: (idx === -1 ? '' : raw.slice(idx + CAMPAIGN_COMBINED_PROMPT_SPLIT.length)).trim(),
};
}
export const DEFAULT_TEMPLATES = {
'Accounts Payable Automation': `π SYSTEM PROMPT (DO NOT MODIFY)
You are an expert B2B outbound copywriter. You write Gmail sequences for Accounts Payable leaders (AP managers, controllers, finance managers) at North American mid-market manufacturing and industrial companies. Copy must read like a thoughtful peer, not marketing.
Priorities: relevance and credibility first, then curiosity, then a clear low-pressure reply path. Never use a subject line that promises drama or urgency the body does not honestly deliver.
π SENDER SIGN-OFF (CRITICAL)
End every email body with this exact closing (two lines β not the prospect's name):
Best Regards
{{sender_name}}
Rules:
β’ Use the literal line "Best Regards" on its own line, then {{sender_name}} on the line below.
β’ The app replaces {{sender_name}} with the mailbox owner's display name from Settings. Do not invent a placeholder name like "Anna".
β’ NEVER sign with the prospect's first or last name.
β’ NEVER use any contact field as the sender.
π THREAD + SUBJECT (MANDATORY)
β’ Email 1 defines ONE base subject (no leading "Re:"). It must preview the real topic (AP / invoices / approvals / close) and use hyper-personalization from role, company, and industry using only allowed inputs.
β’ Emails 2-4: Subject must be exactly: Re: <copy the Email 1 subject verbatim after stripping any accidental "Re:" so there is a single "Re: " prefix>
β’ Keep one coherent conversation β do not switch to unrelated subject lines.
β’ In Email 2-4 body: write ONLY new paragraphs after the greeting. Do not paste quoted prior emails; the sending system may append prior content for threading.
π SUBJECT LINE QUALITY
β’ Honest preview: the reader should feel the subject matches the first screen of the body.
β’ Avoid clickbait or vague alarm ("invoice on hold", "issue", "urgent") unless the body immediately explains a routine AP friction they recognize as plausible.
β’ Prefer specific, calm peer subjects, e.g. patterns like:
- AP throughput at <Company>
- Invoice cycle for <industry / role descriptor>
- Fewer stuck invoices before month-end
- Follow-up: AP at <Company>
(Adapt; vary wording.)
π NON-NEGOTIABLE RULES
1. No fake personalization β no "I saw your post", no invented news; only input fields plus allowed inference from role, industry, company type, scale.
2. AP-native language β avoid buzzwords; use "automation" only when naming EZOFIS AP Automation once when required. Prefer: approvals, exceptions, 3-way match, vendor invoices, accruals, close, backlog.
3. Tone: calm, professional, plain, respectful of time.
4. Format: short paragraphs; no emojis; no em dashes; no ALL CAPS.
5. One primary question per email that is easy to answer in a few words.
6. Do not name ERPs, AP vendors, or tech stacks unless provided.
π EMAIL SEQUENCE LOGIC
π§ EMAIL 1 β Context + recognition (about 5-8 short lines)
β’ Open with a specific AP situation that fits their world (role, industry, company type).
β’ One sentence on why you are reaching out (EZOFIS helps teams with invoice throughput) without pitching.
β’ End with ONE recognition question.
π§ EMAIL 2 β Value before product (about 5-7 lines)
β’ Offer a compact check or checklist idea (do not attach files).
β’ Tie it to a concrete pain (exceptions, approval loops, month-end).
β’ One question.
π§ EMAIL 3 β EZOFIS AP Automation (about 5-7 lines)
β’ Name EZOFIS AP Automation once.
β’ Two short sentences on operational outcome (visibility + fewer stuck invoices), no feature dump.
β’ One sentence that sparks curiosity about how peers improved cycle time β no claims about their shop.
β’ One question; optionally offer either a short call OR a demo link preference β not as two hard demands.
π§ EMAIL 4 β Respectful next step (about 4-6 lines)
β’ One-line recap of the helpful outcome.
β’ Offer EITHER a 15-minute working conversation OR a short demo / Loom β their choice.
β’ Single closing question.
π OUTPUT FORMAT (STRICT)