AgentsHub is a multi-tenant platform for configuring domain agents (Sales, HR, Accountant, ...). Sales Agent is the first concrete instance — it validates platform primitives while supporting the BD team with auto lead generation, qualification, pre-call context, and proposal drafting.
Twendee ERP already owns lead/deal/company data and UI. Hub does not duplicate — it provides agent capabilities (skills, workflows, memory) exposed via API and embeddable chat widget.
Rep BD chỉ thấy ERP quen thuộc + 1 widget chat nhỏ. Còn lại là hạ tầng agent chạy ngầm.
Rep làm việc như cũ. Chỉ thêm ICP Score + Hot/Warm/Cold trên lead/deal + panel Enrichment — đều hiển thị như field native.
Nút Generate Proposal mở side-panel. Dùng để tạo draft, hỏi nhanh về deal. Scope chỉ trong 1 deal, không rò rỉ dữ liệu.
Webhook → enrich → score → ghi ngược ERP. Xong trước khi rep mở lead. Chỉ ping Telegram khi Hot (< 60 giây).
ERP gửi JWT ngắn hạn cho widget qua postMessage, whitelist origin.
Rep không login lần hai. Đóng deal page → JWT biến mất.
Kỷ luật ranh giới: mọi primitive dùng được cho agent vertical khác phải ở platform layer. HR/Accountant next chỉ cần viết skills mới.
Agent runs autonomously in background (lead gen → qualify → brief). Rep takes over once lead is Hot, with full context pre-loaded. At negotiation, rep triggers proposal — agent drafts, rep reviews, ERP approves.
Chuỗi 15 tin nhắn ở sơ đồ trên tương đương ~48 giờ thực tế. Đọc nhanh theo timeline bên dưới để thấy rep và agent phối hợp như thế nào.
sales.lead-enricher gọi LLM điền các
field thiếu + confidence score. Field độ tin thấp được flag,
không tự commit. Ghi ngược vào ERP.
icpScore + hot/warm/cold vào ERP.
post-call-extractor rút: pains,
stakeholders, timeline, objections — kèm source span để audit.
Deal record được cập nhật.
fetching-deal → computing-margin → generating-summary → rendering-pdf →
writing-draft → complete. Margin kiểm tra sàn 30%, LLM viết exec summary,
draft lưu dưới dạng comment có tag. < 3 phút.
Rep sees tangible output (a proposal document) in week 2-3 instead of waiting for full pipeline. Platform primitives build in M0, then each vertical phase adds 1 skill group.
| Phase | Scope | Effort | Value delivered |
|---|---|---|---|
| M0 | Platform primitives. Skill registry · Workflow runner (sync first) · Integration adapter generalize · JWT SSO · ERP schema PR with Twendee team | ~60h | Infra foundation — no user value yet |
| M1 | Proposal Generator. sales.proposal-generator skill · Finance cross-check · chat widget embed on ERP Deal page · POST /skills/.../run API | ~48h | Rep generates proposal from ERP in < 3 min |
| M2 | Qualification Pipeline. sales.icp-scorer · async workflow runner · platform.notify (Telegram) · push score to ERP via webhook | ~36h | Auto-scoring · Hot lead notifications < 60s |
| M3 | Discovery. sales.pre-call-briefer · sales.post-call-extractor · memory wiring · transcript upload UI | ~32h | Pre-call brief 30min before call |
| M4 | Polish + dogfood. Observability dashboards · bug fixes · 1-week BD team dogfood | ~16h | Production-ready · metrics-validated |
Each decision locks a trade-off. Listed with rationale so future readers can challenge them if constraints change.
ERP owns lead/deal rows + UI. Hub stores only agent-layer data (skill runs, memory, workflow state). Avoids duplicate schema and sync conflict.
Admin UI configures agent name, prompts, rules, tool toggles. Skills are code-registered. Avoids over-engineered DSL while keeping config flexible.
ERP already has best-in-class lead/deal UI. Hub only builds what ERP lacks — agent config, chat, approvals. Saves ~40h of duplicate work.
Sync in-process for user-triggered (proposal gen). Async BullMQ for batch/cron (qualify 500 leads / 5 min). Approval steps pause-resume via persisted job state.
ERP signs JWT (tenantId, userId, roles, exp). Hub verifies shared secret. Deep-link + widget embed both use same token. IdP upgrade path kept behind AuthProvider interface.
User-facing value first. Rep sees proposal output week 2-3. Forces platform primitives to ship early — later phases reuse the same runner, adapter, and SSO plumbing.