Workflow & Chatbot
Overview
Workflow is the largest and most intricate feature in the platform. It lets teams build automation flows and chatbots as a sequence of nodes (receive a message, branch on a condition, call an API, reply) and ships with the full toolset a production automation system needs.
| Capability | Details |
|---|---|
| Versioning | Every edit is stored as a version and can be rolled back |
| Activate / Deactivate | Turn a flow on or off without deleting it; concurrent active flows are capped by quota |
| Clone | Copy an existing flow as the basis for a new one |
| Test-run / Test-chat | Try a flow in a sandbox before going live |
| AI generation | Have AI draft a flow from a plain-language description |
| Stats / Logs | Track how often a flow ran and what the outcomes were |
Workflows are fired by Automated Trigger Rules and draw on the Knowledge Base as the bot's source of truth, using a RAG approach backed by embeddings and Meilisearch.
Business Flow
Authoring
POST /api/workflows/generateasks AI to draft a flow from a plain-language description (GenerateWorkflowDto).POST /api/workflowssaves the flow after checking the organization's quota through the Plan Limits module.POST /api/workflows/parse-responseconverts and validates the response spec for nodes that call external APIs.
Testing
POST /api/workflows/:id/test-runexecutes the flow in a sandbox with sample data.POST /api/workflows/:id/test-chatstarts a trial conversation with the bot.- The sandbox calls the embedding API and Meilisearch to retrieve supporting knowledge (RAG).
- This endpoint's policy metadata is read
line-oarather thanworkflow, carried over from the original TypeScript behavior.
Going Live and Operating
POST /api/workflows/:id/activateandPOST /api/workflows/:id/deactivatetoggle a flow. The number of simultaneously active workflows is capped by themaxActiveWorkflowsquota.GET /api/workflowslists flows,GET /api/workflows/:idreturns details,PUT /api/workflows/:idedits, andDELETE /api/workflows/:idsoft-deletes.POST /api/workflows/:id/cloneduplicates a flow.
Versions and History
GET /api/workflows/:id/versionslists versions andGET /api/workflows/:id/versions/:versionIdreturns a single version's detail.POST /api/workflows/:id/versions/:versionId/rollbackrestores the selected version.GET /api/workflows/:id/statsandGET /api/workflows/:id/logsreport execution results.
Runtime
When a trigger fires, the worker walks the flow node by node, calls external APIs through the web_request_execute queue, and delivers replies to the user over LINE.
Key Files & Functions
The code lives in internal/modules/workflow/.
| File | Role |
|---|---|
controller.go | Route registration |
service.go | CRUD, versioning, activate/deactivate, stats |
executor.go | Flow step engine |
sandbox.go | newSandboxService for test-run and test-chat with RAG (embedding + Meilisearch) |
ai.go, prompt.go | AI-assisted flow generation |
paths.go, helpers.go, dto.go | Helpers and DTOs |
| Method | Route | Handler | Policy |
|---|---|---|---|
| GET | /api/workflows | ct.findAll | read workflow |
| GET | /api/workflows/:id | ct.findOne | read workflow |
| GET | /api/workflows/:id/stats | ct.getStats | read workflow |
| GET | /api/workflows/:id/logs | ct.getLogs | read workflow |
| GET | /api/workflows/:id/versions | ct.getVersions | read workflow |
| GET | /api/workflows/:id/versions/:versionId | ct.getVersionDetail | read workflow |
| POST | /api/workflows | ct.create | create workflow |
| POST | /api/workflows/generate | ct.generate | create workflow |
| POST | /api/workflows/parse-response | ct.parseResponse | update workflow |
| POST | /api/workflows/:id/test-run | ct.testRun | update workflow |
| POST | /api/workflows/:id/test-chat | ct.testChat | read line-oa |
| POST | /api/workflows/:id/versions/:versionId/rollback | ct.rollbackToVersion | update workflow |
| POST | /api/workflows/:id/clone | ct.clone | create workflow |
| POST | /api/workflows/:id/activate | ct.activate | update workflow |
| POST | /api/workflows/:id/deactivate | ct.deactivate | update workflow |
| PUT | /api/workflows/:id | ct.update | update workflow |
| DELETE | /api/workflows/:id | ct.remove | delete workflow |
Every route is wrapped with modulegate.ModuleGate(d, "workflow").
Connections to Other Services
- Access control — All routes pass through
ModuleGate("workflow"), withPolicyModuleWorkflowsupplied as policy metadata. - Tables —
workflow,workflow_version,trigger_rule,knowledge_base,knowledge_document,knowledge_chunk,line_oa - Soft-delete caveat — The
workflow,trigger_rule, andworkflow_versiontables use a plaindeleted_datecolumn rather thangorm.DeletedAt, so every query must adddeleted_date IS NULLexplicitly. - Sandbox environment —
EMBEDDING_API_URL(defaults tohttps://poc-rag-xwqe451.1moby.tech/embed),MEILISEARCH_HOST(defaults tohttp://localhost:7700), andMEILISEARCH_API_KEY - RabbitMQ —
web_request_executeandmessage_received_trigger - Cross-module dependencies — Plan Limits (the
maxActiveWorkflowsquota), Knowledge Base, Trigger Rule, and the AI module - Related modules — Automated Trigger Rules, Knowledge Base, AI Configuration, and Auto Response