Workflows
Autonomous agents that monitor conditions and take action. Set up intelligent automation for your farming operation.
Workflows are autonomous agents that run in the background, monitoring conditions and taking action on your behalf. They combine triggers, conditions, and actions to automate routine tasks and send timely alerts.
How Workflows Work
Every workflow follows this pattern:
TRIGGER → EVALUATE CONDITIONS → EXECUTE ACTIONS
- Trigger - Something initiates the workflow (schedule, webhook, threshold, message)
- Conditions - Optional rules that determine if actions should run
- Actions - What happens when triggered (notifications, tasks, API calls, AI responses)
Workflow Types
Scheduled Workflows
Run on a schedule (daily, weekly, or custom cron):
- Daily Farm Brief - Morning summary of weather, tasks, and alerts
- Weekly Equipment Check - Maintenance reminders based on hours
- Monthly Reports - Automated report generation and delivery
Threshold Workflows
Monitor data and trigger when thresholds are crossed:
- Weather Alerts - Notify when frost, heat, or wind thresholds are exceeded
- Equipment Alerts - Alert when service intervals are due
- Inventory Alerts - Notify when supplies run low
Webhook Workflows
Triggered by external systems via HTTP:
- IoT Sensors - React to sensor data from connected devices
- External APIs - Integrate with third-party agricultural systems
- Custom Integrations - Build your own triggers
Messaging Workflows
Triggered by incoming messages:
- WhatsApp Commands - Respond to team messages
- Telegram Bots - Field queries via chat
- SMS Keywords - Simple mobile interactions
Creating a Workflow
From the Catalog
The fastest way to get started:
- Navigate to Workflows
- Click Add Workflow
- Browse the catalog by category
- Select a template
- Configure parameters
- Activate
From Scratch
For custom workflows:
- Navigate to Workflows
- Click Add Workflow
- Choose Start from Scratch
- Select a trigger type
- Add conditions (optional)
- Add actions
- Test and activate
Trigger Types
Cron (Scheduled)
Run workflows on a schedule:
| Schedule | Cron Expression | Example Use |
|---|---|---|
| Daily at 6am | 0 6 * * * | Morning briefing |
| Weekly Monday | 0 8 * * 1 | Weekly review |
| Every 4 hours | 0 */4 * * * | Regular monitoring |
| First of month | 0 9 1 * * | Monthly reports |
Webhook
Receive HTTP POST requests:
POST https://headlands.ag/api/webhooks/{workflow_id}Content-Type: application/json { "sensor_id": "field-station-1", "temperature": 28, "humidity": 85}Webhook data is available in conditions and actions as {{webhook.field_name}}.
Threshold
Monitor data sources continuously:
- Weather - Temperature, wind, precipitation, humidity
- Equipment - Hours, maintenance status, fuel
- Inventory - Stock levels, expiration dates
- Custom - Any numeric field in your data
Messaging
Respond to incoming messages:
- WhatsApp - Link your WhatsApp Business account
- Telegram - Connect your Telegram bot
- Message content available as
{{message.text}}
Conditions
Conditions determine whether actions execute after a trigger fires.
Field Conditions
Check field-level data:
IF field.current_crop = "corn"
AND field.growth_stage = "V6"
Temporal Conditions
Time-based rules:
IF day_of_week IN ["Monday", "Wednesday", "Friday"]
AND hour BETWEEN 6 AND 18
Value Conditions
Compare values using JSONPath:
IF webhook.temperature > 95
OR webhook.humidity < 20
Logic Conditions
Combine conditions:
- AND - All conditions must be true
- OR - Any condition can be true
- NOT - Inverts a condition
Actions
What happens when a workflow executes.
Notification
Send alerts via multiple channels:
| Channel | Configuration |
|---|---|
| Push | Sends to mobile/web app |
| To specified addresses | |
| SMS | To phone numbers (Twilio) |
| To linked WhatsApp number | |
| Telegram | To linked Telegram chat |
Task Creation
Automatically create tasks:
Create task:
Title: "Check field {{trigger.field_name}}"
Description: "Temperature exceeded threshold at {{trigger.value}}°F"
Priority: High
Assign to: Current user
Webhook Call
Call external APIs:
POST https://api.external-system.com/alerts
Headers:
Authorization: Bearer {{secrets.API_KEY}}
Body:
{
"alert": "{{trigger.description}}",
"severity": "high"
}
AI Response
Generate intelligent responses:
Generate AI response:
Context: Include recent weather and field data
Prompt: "Provide recommendations for the current conditions"
Send via: WhatsApp
Record Update
Update data in your knowledge base:
Update equipment record:
Equipment: Tractor 42
Field: last_alert_date
Value: {{now}}
Skill Execution
Run built-in skills:
Execute skill:
Skill: withdrawal_period_calculator
Inputs:
drug_name: "LA-200"
treatment_date: "{{trigger.date}}"
Store result in: withdrawal_date
Action Chains
Actions can be chained together, with later actions using results from earlier ones:
1. Execute skill: weather_analysis
Store as: weather_data
2. Generate AI response:
Include: {{weather_data.recommendation}}
Store as: ai_recommendation
3. Send notification:
Message: {{ai_recommendation}}
Variables & Templates
Available Variables
| Source | Variables |
|---|---|
| Trigger | {{trigger.type}}, {{trigger.data.*}} |
| Webhook | {{webhook.*}} (any posted field) |
| Message | {{message.text}}, {{message.from}} |
| Context | {{now}}, {{today}}, {{user.name}} |
| Previous actions | Named results from earlier actions |
Template Syntax
Use Handlebars-style templates:
Good morning {{user.name}}!
Today's weather: {{weather.description}}
High: {{weather.high}}°F / Low: {{weather.low}}°F
Upcoming tasks:
{{#each tasks}}
- {{this.title}} (due {{this.due_date}})
{{/each}}
Testing Workflows
Test Run
Before activating:
- Click Test on the workflow
- Provide sample trigger data
- Review condition evaluation
- Preview action outputs
- Confirm expected behavior
Execution History
Monitor running workflows:
- Navigate to Executions in sidebar
- Filter by workflow
- View execution details:
- Trigger data
- Condition results
- Action outcomes
- Errors or warnings
Workflow Catalog
Headlands includes 40+ pre-built workflow templates:
Tier Zero (Free)
- Daily Farm Brief
- Weather Alert Monitor
- Task Reminder
- Simple WhatsApp Responder
Tier One (Professional)
- Spray Window Advisor
- Equipment Maintenance Scheduler
- Cattle Health Monitor
- Harvest Coordinator
- Soil Moisture Analyst
- Pest Pressure Tracker
- Compliance Deadline Manager
- Market Price Watcher
- Irrigation Scheduler
- Feed Inventory Monitor
- Grazing Rotation Planner
Tier Two (Enterprise)
- Custom integration templates
- Multi-farm aggregators
- Advanced analytics workflows
- Third-party system connectors
Browse the full catalog at Workflow Catalog.
Best Practices
Start Simple
Begin with catalog templates and customize gradually. A working simple workflow beats a complex broken one.
Use Descriptive Names
Name workflows clearly:
- Good: "Daily Morning Brief - 6am - Push + Email"
- Bad: "Workflow 1"
Test Thoroughly
Always test with realistic data before activating. Check both true and false condition paths.
Monitor Executions
Review execution history weekly. Look for:
- Unexpected failures
- Excessive executions
- Missing expected runs
Document Custom Workflows
Add descriptions explaining:
- Why the workflow exists
- What triggers it
- What actions it takes
- Who should be notified of issues
Troubleshooting
Workflow Not Triggering
- Check that the workflow is activated (toggle on)
- Verify the trigger configuration (correct time, webhook URL, etc.)
- Review execution history for errors
- Check condition logic isn't blocking all executions
Actions Not Executing
- Verify conditions are evaluating to true
- Check action configuration for errors
- Ensure notification channels are configured (phone numbers, emails)
- Review execution logs for specific error messages
Notifications Not Received
- Confirm notification channel is set up in Settings
- Check spam/junk folders for email
- Verify phone numbers include country code
- Ensure WhatsApp/Telegram is properly linked