Introduction
A workflow is a logical flow composed of multiple nodes connected in series. The nodes that make up a workflow include trigger nodes and action nodes. Trigger nodes provide the ability to trigger and start workflow execution, typically serving as the entry and starting point of the process. Action nodes offer various logical functions, such as conditional branching, running JS code, providing HTTP responses, and integrating with WeChat Pay. The sequential, branching, and looping connections of multiple action nodes constitute the process of workflow execution.
How It Works
Start and Run
Workflows are triggered to start execution, with triggering methods implemented via triggers that support multiple approaches. For detailed information, refer to specific triggers:
- Triggered via components or invocations: via the CloudBase SDK, APIs, or component behaviors in the WeDa editor.
- Trigger at specified times: by designing the required trigger time or trigger cycle to achieve timed triggering of workflows.
- Triggered upon receiving an HTTP request: by providing a URL address, triggered when an HTTP request is received at the specified address. Commonly used in Webhook scenarios.
- Triggered upon receiving WeChat event message pushes: activates the workflow when event pushes, customer service messages, or service messages occur in associated Official Accounts or Mini Programs.
- Triggered upon receiving WeChat Pay messages: activates the workflow when callback messages are generated from the associated WeChat Pay account.
Each trigger event initiates the execution of a workflow instance. Before the execution completes, the instance exists independently and exclusively possesses its node execution data, global workflow data, and instance data within the instance environment.
Workflow Execution
After a workflow is triggered, it executes sequentially starting from the trigger according to the configured flow. Upon completion of one node, the next node executes. Branch nodes determine subsequent nodes within branches based on branch configurations. The workflow continues execution until the last executable node, concluding the workflow execution after completing the final node.
Execution Failure
During workflow execution, if a node fails, the workflow stops subsequent execution, and the current triggered run is recorded as an execution failure.
Execution Input and Output
When triggering a workflow through invocation, or via HTTP requests, message pushes, etc., the invocation parameters, HTTP request content, and message content can be considered as the workflow's input parameters. The workflow's input parameters are typically used as the input parameters for the specific trigger node, and the trigger node will output these input parameters again for internal use within the workflow. Subsequent execution nodes can obtain the workflow's input parameters through the output content of the trigger node.
A workflow has two methods to output execution results. The first method involves adding an HTTP Response node: when this node exists and is executed during the process, the workflow's output parameters will be the output content of the HTTP Response node (formatted as an HTTP response package), regardless of subsequent node execution. The second method applies when no HTTP Response node exists: the workflow will use the output of the last executed node as its output parameters and return them to the workflow caller.
Node Description
A workflow is composed of multiple nodes connected in series. Workflow nodes include trigger nodes and execution nodes. The execution starting point of a workflow is the trigger node, which then sequentially invokes execution nodes in the process.
Node Configuration Description
Node Identifier
Each node has a node identifier. In the workflow execution environment, the node identifier can be used to access the input and output content of nodes.
The node identifier is automatically generated when the node is created.
Node Input, Output, and Error Output
Each node has parameters related to input, output, and error output. In workflow configurations or code nodes, these can be accessed via $node.input
, $node.output
, and $node.error
.
During actual configuration or runtime, input content may only exist for some nodes. output content exists for almost all nodes. error content exists only when node execution fails.
Usage Limits
During workflow execution, the maximum execution duration for a single node is 60 seconds; the maximum execution duration for the entire workflow is 10 minutes.
When the maximum execution duration is exceeded, the node or workflow will report an error and the execution status will be marked as node failure or workflow failure.