Workflow Creation Guide
Complete guide to creating, testing, and deploying AI workflows on GreenMonkey.
Workflow Fundamentals
What is a Workflow?
A workflow is a visual representation of connected operations that:
- Process data through multiple steps
- Integrate various AI models and tools
- Automate complex tasks
- Handle logic and conditions
- Produce consistent results
Workflow Components
graph TD
A[Trigger] --> B[Input]
B --> C[Process]
C --> D[Transform]
D --> E[Output]
F[Error Handler] -.-> C
F -.-> D
Creating Your First Workflow
Step 1: Define the Goal
Before building, clearly define:
- Purpose: What problem does it solve?
- Input: What data is needed?
- Output: What should be produced?
- Users: Who will use this workflow?
Example:
Goal: Customer Feedback Analyzer
Input: CSV file with customer reviews
Output: Sentiment report with actionable insights
Users: Marketing team, Product managers
Step 2: Access Workflow Builder
- Navigate to Dashboard ā Workflows
- Click "Create New Workflow"
- Choose:
- Blank Canvas - Start from scratch
- Template - Pre-built workflow
- Import - Upload .flow file
Step 3: Design the Flow
Adding Nodes
Drag nodes from the palette:
// Node structure
{
id: 'unique-id',
type: 'node-type',
position: { x: 100, y: 100 },
data: {
label: 'Node Label',
config: {
// Node-specific configuration
}
}
}
Connecting Nodes
Draw connections between nodes:
- Click output port
- Drag to input port
- Release to connect
// Connection structure
{
id: 'connection-id',
source: 'node-1',
sourceHandle: 'output',
target: 'node-2',
targetHandle: 'input'
}
Node Configuration
Input Nodes
Form Input
Type: input/form
Config:
fields:
- name: customer_name
type: text
required: true
- name: feedback
type: textarea
required: true
- name: rating
type: number
min: 1
max: 5
File Upload
Type: input/file
Config:
accept: [.csv, .xlsx, .json]
maxSize: 10MB
parse: true
encoding: UTF-8
API Webhook
Type: input/webhook
Config:
path: /webhooks/feedback
method: POST
auth: bearer_token
validate:
- field: source
required: true
Processing Nodes
AI Processor Configuration
{
type: 'processor/ai',
data: {
label: 'Sentiment Analysis',
config: {
provider: 'openai',
model: 'gpt-4',
prompt: `Analyze the sentiment of this feedback:
{{feedback}}
Return JSON with:
- sentiment: positive/negative/neutral
- score: 0-100
- key_points: array of main points
- suggested_action: recommendation`,
temperature: 0.3,
maxTokens: 500,
responseFormat: 'json'
}
}
}
Data Transformer
{
type: 'processor/transform',
data: {
label: 'Aggregate Results',
config: {
operation: 'aggregate',
groupBy: 'category',
calculations: [
{ field: 'sentiment_score', op: 'average' },
{ field: 'feedback', op: 'count' }
]
}
}
}
Logic Nodes
Conditional Routing
{
type: 'logic/condition',
data: {
label: 'Route by Sentiment',
config: {
conditions: [
{
if: 'sentiment === "negative"',
then: 'alert-team',
priority: 1
},
{
if: 'score < 50',
then: 'escalate',
priority: 2
},
{
else: 'standard-process'
}
]
}
}
}
Loop Configuration
{
type: 'logic/loop',
data: {
label: 'Process Each Review',
config: {
iterator: 'review',
source: '{{reviews}}',
parallel: true,
maxConcurrent: 5,
continueOnError: true
}
}
}
Advanced Workflow Features
Variables and Context
Setting Variables
// In any node
{
config: {
output: {
variableName: 'totalReviews',
value: '{{count(reviews)}}'
}
}
}
Using Variables
// Reference in prompts
'You have analyzed {{totalReviews}} reviews';
// In conditions
'{{totalReviews}} > 100';
// In transformations
"{{reviews.filter(r => r.sentiment === 'positive')}}";
Global Context
// Available everywhere
{
{
workflow.id;
}
}
{
{
workflow.name;
}
}
{
{
workflow.version;
}
}
{
{
execution.id;
}
}
{
{
execution.startTime;
}
}
{
{
user.email;
}
}
{
{
env.API_KEY;
}
} // Environment variables
Error Handling
Node-Level Error Handling
{
type: 'processor/ai',
data: {
config: {
// ... node config
},
errorHandling: {
strategy: 'retry', // retry | fallback | fail
retries: 3,
backoff: 'exponential',
fallbackValue: {
sentiment: 'unknown',
score: 0
}
}
}
}
Global Error Handler
{
type: 'error/handler',
data: {
label: 'Global Error Handler',
config: {
catchErrors: ['TypeError', 'NetworkError'],
actions: [
{
type: 'log',
level: 'error'
},
{
type: 'notify',
channel: 'slack',
message: 'Workflow failed: {{error.message}}'
}
]
}
}
}
Parallel Processing
{
type: 'logic/parallel',
data: {
label: 'Parallel Analysis',
config: {
branches: [
{ id: 'sentiment', node: 'sentiment-analysis' },
{ id: 'keywords', node: 'keyword-extraction' },
{ id: 'entities', node: 'entity-recognition' }
],
waitForAll: true,
timeout: 30000,
combineResults: {
strategy: 'merge',
outputKey: 'analysis'
}
}
}
}
Testing Workflows
Test Mode
Enable test mode:
- Click Test button
- Provide sample input
- Step through execution
- Inspect node outputs
Test Configuration
{
testMode: {
enabled: true,
mockData: {
'api-call': { status: 200, data: [...] },
'ai-processor': { response: 'Mocked response' }
},
breakpoints: ['node-3', 'node-7'],
slowMode: true, // Visual execution
logLevel: 'verbose'
}
}
Unit Testing Nodes
Test individual nodes:
// Test AI processor
const testCases = [
{
input: { feedback: 'Great product!' },
expected: { sentiment: 'positive', score: 90 },
},
{
input: { feedback: 'Terrible experience' },
expected: { sentiment: 'negative', score: 20 },
},
];
for (const test of testCases) {
const result = await node.execute(test.input);
assert.equal(result.sentiment, test.expected.sentiment);
}
Integration Testing
Test complete workflows:
describe('Customer Feedback Workflow', () => {
it('should process positive feedback correctly', async () => {
const workflow = await loadWorkflow('feedback-analyzer');
const result = await workflow.execute({
reviews: [
{ text: 'Excellent service!', rating: 5 },
{ text: 'Very satisfied', rating: 4 },
],
});
expect(result.summary.averageSentiment).toBe('positive');
expect(result.summary.averageRating).toBe(4.5);
});
});
Workflow Optimization
Performance Tips
- Minimize AI Calls
// Bad: Multiple calls
const sentiment = await analyzeSentiment(text);
const keywords = await extractKeywords(text);
// Good: Combined call
const analysis = await analyzeText(text, ['sentiment', 'keywords']);
- Cache Results
{
type: 'processor/cache',
config: {
key: '{{hash(input)}}',
ttl: 3600,
storage: 'redis'
}
}
- Batch Processing
{
type: 'processor/batch',
config: {
batchSize: 100,
operation: 'sentiment_analysis',
parallel: true
}
}
Cost Optimization
Track and minimize costs:
{
monitoring: {
trackCosts: true,
budgetLimit: 10.00, // $10 per execution
alerts: [
{
threshold: 0.8, // 80% of budget
action: 'warn'
},
{
threshold: 1.0, // 100% of budget
action: 'stop'
}
]
}
}
Deploying Workflows
Deployment Options
1. Manual Trigger
trigger:
type: manual
permissions:
- role: owner
- role: team_member
2. Scheduled Execution
trigger:
type: schedule
config:
cron: '0 9 * * MON-FRI' # 9 AM weekdays
timezone: 'America/New_York'
3. Webhook Trigger
trigger:
type: webhook
config:
path: /api/workflows/feedback-analyzer
method: POST
auth: api_key
4. Event Trigger
trigger:
type: event
config:
source: database
event: new_review_created
filters:
- rating: '< 3'
Deployment Settings
{
deployment: {
name: "Customer Feedback Analyzer",
version: "1.2.0",
description: "Analyzes customer feedback and generates insights",
// Execution limits
limits: {
maxExecutionTime: 300, // seconds
maxMemory: "2GB",
maxTokens: 10000
},
// Scaling
scaling: {
minInstances: 1,
maxInstances: 10,
scaleMetric: "queue_length",
scaleThreshold: 5
},
// Environment
environment: {
OPENAI_API_KEY: "{{secret:openai_key}}",
SLACK_WEBHOOK: "{{secret:slack_webhook}}"
}
}
}
Monitoring and Analytics
Execution Tracking
Monitor workflow performance:
{
monitoring: {
metrics: [
'execution_time',
'success_rate',
'cost_per_run',
'tokens_used'
],
dashboard: {
widgets: [
{ type: 'line_chart', metric: 'execution_time' },
{ type: 'pie_chart', metric: 'status_distribution' },
{ type: 'number', metric: 'total_executions' }
]
},
alerts: [
{
condition: 'success_rate < 0.9',
channels: ['email', 'slack']
}
]
}
}
Logging
Configure detailed logging:
{
logging: {
level: 'info', // debug | info | warn | error
destinations: [
{ type: 'console' },
{ type: 'file', path: '/logs/workflow.log' },
{ type: 'elasticsearch', index: 'workflows' }
],
// What to log
include: [
'input_data',
'node_outputs',
'execution_time',
'errors'
],
// Sensitive data
redact: [
'api_keys',
'passwords',
'credit_cards'
]
}
}
Sharing and Monetization
Publishing Workflows
Make your workflow available to others:
-
Test Thoroughly
- Run with various inputs
- Handle edge cases
- Verify outputs
-
Document
- Clear description
- Input requirements
- Expected outputs
- Example use cases
-
Set Pricing
pricing: model: usage_based rate: 0.10 # per execution free_tier: 10 # executions/month
-
Publish
- Add to marketplace
- Set visibility
- Enable reviews
Workflow Marketplace Listing
marketplace:
title: 'Advanced Customer Feedback Analyzer'
category: 'Business Intelligence'
description: |
Automatically analyze customer feedback to extract
sentiment, key themes, and actionable insights.
features:
- Multi-language support
- Sentiment analysis
- Theme extraction
- Trend detection
- Automated reporting
requirements:
- OpenAI API key
- Minimum 10 reviews per batch
pricing:
starter: $0.05/execution
pro: $0.03/execution (>1000/month)
enterprise: Custom
support:
documentation: true
email: true
response_time: '< 24 hours'
Best Practices
Workflow Design
ā Do:
- Start simple, iterate
- Test each node individually
- Handle errors gracefully
- Document thoroughly
- Monitor performance
ā Don't:
- Over-complicate flows
- Ignore edge cases
- Hard-code sensitive data
- Skip testing
- Forget about costs
Security
- API Key Management
// Use environment variables
config: {
apiKey: '{{env.OPENAI_API_KEY}}';
}
// Never hard-code
config: {
apiKey: 'sk-abc123...'; // NO!
}
- Data Privacy
{
privacy: {
pii_detection: true,
redact_sensitive: true,
encryption: 'at_rest',
retention: '30_days'
}
}
Maintenance
Regular maintenance checklist:
- Review execution logs
- Update node versions
- Optimize slow nodes
- Clean up unused variables
- Update documentation
- Test with new data
Troubleshooting
Common Issues
Issue | Cause | Solution |
---|---|---|
Workflow won't save | Invalid connections | Check all nodes connected |
Execution fails | Missing config | Verify all required fields |
Slow performance | Inefficient design | Optimize node arrangement |
High costs | Too many AI calls | Batch operations |
Debug Techniques
- Enable Verbose Logging
{
debug: {
verboseLogging: true,
logAllNodeOutputs: true,
preserveExecutionData: true
}
}
- Use Breakpoints
- Click node to add breakpoint
- Execution pauses at node
- Inspect data and state
- Test Data
- Start with simple inputs
- Gradually increase complexity
- Test edge cases