Overview
TheprocessSingleNode workflow executes a single node within a workflow. It handles the complete lifecycle of node execution, including validation, processing, token charging, file generation, and error handling.
Purpose
This workflow is designed to:- Execute a single node independently
- Validate user access to required AI models
- Process the node based on its type
- Track token usage for billing
- Generate output files when configured
- Handle errors gracefully with comprehensive logging
- Notify users of execution status changes
Workflow signature
Parameters
| Parameter | Type | Description |
|---|---|---|
nodeId | string | Unique identifier of the node to execute |
userId | string | ID of the user executing the workflow |
sessionId | string | Session identifier for tracking execution context |
flowId | string | ID of the flow containing the node |
Return value
Returns"Node executed successfully" on successful completion, or throws an error on failure.
Execution flow
The workflow follows this sequence:Set initial status
Notifies the user that the node execution has started by setting status to
PENDING using notifyStatusActivity.Retrieve node information
Queries the database to get node details (type, flow_id, data) using
getInfoInDatabaseActivity.Process by node type
Executes different logic based on the node type:
- TEXT_GENERATOR: Validates model access, generates text, charges tokens, and optionally generates files
- SCRIPTING: Runs user JavaScript or Python via Lambda (see the Scripting node doc)
- Other types: Currently throws an error (not yet supported)
Log successful execution
Creates an execution log entry with success status using
generateExecutionLogsActivity.Notify completion
Updates the node status to
COMPLETED using notifyStatusActivity.Node type: TEXT_GENERATOR
When processing aTEXT_GENERATOR node, the workflow:
- Validates model access: Uses
validateModelAccessActivityto ensure the user has access to the specified AI model and system - Generates text: Executes
textGeneratorActivityto produce the output - Validates tokens: Ensures both input and output tokens are returned
- Charges tokens: Records token usage for billing using
chargeTokensActivity - Generates file (optional): If
saveOutputandfileTypeare configured, generates a file usinggenerateFileActivity
Error handling
The workflow implements comprehensive error handling:Log error
Creates an execution log entry with error status using
generateExecutionLogsActivityUpdate node data
Updates the nodeβs data with execution status using
nodeExecutionErrorActivityNotify failure
Updates the node status to
FAILED using notifyStatusActivityActivities used
This workflow uses the following activities:notifyStatusActivity- Status notifications (start, completion, failure)getInfoInDatabaseActivity- Database queriesvalidateModelAccessActivity- Model access validationtextGeneratorActivity- AI text generation (TEXT_GENERATOR nodes)scriptingActivity- Script execution (SCRIPTING nodes)chargeTokensActivity- Token billinggenerateFileActivity- File generation (optional)generateExecutionLogsActivity- Execution loggingnodeExecutionErrorActivity- Error handling
Status transitions
The node status progresses through these states:- PENDING - Workflow started, node execution beginning
- COMPLETED - Node executed successfully
- FAILED - Node execution encountered an error
Example usage
Related documentation
- Worker overview
- Activities documentation
- processAgent workflow (in development)