Skip to content

feat: add Workflow Engine and CRM module#200

Open
iPythoning wants to merge 1 commit intodataelement:mainfrom
iPythoning:feature/workflow-crm
Open

feat: add Workflow Engine and CRM module#200
iPythoning wants to merge 1 commit intodataelement:mainfrom
iPythoning:feature/workflow-crm

Conversation

@iPythoning
Copy link

Summary

Adds two major features to Clawith:

Multi-Agent Workflow Engine

  • LLM-driven planning: Decomposes user business goals into executable agent steps
  • Sequential execution with built-in retry for failed steps
  • Rich deliverable viewer: Markdown rendering, table export (CSV), PDF export, CRM import
  • Real-time polling UI with step-by-step progress tracking
  • Contextual AI chat: Ask questions about workflow results in context

Lightweight CRM

  • Drag-and-drop Kanban pipeline: Lead → Contacted → Qualified → Proposal → Negotiation → Won/Lost
  • Contact management: Search, batch delete, detail panel with activity history
  • Deal tracking: Create/delete deals with value and currency per contact
  • Workflow integration: Import contacts from workflow step output directly into CRM

Quality

  • Full i18n (English + Chinese) — zero hardcoded UI strings
  • Multi-tenant isolation: All queries filter by tenant_id, workflow access verified via _can_access_workflow() helper
  • Alembic migration for 5 new tables (workflows, workflow_steps, crm_contacts, crm_deals, crm_activities)

Files added/modified

File Description
backend/app/models/workflow.py Workflow + WorkflowStep SQLAlchemy models
backend/app/models/crm.py CRMContact, CRMDeal, CRMActivity models
backend/app/api/workflows.py Workflow REST API (CRUD, retry, chat, export)
backend/app/api/crm.py CRM REST API (contacts, deals, activities, stats)
backend/app/services/workflow_orchestrator.py Core workflow engine (plan, execute, summarize)
backend/app/main.py Register workflow + CRM routers
backend/alembic/versions/add_workflow_crm_tables.py Migration for 5 new tables
frontend/src/pages/WorkflowList.tsx Workflow list page with create form
frontend/src/pages/WorkflowDetail.tsx Workflow detail with steps, deliverables, chat
frontend/src/pages/CRMDashboard.tsx CRM dashboard with pipeline + contacts views
frontend/src/App.tsx Add routes for workflow and CRM pages
frontend/src/pages/Layout.tsx Add sidebar navigation links
frontend/src/services/api.ts Add workflowApi and crmApi
frontend/src/i18n/en.json English translations for workflow + CRM
frontend/src/i18n/zh.json Chinese translations for workflow + CRM

Test plan

  • Run alembic upgrade head — verify 5 tables created
  • Create a workflow — verify planning + execution + deliverable display
  • Test workflow retry on failed steps
  • Test CSV/PDF export from workflow step
  • Create CRM contacts manually and via workflow import
  • Drag deals between pipeline stages
  • Switch language (EN/ZH) — verify no hardcoded strings
  • Verify tenant isolation: User A cannot see User B's workflows/contacts

Multi-agent workflow orchestration:
- LLM-driven planning decomposes user goals into agent steps
- Sequential execution with retry, CSV/PDF export, CRM import
- Real-time polling UI with step-by-step deliverable viewer
- Contextual AI chat assistant for workflow Q&A

Lightweight CRM for trade contacts and deals:
- Drag-and-drop Kanban pipeline (Lead → Won/Lost)
- Contact management with batch operations
- Deal tracking with stage progression
- Activity log per contact

Both modules include:
- Full i18n (en + zh) — no hardcoded strings
- Multi-tenant isolation (tenant_id checks on all queries)
- Alembic migration for 5 new tables

Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
@wisdomqin
Copy link
Contributor

Thanks for this substantial contribution! The Workflow Engine and CRM module are well-structured with good practices (i18n coverage, tenant isolation, retry logic).

However, we can't merge this into the core platform as-is. The main concern is that the workflow orchestrator is tightly coupled to a specific industry (foreign trade):

  • AGENT_ROLES hardcodes 7 agent names (Leo, Ava, Marco, etc.) and their tools
  • PLANNING_PROMPT is written specifically for trade workflows (market research → lead mining → outreach → PI generation)
  • get_default_llm_model() picks a random enabled model without tenant scoping

Clawith is a general-purpose multi-agent platform, and core features need to work across all industries and use cases.

That said, we have a plugin/extension system on our roadmap. Once that's available, a trade-specific Workflow + CRM plugin would be a great fit — users who need it can install it, while the core platform stays industry-agnostic.

We'd love for you to publish this as a plugin when the system is ready. In the meantime, a few suggestions if you'd like to prepare for that:

  1. Make the orchestrator generic — read agents and tools dynamically from the database instead of hardcoding
  2. Move industry-specific prompts into configurable templates
  3. Separate CRM into its own independent module
  4. Use Depends(get_db) instead of async_session() directly in API routes (to match project conventions)

Looking forward to collaborating on this!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants