File size: 28,244 Bytes
5301ae9
 
 
 
 
 
 
 
6f3bb09
5301ae9
6f3bb09
96e8e35
6f3bb09
96e8e35
 
 
6f3bb09
96e8e35
 
6f3bb09
 
 
 
 
 
 
 
 
 
 
 
 
96e8e35
 
5301ae9
5940a39
6f3bb09
 
 
5301ae9
6f3bb09
 
 
5301ae9
5940a39
96e8e35
 
 
 
 
 
5301ae9
5940a39
96e8e35
 
 
 
 
 
5940a39
 
96e8e35
 
 
 
6f3bb09
 
 
 
 
 
 
 
 
 
 
 
96e8e35
 
 
 
 
 
 
 
 
 
 
 
 
 
5940a39
96e8e35
 
5940a39
96e8e35
5940a39
6f3bb09
96e8e35
6f3bb09
96e8e35
 
6f3bb09
 
 
96e8e35
 
6f3bb09
96e8e35
6f3bb09
96e8e35
6f3bb09
96e8e35
 
6f3bb09
 
 
 
96e8e35
6f3bb09
96e8e35
 
6f3bb09
96e8e35
6f3bb09
96e8e35
6f3bb09
96e8e35
 
6f3bb09
 
 
 
 
96e8e35
6f3bb09
96e8e35
 
6f3bb09
96e8e35
6f3bb09
96e8e35
6f3bb09
96e8e35
 
6f3bb09
 
 
 
96e8e35
 
6f3bb09
96e8e35
 
 
6f3bb09
 
 
5940a39
 
 
96e8e35
5940a39
 
96e8e35
 
6f3bb09
5940a39
6f3bb09
 
 
 
 
 
 
 
5940a39
96e8e35
 
 
 
5940a39
96e8e35
5940a39
efc3d9b
 
 
 
 
 
96e8e35
5940a39
efc3d9b
 
 
 
 
 
96e8e35
5940a39
efc3d9b
 
 
 
 
 
96e8e35
5940a39
efc3d9b
 
 
 
 
 
 
 
5940a39
6f3bb09
96e8e35
6f3bb09
 
 
 
96e8e35
d4098d5
 
775fa0e
d4098d5
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
5940a39
5301ae9
acf4199
5301ae9
acf4199
 
 
 
 
 
 
 
 
 
 
 
 
 
 
5301ae9
acf4199
5301ae9
acf4199
 
5301ae9
acf4199
 
 
 
 
5301ae9
acf4199
5301ae9
acf4199
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
5301ae9
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
3fdd55d
5301ae9
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
acf4199
 
 
 
 
 
 
 
 
 
 
 
 
5301ae9
 
acf4199
5301ae9
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
3fdd55d
 
 
 
 
 
 
 
5301ae9
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
5df542b
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
5301ae9
 
 
 
 
 
 
 
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
610
611
612
613
614
615
616
617
618
619
620
621
622
623
624
625
626
627
628
629
630
631
632
633
634
635
636
637
638
639
640
641
642
643
644
645
646
647
648
649
650
651
652
653
654
655
656
657
658
659
660
661
662
663
664
665
666
667
668
669
670
671
672
673
674
675
676
677
678
679
680
681
682
683
684
685
686
687
688
689
690
691
692
693
694
695
696
697
698
699
700
701
702
703
704
705
706
707
708
709
710
711
712
713
714
715
716
717
718
719
720
721
722
723
724
725
726
727
728
729
730
731
732
733
734
735
736
737
738
739
740
741
742
743
744
745
746
747
748
749
750
751
752
753
754
755
756
757
758
759
760
761
762
763
764
765
766
767
768
769
770
771
772
773
774
775
776
777
778
779
780
781
782
783
784
785
786
787
788
789
790
791
792
793
794
795
796
797
798
799
800
801
802
803
804
805
806
807
808
809
810
811
812
813
814
815
816
817
818
819
820
821
822
823
824
825
826
827
828
829
830
831
832
833
834
835
836
837
838
839
840
841
842
843
844
845
846
847
848
849
850
851
852
853
854
855
856
857
858
859
860
861
862
863
864
865
866
867
868
869
870
871
872
873
874
875
876
877
878
879
880
881
882
883
884
885
886
887
888
889
890
891
892
893
894
895
896
897
898
899
900
901
902
903
904
905
906
907
908
909
910
911
912
913
914
915
916
917
918
919
920
921
922
923
924
925
926
927
928
929
930
931
932
933
934
935
936
937
938
939
940
941
942
943
944
945
946
947
948
949
950
951
952
953
954
955
956
957
958
959
960
961
962
963
964
965
966
967
968
969
970
971
972
973
974
975
import React, { useState, useEffect } from 'react';
import { FileText, Save, RotateCcw, Sparkles, CheckCircle2 } 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';

const DEFAULT_TEMPLATES = {
    'Accounts Payable Automation': `πŸ”’ 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 Accounts Payable professionals (Accounts Payable Managers, Finance Managers, Controllers) at North American mid-market manufacturing and industrial companies.
Your goal is to generate reply-worthy AP email sequences that feel:
β€’ Familiar
β€’ Simple
β€’ Relevant
β€’ Calm
β€’ Non-salesy

The objective is interest and response, not persuasion.

πŸ”’ SENDER IDENTITY (CRITICAL – FIXES SIGNATURE BUG)

The sender of all emails is a fixed identity.

Sender first name: Anna

Rules:
β€’ The sender name must ALWAYS be exactly: Anna
β€’ NEVER use the contact's first name, last name, or any contact field as the sender
β€’ NEVER infer the sender from the contact
β€’ If there is ambiguity, default to Anna

πŸ”’ 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. AP-native language only
   β€’ Avoid words like: workflow, automation (except when naming EZOFIS once), optimization, transformation, AI hype
   β€’ Use words like: waiting, on hold, approvals, receiving, matching, backup, follow-ups, status

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, service, project-based)
β€’ Scale indicators (employee count, global vs local)

You MUST NOT:
β€’ Name ERP systems
β€’ Name AP tools
β€’ 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 only on Accounts Payable.
Each email should feel like a natural continuation of the previous one.

πŸ”’ EMAIL SEQUENCE LOGIC (MANDATORY)

πŸ“§ EMAIL 1 – Recognition

Purpose: Create immediate familiarity.

Rules:
β€’ Describe a real AP situation relevant to the contact's environment
β€’ No solutions yet
β€’ Ask ONE recognition question

Length: 4-6 lines
End with a question

πŸ“§ EMAIL 2 – Checklist Offer

Purpose: Offer practical value without selling.

Rules:
β€’ Mention a short, simple AP checklist
β€’ Do NOT attach the checklist
β€’ Do NOT oversell it
β€’ Ask permission to send it

Allowed phrasing: "short checklist", "simple checklist", "AP checklist"

Length: 4-6 lines
End with a question

πŸ“§ EMAIL 3 – Soft Product Introduction (EZOFIS)

Purpose: Introduce EZOFIS without pressure.

Rules:
β€’ Mention EZOFIS AP Automation by name
β€’ Describe it in ONE plain sentence
β€’ No feature lists
β€’ No meeting requests
β€’ Frame it as context, not a pitch

Example style: "Some teams use EZOFIS AP Automation to keep invoice context and approvals together so fewer items get stuck."

Length: 3-5 lines
End with a question

πŸ“§ EMAIL 4 – Demo Video Ask

Purpose: Offer a low-friction next step.

Rules:
β€’ Ask permission to send a short demo video
β€’ Do NOT ask for a meeting
β€’ Do NOT push urgency
β€’ Keep tone optional and professional

Length: 3-4 lines
End with a question

πŸ”’ SUBJECT LINE RULES

β€’ Must look like an internal or peer email
β€’ Short and plain
β€’ No marketing language

Examples:
β€’ Invoice on hold
β€’ Waiting on backup
β€’ Approval follow-ups
β€’ Receiving confirmation
β€’ AP delays

πŸ”’ SIGNATURE RULE (STRICT)

End every email with exactly:

Anna

Rules:
β€’ Do NOT vary the sender 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: <subject line>
Body: Hi <First Name>,

<email body content>

Anna

Email 2
Subject: <subject line>
Body: Hi <First Name>,

<email body content>

Anna

Email 3
Subject: <subject line>
Body: Hi <First Name>,

<email body content>

Anna

Email 4
Subject: <subject line>
Body: Hi <First Name>,

<email body content>

Anna

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 sender name is NOT the same as the contact name
β€’ If it matches, replace it with Anna
β€’ If unsure about a detail, remove it and keep the email generic

When in doubt, keep it simpler.`,
    
    '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 IDENTITY (CRITICAL – FIXES SIGNATURE BUG)
The sender of all emails is a fixed identity.
Sender first name: Anna
Rules:
The sender name must ALWAYS be exactly: Anna
NEVER use the contact's first name, last name, or any contact field as the sender
NEVER infer the sender from the contact
If there is ambiguity, default to Anna
πŸ”’ 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: 4–6 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: 4–6 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
Describe it in ONE plain sentence
Focus on:
Capturing POs
Digitizing pick slips
Capturing delivery slips in the field
No feature lists
No meeting requests
Frame it as context, not a pitch
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: 3–5 lines
End with a question
πŸ“§ EMAIL 4 – Demo Video Ask
Purpose:
Offer a low-friction next step.
Rules:
Ask permission to send a short demo video
Do NOT ask for a meeting
Do NOT push urgency
Keep tone optional and professional
Length: 3–4 lines
End with a question
πŸ”’ SUBJECT LINE RULES
Must look like an internal or peer-to-peer work email
Short and plain
No marketing language
Examples:
Missing customer PO
Order waiting
Pick slip issue
Delivery confirmation
Order paperwork
πŸ”’ SIGNATURE RULE (STRICT)
End every email with exactly:
Anna
Rules:
Do NOT vary the sender 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: <subject line>
Body:
Hi <First Name>,

<email body content>

Anna

Email 2
Subject: <subject line>
Body:
Hi <First Name>,

<email body content>

Anna

Email 3
Subject: <subject line>
Body:
Hi <First Name>,

<email body content>

Anna

Email 4
Subject: <subject line>
Body:
Hi <First Name>,

<email body content>

Anna
πŸ”’ FINAL VALIDATION CHECK (MANDATORY)
Before finalizing output:
Verify the sender name is NOT the same as the contact name
If it matches, replace it with Anna
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 IDENTITY (CRITICAL – FIXES SIGNATURE BUG)

The sender of all emails is a fixed identity.
Sender first name: Jenny

Rules:
The sender name must ALWAYS be exactly: Jenny
NEVER use the contact's first name, last name, or any contact field as the sender
NEVER infer the sender from the contact
If there is ambiguity, default to Jenny

πŸ”’ 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

πŸ”’ SUBJECT LINE RULES

Must look like an internal or peer email
Short
Plain
No marketing tone
Examples:
Can't find the file
Latest version?
Document follow-up
Missing attachment
Audit prep

πŸ”’ SIGNATURE RULE (STRICT)

End every email with exactly:

Jenny

Rules:
Do NOT vary the sender 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:
Body:
Hi <First Name>,

<email body content>

Jenny

Email 2
Subject:
Body:
Hi <First Name>,

<email body content>

Jenny

Email 3
Subject:
Body:
Hi <First Name>,

<email body content>

Jenny

Email 4
Subject:
Body:
Hi <First Name>,

<email body content>

Jenny

Email 5
Subject:
Body:
Hi <First Name>,

<email body content>

Jenny

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 sender name is NOT the same as the contact name
If it matches, replace it with Jenny
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,
{{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,
{{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,
{{sender_name}}`,
};

export default function PromptEditor({ selectedProducts, prompts, onPromptsChange, onSaveComplete }) {
    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(() => {
        // Initialize prompts for selected products
        const newPrompts = {};
        selectedProducts.forEach(product => {
            // Check if there's a saved prompt that's different from the default
            const savedPrompt = prompts[product.name];
            const defaultTemplate = DEFAULT_TEMPLATES[product.name];
            
            // If we have a default template, use it (this ensures latest defaults are always used)
            // Only use saved prompt if there's no default template
            if (defaultTemplate) {
                newPrompts[product.name] = defaultTemplate;
            } else if (savedPrompt) {
                newPrompts[product.name] = savedPrompt;
            } 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,\n{{sender_name}}`;
            }
        });
        setLocalPrompts(newPrompts);
    }, [selectedProducts, prompts]);

    const handlePromptChange = (productName, value) => {
        setLocalPrompts(prev => ({
            ...prev,
            [productName]: value
        }));
        setSavedStatus(prev => ({
            ...prev,
            [productName]: false
        }));
    };

    const handleSave = (productName) => {
        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 handleReset = (productName) => {
        const defaultTemplate = 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,\n{{sender_name}}`;
        handlePromptChange(productName, defaultTemplate);
    };

    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="border-b border-slate-100 bg-slate-50/50 px-6 py-4 flex items-center justify-between">
                                    <div className="flex items-center gap-3">
                                        <div className="rounded-lg bg-violet-100 p-2">
                                            <Sparkles className="h-4 w-4 text-violet-600" />
                                        </div>
                                        <div>
                                            <h4 className="font-semibold text-slate-800">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={() => handleReset(product.name)}
                                            className="text-slate-500 hover:text-slate-700"
                                        >
                                            <RotateCcw className="h-4 w-4 mr-1" />
                                            Reset
                                        </Button>
                                        <Button
                                            size="sm"
                                            onClick={() => handleSave(product.name)}
                                            className="bg-violet-600 hover:bg-violet-700"
                                        >
                                            {savedStatus[product.name] ? (
                                                <>
                                                    <CheckCircle2 className="h-4 w-4 mr-1" />
                                                    Saved!
                                                </>
                                            ) : (
                                                <>
                                                    <Save className="h-4 w-4 mr-1" />
                                                    Save Template
                                                </>
                                            )}
                                        </Button>
                                    </div>
                                </div>
                                <div className="p-6">
                                    <Textarea
                                        value={localPrompts[product.name] || ''}
                                        onChange={(e) => handlePromptChange(product.name, e.target.value)}
                                        placeholder="Enter your email template here..."
                                        className="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="h-4 w-4 mr-1" />
                                                Saved!
                                            </>
                                        ) : (
                                            <>
                                                <Save className="h-4 w-4 mr-1" />
                                                Save Template
                                            </>
                                        )}
                                    </Button>
                                </div>
                            </motion.div>
                        </TabsContent>
                    ))}
                </AnimatePresence>
            </Tabs>
        </div>
    );
}