Skip to content

Workflows (Node-RED)

What are Workflows?

Workflows (Flows) are automated processes that allow connecting different components of the Rosepetal system using Node-RED, a visual programming tool based on nodes that facilitates the integration of devices, APIs and services.

Access to Flows

From the Dashboard

  • "Flows" card in the main panel
  • System status: Online/Offline visible
  • Direct access: Click to open the editor

System States

🟢 System Online

  • Editor available: Full access to Node-RED
  • Active flows: Processes running automatically
  • Established communication: Connection with devices and services
  • Real-time monitoring: Node status visible

🔴 System Offline

  • Connection error: Informative screen with retry option
  • Stopped flows: Automatic processes paused
  • Diagnostics available: Tools to identify problems
  • Recovery mode: Options to restore functionality

Flow Assistant

🤖 Intelligent Assistant

The Flow Assistant is an integrated AI tool that helps create and modify flows using natural language.

Main Features

  • Chat interface: Communication in Spanish or English
  • Contextual understanding: Understands the purpose of your flow
  • Automatic generation: Creates nodes and connections automatically
  • Smart suggestions: Proposes improvements and optimizations

How to Use the Assistant

  1. Select active flow: From the dropdown of available flows
  2. Describe need: Write in natural language what you need
  3. Review proposal: The assistant generates a solution
  4. Apply changes: Confirm the proposed implementation

💬 Usage Examples

Create New Node

User: "I need a node that takes images from the main camera every 5 seconds"
Assistant: "Perfect, I'll create an inject node configured for every 5 seconds connected to a camera-capture node"

Process Images

User: "I want to apply the classification model 'defects_v2' to captured images"
Assistant: "I'll add an AI-predict node after the capture, configured with your defects_v2 model"

Automate Responses

User: "If it finds a defect, send an email to the supervisor"
Assistant: "I'll create a conditional branch that detects defects and activates a configured email node"

Node-RED Editor

🎨 Visual Interface

Main Panel

  • Design canvas: Work area to create flows
  • Node bar: Palette with available components
  • Side panel: Configuration and information
  • Top menu: Editing and deploy tools

Basic Elements

  • Nodes: Functional components that process data
  • Connections: Cables that transport information between nodes
  • Subflows: Reusable groupings of nodes
  • Comments: Visual documentation of the flow

📦 Node Types

Input Nodes

  • inject: Inject data manually or by time
  • http in: Receive HTTP requests
  • tcp in: TCP/IP communication
  • serial in: Data from serial ports
  • mqtt in: MQTT messages

Function Nodes (Processing)

  • function: Custom JavaScript
  • switch: Conditional routing
  • change: Modify message properties
  • template: Format data with templates
  • delay: Delay or limit messages

Output Nodes

  • debug: Show messages in console
  • http response: Respond to HTTP requests
  • mqtt out: Publish MQTT messages
  • file: Write to files
  • email: Send emails

Rosepetal Specific

  • camera-capture: Capture images from cameras
  • ai-predict: Make predictions with models
  • dataset-upload: Upload images to datasets
  • quality-check: Quality verifications
  • plc-write: Write to industrial PLCs

Common Use Cases

🏭 Industrial Automation

Automatic Quality Control

Timer (5s) → Camera Capture → AI Predict → Quality Check

                              PLC Output (OK/NOK)

Description: Every 5 seconds takes an image, analyzes it with AI and sends result to PLC.

Defect Alert

Camera Trigger → AI Model → Switch (if defect) → Email Alert
                      ↓                      ↓
                 Good Counter        Store Defect Image

Description: Detects defects and sends alerts while counting good pieces.

📊 Data Collection

Real-time Statistics

Production Data → Format → InfluxDB → Grafana Dashboard

   Daily Report → Email → Management

Description: Collects production data, stores it and generates automatic reports.

Automatic Backup

Timer (Daily) → Export Datasets → Compress → Upload to S3

              Delete Old Backups

Description: Performs daily dataset backup and cleans old versions.

🔄 System Integration

ERP Integration

Order Received → Parse Data → Configure AI Model → Start Production
      ↓                              ↓
Update Database            Production Complete → Update ERP

Description: Integrates production orders from ERP with the AI system.

Multi-Camera System

Camera 1 ↘
Camera 2 → Merge → AI Analysis → Decision Logic → Multiple Outputs
Camera 3 ↗

Description: Analyzes images from multiple cameras simultaneously.

Node Configuration

⚙️ Rosepetal Nodes

Camera Capture Node

  • Camera ID: Camera identifier
  • Resolution: Capture resolution
  • Format: JPG, PNG, RAW
  • Trigger: Manual, timer, external
  • ROI: Specific region of interest

AI Predict Node

  • Model: Trained model selection
  • Confidence Threshold: Confidence threshold
  • Output Format: JSON, image, both
  • Batch Processing: Process multiple images
  • Preprocessing: Resize, normalize

Quality Check Node

  • Pass Criteria: Criteria to approve piece
  • Fail Actions: Actions when it fails
  • Statistics: Collect statistics
  • Alerts: Configure automatic alerts

🔧 Advanced Configuration

Global Variables

javascript
// Global configuration accessible from any node
global.set("production_line", "Line_A");
global.set("shift", "Morning");
global.set("quality_threshold", 0.95);

Context Storage

  • Node context: Node local variables
  • Flow context: Variables shared in the flow
  • Global context: Globally available variables

Error Handling

javascript
// Error handling in function nodes
try {
    // Main logic
    msg.payload = processImage(msg.payload);
    return msg;
} catch (error) {
    node.error("Error processing: " + error.message, msg);
    return null;
}

Monitoring and Debugging

🔍 Debug Tools

Debug Node

  • Complete output: View entire message
  • Specific properties: Only msg.payload, msg.topic
  • Console: Show in debug sidebar
  • Node status: Visual activity indicators

Flow Analytics

  • Message tracking: Follow messages through the flow
  • Performance metrics: Processing time per node
  • Error rates: Error frequency
  • Throughput: Messages processed per second

📈 Real-time Metrics

Integrated Dashboard

  • Node status: Green/red status of each node
  • Message count: Counter of processed messages
  • Error indicators: Visual alerts of problems
  • Performance graphs: Performance charts

Alerts and Notifications

  • Email notifications: For critical errors
  • Slack integration: Team notifications
  • SMS alerts: For emergencies
  • Custom webhooks: Custom integrations

Deploy and Versioning

🚀 Deployment

Deploy Process

  1. Validate flow: Verify connections and configuration
  2. Deploy button: Apply changes to runtime
  3. Verify status: Confirm nodes are active
  4. Test flow: Test complete functionality

Deploy Types

  • Full deploy: Restarts all flows
  • Modified flows: Only modified flows
  • Modified nodes: Only changed nodes

📦 Version Management

Export/Import

  • Export flow: Download as JSON file
  • Import flow: Load from file
  • Library: Save in personal library
  • Share: Share with other users

Version Control

  • Git integration: Versioning with Git
  • Automatic backup: Backup before changes
  • Rollback: Return to previous version
  • Change history: History of modifications

Best Practices

📋 Flow Design

Organization

  • Comments: Document purpose of each section
  • Grouping: Organize related nodes
  • Colors: Use colors to differentiate types
  • Descriptive names: For nodes and variables

Performance

  • Avoid infinite loops: Control recursive flows
  • Batch processing: Group similar operations
  • Error handling: Handle errors gracefully
  • Resource cleanup: Free unused resources

🔐 Security

Credentials

  • Don't hardcode: Use external configuration
  • Encryption: Encrypt sensitive credentials
  • Access control: Limit access by roles
  • Audit trail: Record changes and access

Data Validation

  • Input validation: Validate input data
  • Sanitization: Clean potentially dangerous data
  • Rate limiting: Limit request frequency
  • Error messages: Don't expose sensitive information

Troubleshooting

❌ Common Problems

Nodes in Error State

  1. Review configuration: Verify node parameters
  2. Check connections: Confirm connectivity
  3. Debug output: View error messages
  4. Restart node: Redeploy specific node

Slow Flow

  1. Identify bottlenecks: Nodes consuming time
  2. Optimize queries: Databases and APIs
  3. Parallel processing: Parallelize operations
  4. Resource monitoring: Check CPU and memory

Message Loss

  1. Buffer overflow: Check buffer sizes
  2. Error handling: Implement error handling
  3. Message persistence: Persist critical messages
  4. Retry logic: Retry logic

🔧 Diagnostic Tools

Log Analysis

  • Node-RED logs: Runtime specific logs
  • System logs: Operating system logs
  • Custom logging: Flow specific logs
  • Log aggregation: Centralize logs for analysis

Performance Monitoring

  • CPU usage: Usage per node
  • Memory consumption: Memory consumption
  • Network I/O: Network traffic
  • Disk usage: Storage usage