| name | userchat-to-sop-pipeline |
| description | Complete end-to-end pipeline for transforming Excel customer support data into production-ready Agent SOP documents, flowcharts, ALF implementation package, individual ALF registration files, and client-facing deployment scenario through 7 stages. |
Userchat-to-SOP Complete Pipeline
Overview
Orchestrates the complete pipeline: Excel data โ Clustering โ Pattern Extraction โ SOP Generation โ Flowcharts โ ALF Package โ ALF Document Export โ Deployment Scenario.
Language: Detect the language from the user's first message and respond in that language throughout. Support Korean (ํ๊ตญ์ด) and Japanese (ๆฅๆฌ่ช). Default to Korean if language is unclear.
Pipeline Flow:
Excel Input (๊ณ ๊ฐ ์๋ด ๋ฐ์ดํฐ)
โ
Stage 1: Clustering (Python) [~3 min]
โ clustered_data.xlsx, cluster_tags.xlsx, analysis_report.md
โ
Stage 2: Pattern Extraction (LLM) [~8 min]
โ patterns.json (with sop_topic_map), faq.json, patterns_enriched.json
โ
Stage 3: SOP Generation + Verification (LLM) [~12 min]
โ TS_*.sop.md, HT_*.sop.md (verified against real conversations)
โ
Stage 4: Flowchart Generation (LLM) [~4 min, optional]
โ *_FLOWCHART.md (Mermaid markdown)
โ
Stage 5: ALF Implementation Package (LLM + Python) [~25 min]
โ rules_draft.md, rag_items.md, tasks, api_requirements,
alf_implementation_guide.md, analysis_report.md
โ
Stage 6: ALF Document Export (LLM) [~10 min]
โ 06_alf_documents/rules/ (individual rule files), 06_alf_documents/rag/ (individual RAG docs)
โ
Stage 7: Deployment Scenario (LLM) [~5 min]
โ deployment_qa_set.html, deployment_qa_set.md (+ optional Notion)
Total Time: ~65-80 minutes
Parameters
Required
- language (default: "ko"):
"ko" (Korean) or "ja" (Japanese)
Stage 1 Parameters (์๋ ์์ง)
input_file: data/ ๋๋ ํ ๋ฆฌ์์ ์๋ ๊ฐ์ง
company: ํ์ผ๋ช
์์ ์๋ ์ถ์ถ
output_dir: results/{company}๋ก ์๋ ์ค์
sample_size: ๊ธฐ๋ณธ๊ฐ 3000
k: ๊ธฐ๋ณธ๊ฐ "auto"
App Functions (์ฑํ์คํฌ ์ฐ๋)
- app_functions (default: false): ์ฑํ์คํฌ(์ฑํจ์) ์ฐ๋ ์ฌ๋ถ. Stage 5์ ์ ๋ฌ๋จ โ ์์ธ ์ค๋ช
์
/stage5-sop-to-guide Parameters ์ฐธ์กฐ
- app_functions_services (default:
[]): ์ฐ๋๋ ์ฑ ์๋น์ค ๋ชฉ๋ก. Stage 5์ ์ ๋ฌ๋จ
Optional
- auto_proceed (default: true):
true = ๋จ๊ณ ๊ฐ ์๋ ์งํ, false = ๋จ๊ณ๋ง๋ค ํ์ธ
- generate_flowcharts (default: true): Stage 4 ์คํ ์ฌ๋ถ
- flowchart_target (default: "all"):
"all", "ts_only", "ht_only"
- flowchart_format (default: "markdown"):
"markdown", "svg", "both"
- generate_alf_package (default: true): Stage 5 ์คํ ์ฌ๋ถ
- generate_alf_export (default: true): Stage 6 ์คํ ์ฌ๋ถ
- generate_deployment_scenario (default: true): Stage 7 ์คํ ์ฌ๋ถ
- notion_parent_page (default: none): Notion ๋ถ๋ชจ ํ์ด์ง URL/ID (Stage 7์์ ์ฌ์ฉ)
Steps
1. Initialize Pipeline
Actions:
- Detect language from user's first message
- Set
LANGUAGE={language} for all Python script executions
- Check
.env for required API keys:
- Embedding/Tagging key (one of):
UPSTAGE_API_KEY (Upstage Solar) โ required for Stage 1 clustering & tagging
- LLM key (one of):
PRISM_API_KEY (Prism Gateway, recommended for Channel ๋ด๋ถ ์ฌ์ฉ) ๋๋ ANTHROPIC_API_KEY (Claude API ์ง์ ์ฌ์ฉ) โ required for Stage 2~7
- If a required key is missing, instruct the user to add it to
.env directly.
- MUST NOT proceed until at least one embedding key (
UPSTAGE_API_KEY) AND one LLM key (PRISM_API_KEY or ANTHROPIC_API_KEY) are present in .env.
- Validate:
pip install -r requirements.txt
- Collect app function info: Ask whether the client uses app task functions (์ฑํ์คํฌ):
- "์ด ๊ณ ๊ฐ์ฌ๋ ์ด์ง์ด๋๋ฏผ, ์นดํ24, ์ฌ๋ฐฉ๋ท ๋ฑ ์ฑํ์คํฌ(์ฑํจ์) ์ฐ๋์ ์ฌ์ฉํ๊ณ ์๋์?"
- If yes: ask which services are connected (์ด์ง์ด๋๋ฏผ / ์นดํ24 / ์ฌ๋ฐฉ๋ท / ๊ธฐํ)
- Store as
app_functions=true and app_functions_services=[...]
- This will be passed to Stage 5 so that task planning uses app functions where applicable instead of custom code nodes
2. Execute Stage 1: Clustering
Run /stage1-clustering with auto-detected parameters.
Outputs:
results/{company}/01_clustering/{company}_clustered.xlsx
results/{company}/01_clustering/{company}_tags.xlsx
results/{company}/01_clustering/{company}_messages.csv
results/{company}/01_clustering/analysis_report.md
Quality Checks: Clustering succeeded, no single cluster >50%, silhouette score >0.05
Transition: If auto_proceed=true, proceed immediately. Otherwise ask user.
3. Execute Stage 2: Pattern Extraction
Run /stage2-extraction with auto-detected parameters.
Key defaults (updated):
min_total_samples: 500 (increased from 300)
n_samples_per_cluster: max(25, ceil(500 / K))
Outputs: patterns.json (with sop_topic_map), faq.json, keywords.json, patterns_enriched.json
Quality Checks: All JSON valid, patterns extracted, FAQ pairs are specific
Transition: If auto_proceed=true, proceed immediately. Otherwise ask user.
4. Execute Stage 3: SOP Generation + Verification
Run /stage3-sop-generation with auto-detected parameters.
Key change: Stage 3 now includes a verification loop โ each SOP is tested against 3-5 real conversations from enriched data, and gaps are fixed before finalizing.
Outputs:
results/{company}/03_sop/HT_*.sop.md (multiple files)
results/{company}/03_sop/TS_*.sop.md (multiple files)
results/{company}/03_sop/metadata.json
Quality Checks: Template structure followed, Cases include concrete details, verification coverage >70%
Transition: If auto_proceed=true, proceed immediately. Otherwise ask user.
5. Execute Stage 4: Flowchart Generation (optional, default enabled)
Run /stage4-flowchart-generation.
Skip if: generate_flowcharts=false or user declines during review.
Outputs: *_FLOWCHART.md, optionally *_flowchart.svg
6. Execute Stage 5: ALF Implementation Package (default enabled)
Run /stage5-sop-to-guide with the following pipeline-mode overrides:
Skip if: generate_alf_package=false
Pipeline-mode overrides passed to Stage 5:
app_functions = value collected in Step 1 (skip stage5's own question)
app_functions_services = list collected in Step 1
Pipeline deliverables (final outputs):
results/{company}/05_sales_report/alf_setup/rules_draft.md
results/{company}/05_sales_report/alf_setup/rag_items.md
results/{company}/05_sales_report/tasks/TASK{N}_{name}.md
results/{company}/{company}_api_requirements.md
results/{company}/{company}_alf_implementation_guide.md
results/{company}/05_sales_report/{company}_analysis_report.md
Intermediate files (generated but not deliverables):
05_sales_report/analysis/cross_analysis.json
05_sales_report/analysis/heatmap.png
05_sales_report/analysis/automation_analysis.md
05_sales_report/sales_report_config.json
Quality Checks: Rules draft has 9 sections, RAG items have Priority 1+2, ROI figures generated
Transition: If auto_proceed=true, proceed immediately. Otherwise ask user.
7. Execute Stage 6: ALF Document Export (default enabled)
Run /stage6-alf-document-export.
Skip if: generate_alf_export=false or Stage 5 was skipped.
Outputs:
results/{company}/06_alf_documents/rules/01~09_*.md (9 individual rule files)
results/{company}/06_alf_documents/rag/*.md (individual RAG knowledge documents)
Quality Checks: Rule file count matches sections, RAG doc count matches rag_items
8. Execute Stage 7: Deployment Scenario (default enabled)
Run /stage7-deployment-scenario.
Skip if: generate_deployment_scenario=false or Stage 6 was skipped.
Outputs:
results/{company}/07_deployment/deployment_qa_set.html (๊ณ ๊ฐ์ฌ ๊ณต์ ์ฉ)
results/{company}/07_deployment/deployment_qa_set.md (๋ก์ปฌ ๋ณด๊ด์ฉ)
- Notion pages (if
notion_parent_page provided)
Quality Checks: All categories mapped, each has test queries, Step 1/2 classification consistent with api_requirements
9. Validate and Summarize
Verify all outputs exist:
results/{company}/
โโโ 01_clustering/ (clustered.xlsx, tags.xlsx, messages.csv, analysis_report.md)
โโโ 02_extraction/ (patterns.json, faq.json, keywords.json, patterns_enriched.json)
โโโ 03_sop/ (HT_*.sop.md, TS_*.sop.md, metadata.json, *_FLOWCHART.md)
โโโ 04_flowcharts/ (Stage 4 โ ๋ณ๋ ํ๋ก์ฐ์ฐจํธ, ์ ํ)
โโโ 05_sales_report/
โ โโโ alf_setup/ (rules_draft.md, rag_items.md)
โ โโโ tasks/ (TASK{N}_{name}.md)
โ โโโ analysis/
โ โโโ {company}_analysis_report.md
โโโ 06_alf_documents/
โ โโโ rules/ (๊ฐ๋ณ ๊ท์น ํ์ผ 9๊ฐ, ALF ๋ฑ๋ก์ฉ)
โ โโโ rag/ (๊ฐ๋ณ RAG ์ง์ ๋ฌธ์)
โโโ 07_deployment/ (deployment_qa_set.html, deployment_qa_set.md)
โโโ {company}_api_requirements.md
โโโ {company}_alf_implementation_guide.md
โโโ pipeline_summary.md
Generate pipeline_summary.md with execution info, statistics per stage, verification results, key insights, and next steps.
Communicate results:
โ
Userchat-to-SOP Pipeline Complete: {Company}
๐ Results
- Records: {N}, Clusters: {K}
- Patterns: {P}, FAQ Pairs: {F}
- SOP Files: {count} (TS: {ts}, HT: {ht})
- Verification Coverage: {X}%
- Flowcharts: {fc_count}
- Rules: 9 sections โ {rule_files} individual files
- RAG Items: Priority 1: {p1} / Priority 2: {p2} โ {rag_docs} documents
- Tasks: {task_count} / APIs: {api_count}
- ํด๊ฒฐ์จ: ๋ณด์์ {X}% ~ ๋๊ด์ {Y}%
- QA ์ธํธ: Step 1 {s1}๊ฑด + Step 2 {s2}๊ฑด
๐ Output: results/{company}/
๐ Key reports:
- {company}_alf_implementation_guide.md (ALF ๋์
๊ฐ์ด๋)
- {company}_analysis_report.md (๋ฐ์ดํฐ ๋ถ์ ๋ฆฌํฌํธ)
- 07_deployment/deployment_qa_set.html (๋ฐฐํฌ ์๋๋ฆฌ์ค & QA ์ธํธ)
Pipeline Defaults
| Stage | Parameter | Default |
|---|
| 1 | sample_size | 3000 |
| 1 | k_range | 8,10,12,15,20,25 |
| 2 | min_total_samples | 500 |
| 2 | n_samples_per_cluster | max(25, ceil(500/K)) |
| 3 | verification | enabled (3-5 conversations per SOP) |
| 4 | flowchart_target | all |
| 4 | flowchart_format | markdown |
| 5 | intermediate_artifacts | generated but not deliverables |
| 6 | enabled | true (requires Stage 5) |
| 7 | enabled | true (requires Stage 6) |
| 7 | notion_parent_page | none (local files only) |
Pipeline-mode vs Standalone-mode Differences
When running Stage 5 as part of the full pipeline (/userchat-to-sop-pipeline), the following are skipped or demoted:
| Artifact | Pipeline mode | Standalone (/stage5-sop-to-guide) |
|---|
cross_analysis.json | Generated (intermediate) | Deliverable |
heatmap.png | Generated (intermediate) | Deliverable |
automation_analysis.md | Generated (intermediate) | Deliverable |
sales_report_config.json | Generated (intermediate) | Deliverable |
Troubleshooting
| Issue | Solution |
|---|
| Stage 1 fails | pip install -r requirements.txt, check UPSTAGE_API_KEY |
| Stage 2 too slow | Reduce min_total_samples to 300, or focus_clusters="top_10" |
| SOPs too generic | Stage 3 verification should catch this; if not, increase Stage 2 samples |
| Stage 5 fails | Check ANTHROPIC_API_KEY (for dialog classification), verify Stage 1-3 outputs exist |
| Stage 6 fails | Verify rules_draft.md and rag_items.md exist from Stage 5 |
| Stage 7 fails | Verify cross_analysis.json, rag_items.md, api_requirements.md exist from Stage 5-6 |
| Need to resume | Each stage runs independently: /stage2-extraction, /stage5-sop-to-guide, /stage7-deployment-scenario, etc. |
| Flowchart fails | Use flowchart_format="markdown" (no CLI needed) |
Notes
- Hybrid approach: Python for clustering (fast, deterministic), LLM for extraction and composition (language understanding)
- Stage 2: sequential processing in main agent โ no subagents (causes hanging)
- Stage 3 verification loop is the key quality improvement โ invests tokens in checking rather than elaborate prompts
- Stage 5 pipeline mode: Skips QA scenarios; intermediate analysis files are generated for report input but not listed as deliverables
- Stage 6 depends on Stage 5 โ if Stage 5 is skipped, Stage 6 is also skipped
- Stage 7 depends on Stage 6 โ generates client-facing deployment scenario + QA set from existing outputs (~5 min)
- Cost: ~$2-5 per 1000 records (Upstage + Claude, full pipeline including Stage 5-7)
- Each stage is independent and can be resumed separately