Admin: Workflow Templates
Manage the 50-template research library — publish, unpublish, seed, and monitor ResearchWorkflow templates in the marketplace.
Admin Overview#
The Workflow Templates admin surface lets administrators manage the research template marketplace. This includes publishing and unpublishing templates, monitoring usage and ratings, seeding the 50 pre-built templates into the database, and reviewing the metadata fields that drive discovery and filtering.
Access Point
/admin/workflow-templates.Template Management
View, publish, unpublish, and delete marketplace templates from the admin interface.
Seed 50 Templates
Run the seed script or API endpoint to populate the marketplace with all 50 pre-built research templates.
Rating Oversight
Monitor template ratings and purchase counts to identify underperforming or abused templates.
Template Management Page#
The admin template management page at /admin/workflow-templates shows all ResearchWorkflow records where isTemplate: true. It has two tabs: Published and Unpublished.
Publish Template
Move an approved template to the Published state, making it visible in the marketplace at /marketplace/workflows.
Unpublish Template
Remove a template from marketplace visibility without deleting it. Useful for quality issues or content review.
Edit Metadata
Update templateCategory, templateTags, publishedPrice, publishedDescription, and templatePreview for any template.
Delete Template
Permanently remove a template and all associated ratings. This action cannot be undone.
For each template in the list, the admin table shows:
| Column | Field Source | Notes |
|---|---|---|
| Name | ResearchWorkflow.name | Template display name |
| Category | ResearchWorkflow.templateCategory | One of 7 categories; used for filtering |
| Price | ResearchWorkflow.publishedPrice | Shown as "$0" for free templates |
| Tags | ResearchWorkflow.templateTags | Searchable tag array |
| Rating | ResearchWorkflow.averageRating | Computed average from WorkflowTemplateRating records |
| Uses | ResearchWorkflow.purchaseCount | Number of times this template was launched |
| Status | ResearchWorkflow.publishedStatus | PUBLISHED or DRAFT |
| Created | ResearchWorkflow.createdAt | Template creation date |
Deleting a template
WorkflowTemplateRating records. Existing workflow runs that referenced this template are not affected (run history is preserved), but the template will no longer appear in the wizard browser or marketplace.Seeding the 50 Templates#
The 50 pre-built research templates are defined in scripts/seed-research-workflow-templates.ts and are called automatically as part of the main Prisma seed script. To populate the marketplace with all 50 templates on a fresh deployment:
Run the Prisma seed
Verify templates in admin
Verify marketplace
To run only the template seed (without re-running the full seed):
Standalone execution
npx tsx scripts/seed-research-workflow-templates.ts. The script is idempotent — it skips templates that already exist by checking the template name. You can safely run it multiple times.| Category | Count | Price Range |
|---|---|---|
| Competitive Intelligence | 10 | $79–$199 |
| Market Research | 10 | $129–$249 |
| Investment & Financial | 8 | $149–$299 |
| Technology & Innovation | 8 | $129–$199 |
| Marketing & Brand | 6 | $99–$149 |
| HR & Talent | 5 | $99–$179 |
| Strategic Planning | 5 | $149–$199 |
| Total | 52 | $79–$299 |
Adding custom templates
Template Metadata Fields#
The following fields on ResearchWorkflow drive template discovery, filtering, and quality signals in the marketplace:
| Field | Type | Purpose | Used By |
|---|---|---|---|
| templateCategory | String? | Category for sidebar filtering (one of 7 values) | Marketplace sidebar, in-wizard browser, API filter |
| templateTags | String[] | Searchable tags (e.g., "b2b", "saas", "competitor-analysis") | Search, tag cloud, API filter |
| templatePreview | Json? | WorkflowTemplatePreview object: outputSections, estimatedOutputPages, sampleInsight, agentSequence, estimatedRunTimeMinutes | Preview modal in marketplace and wizard browser |
| purchaseCount | Int (default 0) | Number of times launched via run-from-wizard API | Popular sort, social proof display |
| averageRating | Float? | Computed from WorkflowTemplateRating records; recalculated on each new rating | Top Rated sort, star display |
Valid values for templateCategory:
| Value | Display Label |
|---|---|
| competitive | Competitive Intelligence |
| market | Market Research |
| investment | Investment & Financial |
| technology | Technology & Innovation |
| marketing | Marketing & Brand |
| hr | HR & Talent |
| strategy | Strategic Planning |
The templatePreview JSON field stores a WorkflowTemplatePreview object:
| Field | Type | Example |
|---|---|---|
| outputSections | string[] | ["Executive Summary", "Competitor Profiles", "Gap Analysis"] |
| estimatedOutputPages | number | 12 |
| sampleInsight | string | "This template identifies the top 5 competitors, benchmarks pricing and features, and surfaces 3 strategic opportunities." |
| agentSequence | string[] | ["Source Collection", "Multi-Source Synthesis", "Verification", "Format"] |
| estimatedRunTimeMinutes | number | 5 |
Rating System#
Users can submit one rating (1–5 stars, optional text) per template after a completed workflow run. Ratings are stored in the WorkflowTemplateRating model and the template's averageRating is recalculated on every new submission.
| Scenario | Admin Action |
|---|---|
| Template rated falsely / spam reviews | Delete individual ratings via Prisma Studio or direct DB query on workflow_template_ratings table |
| Template consistently rated < 3 stars | Unpublish from admin page; investigate quality issues; re-publish after improvement |
| averageRating not updating | Check /api/marketplace/workflows/[id]/rate route; verify averageRating recalculation logic |
| purchaseCount seems off | purchaseCount increments on each call to POST /api/research/workflows/run-from-wizard — check for duplicate requests or errors in that route |
Unique constraint
WorkflowTemplateRating model has a @@unique([templateId, userId]) constraint — one rating per user per template. The rating API uses an upsert, so submitting a second rating overwrites the first.Database Models#
The Workflow Templates feature uses these database models:
| Model | Table | Purpose | Growth Pattern |
|---|---|---|---|
| ResearchWorkflow (extended) | research_workflows | Template records with templateCategory, templateTags, templatePreview, purchaseCount, averageRating | One record per template; admin-curated or user-submitted |
| ResearchWorkflowRun (extended) | research_workflow_runs | Stores wizardSessionId and wizardInput JSON for runs triggered from wizard | Grows with each workflow launch |
| WorkflowTemplateRating | workflow_template_ratings | User ratings (1–5) with optional reviews; unique per user+template | Grows with marketplace activity |
The WorkflowTemplateRating model has the following schema:
| Field | Type | Notes |
|---|---|---|
| id | String (cuid) | Primary key |
| templateId | String | FK → research_workflows.id (cascade delete) |
| userId | String | FK → User.id (cascade delete) |
| rating | Int | 1–5 inclusive |
| review | String? | Optional text review |
| createdAt | DateTime | Submission timestamp |
API Endpoints#
Admin-relevant API endpoints for the Workflow Templates feature:
| Method | Route | Purpose | Auth |
|---|---|---|---|
| GET | /api/admin/workflow-templates | List all templates with status filter | Admin only |
| PATCH | /api/admin/workflow-templates/[id] | Update template (publish/unpublish/edit metadata) | Admin only |
| DELETE | /api/admin/workflow-templates/[id] | Permanently delete template | Admin only |
| POST | /api/research/workflows/run-from-wizard | Launch template with wizard context; increments purchaseCount | Authenticated user |
| POST | /api/marketplace/workflows/[id]/rate | Upsert rating; recalculates averageRating | Authenticated user |
| GET | /api/research/workflows/runs/[runId]/status | Poll run status for progress tracker | Authenticated user |
| GET | /api/marketplace/workflows | List published templates with category/tag/sort filters | Public |
The marketplace workflows API accepts these query parameters for template discovery:
| Parameter | Values | Notes |
|---|---|---|
| category | competitive, market, investment, technology, marketing, hr, strategy | Filters by templateCategory |
| sort | popular, top-rated, newest, price-asc, price-desc | popular → ORDER BY purchaseCount DESC; top-rated → ORDER BY averageRating DESC |
| search | any string | Full-text search on name and publishedDescription |
| minPrice / maxPrice | number | Filter by publishedPrice range |
| page / limit | number | Pagination (default limit: 12) |
Monitoring#
Key metrics to watch for the Workflow Templates feature:
| Metric | Where to Check | Healthy Signal | Action If Abnormal |
|---|---|---|---|
| Template count in marketplace | Admin /admin/workflow-templates Published tab | 50+ templates visible | Run seed script if count < 50 |
| purchaseCount per template | Admin templates table | Growing over time; competitive templates lead | Investigate if count stuck at 0 after launch |
| averageRating distribution | Admin templates table | Majority of templates ≥ 4.0 stars | Unpublish templates rated < 3.0 consistently |
| run-from-wizard API error rate | Server logs | < 1% error rate | Check orchestrator.ts and ResearchWorkflowRun creation |
| WorkflowTemplateRating growth | workflow_template_ratings table row count | Growing proportionally with purchaseCount | If near 0, check rate API and post-run UX |
| Seed idempotency | Template count after re-run | Count unchanged | Check upsert logic in seed script if duplicates appear |
First-time setup
npx prisma db seed to populate the 50 templates. The marketplace and in-wizard browser will appear empty until the seed runs. Also apply the migration 20260302000001_add_workflow_template_fields using npx prisma migrate deploy to ensure the new schema fields are present in production.Success Metric
Target: ≥ 15% of Step 5 wizard users choose 'Run as Workflow' within 60 days of launch.
Template Adoption
Target: ≥ 40% of 'Run as Workflow' sessions use a marketplace template (not a blank workflow).