Skip to main content

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.

CapabilityDetails
VersioningEvery edit is stored as a version and can be rolled back
Activate / DeactivateTurn a flow on or off without deleting it; concurrent active flows are capped by quota
CloneCopy an existing flow as the basis for a new one
Test-run / Test-chatTry a flow in a sandbox before going live
AI generationHave AI draft a flow from a plain-language description
Stats / LogsTrack 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

  1. POST /api/workflows/generate asks AI to draft a flow from a plain-language description (GenerateWorkflowDto).
  2. POST /api/workflows saves the flow after checking the organization's quota through the Plan Limits module.
  3. POST /api/workflows/parse-response converts and validates the response spec for nodes that call external APIs.

Testing

  1. POST /api/workflows/:id/test-run executes the flow in a sandbox with sample data.
  2. POST /api/workflows/:id/test-chat starts 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-oa rather than workflow, carried over from the original TypeScript behavior.

Going Live and Operating

  1. POST /api/workflows/:id/activate and POST /api/workflows/:id/deactivate toggle a flow. The number of simultaneously active workflows is capped by the maxActiveWorkflows quota.
  2. GET /api/workflows lists flows, GET /api/workflows/:id returns details, PUT /api/workflows/:id edits, and DELETE /api/workflows/:id soft-deletes.
  3. POST /api/workflows/:id/clone duplicates a flow.

Versions and History

  1. GET /api/workflows/:id/versions lists versions and GET /api/workflows/:id/versions/:versionId returns a single version's detail.
  2. POST /api/workflows/:id/versions/:versionId/rollback restores the selected version.
  3. GET /api/workflows/:id/stats and GET /api/workflows/:id/logs report 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/.

FileRole
controller.goRoute registration
service.goCRUD, versioning, activate/deactivate, stats
executor.goFlow step engine
sandbox.gonewSandboxService for test-run and test-chat with RAG (embedding + Meilisearch)
ai.go, prompt.goAI-assisted flow generation
paths.go, helpers.go, dto.goHelpers and DTOs
MethodRouteHandlerPolicy
GET/api/workflowsct.findAllread workflow
GET/api/workflows/:idct.findOneread workflow
GET/api/workflows/:id/statsct.getStatsread workflow
GET/api/workflows/:id/logsct.getLogsread workflow
GET/api/workflows/:id/versionsct.getVersionsread workflow
GET/api/workflows/:id/versions/:versionIdct.getVersionDetailread workflow
POST/api/workflowsct.createcreate workflow
POST/api/workflows/generatect.generatecreate workflow
POST/api/workflows/parse-responsect.parseResponseupdate workflow
POST/api/workflows/:id/test-runct.testRunupdate workflow
POST/api/workflows/:id/test-chatct.testChatread line-oa
POST/api/workflows/:id/versions/:versionId/rollbackct.rollbackToVersionupdate workflow
POST/api/workflows/:id/clonect.clonecreate workflow
POST/api/workflows/:id/activatect.activateupdate workflow
POST/api/workflows/:id/deactivatect.deactivateupdate workflow
PUT/api/workflows/:idct.updateupdate workflow
DELETE/api/workflows/:idct.removedelete workflow

Every route is wrapped with modulegate.ModuleGate(d, "workflow").

Connections to Other Services

  • Access control — All routes pass through ModuleGate("workflow"), with PolicyModuleWorkflow supplied as policy metadata.
  • Tablesworkflow, workflow_version, trigger_rule, knowledge_base, knowledge_document, knowledge_chunk, line_oa
  • Soft-delete caveat — The workflow, trigger_rule, and workflow_version tables use a plain deleted_date column rather than gorm.DeletedAt, so every query must add deleted_date IS NULL explicitly.
  • Sandbox environmentEMBEDDING_API_URL (defaults to https://poc-rag-xwqe451.1moby.tech/embed), MEILISEARCH_HOST (defaults to http://localhost:7700), and MEILISEARCH_API_KEY
  • RabbitMQweb_request_execute and message_received_trigger
  • Cross-module dependencies — Plan Limits (the maxActiveWorkflows quota), Knowledge Base, Trigger Rule, and the AI module
  • Related modulesAutomated Trigger Rules, Knowledge Base, AI Configuration, and Auto Response