Pre-built AINL workflow templates for common use cases.
Creates a REST API endpoint that fetches and processes data.
Use when:
- Building API services
- Creating data fetch endpoints
- Need authenticated API calls
Frame variables:
api_key: Authentication tokenbase_url: API base URL
Checks a service health endpoint and alerts if unhealthy.
Use when:
- Monitoring service health
- Need recurring checks
- Want automated alerts
Frame variables:
health_url: Health check endpointalert_webhook: Where to send alerts
Schedule: Every 5 minutes (*/5 * * * *)
ETL workflow: Extract from API, Transform, Load to warehouse.
Use when:
- Building data pipelines
- Daily data exports
- Need scheduled ETL
Frame variables:
source_api: Data source URLwarehouse_url: Data warehouse URLapi_key: API authentication
Schedule: Daily at 2 AM (0 2 * * *)
Monitors Solana wallet balance and alerts if below threshold.
Use when:
- Monitoring crypto wallets
- Need balance alerts
- Working with Solana
Frame variables:
wallet_address: Solana wallet addressthreshold_sol: Alert threshold in SOLalert_webhook: Where to send alerts
Schedule: Hourly (0 * * * *)
AI-powered content moderation workflow.
Use when:
- Content moderation
- AI classification tasks
- Need LLM in workflows
Frame variables:
content: Content to moderatewebhook_url: Where to send flags
Requirements: AINL_CONFIG with LLM provider setup
Approval workflow with conditional logic.
Use when:
- Multi-step processes
- Approval workflows
- Conditional automation
Frame variables:
request_id: Request to processapi_base_url: API base URLapproval_webhook: Manual approval URL
# Copy template
cp templates/ainl/monitor_workflow.ainl my_monitor.ainl
# Edit frame variables and logic
nano my_monitor.ainl
# Validate
ainl validate my_monitor.ainl --strict
# Run
ainl run my_monitor.ainl --frame '{"health_url":"https://api.example.com/health","alert_webhook":"https://hooks.slack.com/..."}'"Create a health monitor based on the monitor_workflow.ainl template for https://api.example.com/health"
Claude will customize the template for your use case.
All templates follow this structure:
# Title and description
# Frame variable declarations (# frame: name: type)
workflow_name [@cron "schedule" | @api "/path"]:
in: parameters
# Steps
result = adapter.operation args
# Conditional logic (if needed)
if condition:
# then branch
# Output
out {result: value}
Templates use frame variables for configuration. These are passed at runtime:
// In ainl_run MCP call
{
source: "...",
frame: {
api_key: "sk-...",
webhook_url: "https://...",
threshold: 100
}
}Declare frame variables in comments:
# frame: api_key: string
# frame: threshold: number
Templates use these adapters (enable in ainl_run):
- http:
api_endpoint.ainl,monitor_workflow.ainl,data_pipeline.ainl,multi_step_automation.ainl - solana:
blockchain_monitor.ainl - llm:
llm_workflow.ainl(requires config) - core: All templates (always available)
Example ainl_run call:
ainl_run({
source: "...",
frame: {...},
adapters: {
enable: ["http"],
http: {
allow_hosts: ["api.example.com"],
timeout_s: 30
}
}
})- Always validate first:
ainl validate template.ainl --strict - Test with sample data: Use
ainl_runwith test frame variables - Start simple: Copy a template, test it, then customize
- Use frame hints: Add
# frame:comments for all variables - Set timeouts: Specify timeout for HTTP calls (3rd argument)
- Handle errors: Use
ifconditions to check for failures
Using these templates for recurring tasks:
| Template | Traditional (Python) | AINL | Savings |
|---|---|---|---|
| Monitor (hourly) | 12,000 tokens/day | 120 tokens/day | 99% |
| Pipeline (daily) | 500 tokens/run | 5 tokens/run | 99% |
| API endpoint | 300 tokens/call | 5 tokens/call | 98% |
Compile once, run many times = massive token savings!
To add a new template:
- Create
.ainlfile following the structure - Add frame variable comments
- Test with
ainl validateandainl run - Document in this README
- Submit PR
- AINL Language Guide:
../docs/AINL_LANGUAGE_GUIDE.md - MCP Tools: Use
ainl_capabilitiesto see available adapters - AINL Spec: https://ainativelang.com/docs