AI & Automation Templates
Workflow templates for AI-powered automation: content generation, data enrichment, sentiment analysis, and intelligent task routing—all orchestrated from the terminal.
AI Content Generation Pipeline
Automate blog post creation with Claude/GPT-4, generate social media variations, and publish across platforms.
Use Case
Generate weekly blog content using AI, create social media summaries, optimize for SEO, and publish to your CMS and social channels.
Workflow Configuration
name: ai-blog-content-pipeline
description: AI-powered content generation and distribution
trigger:
type: schedule
cron: "0 9 * * 1" # Mondays at 9am
steps:
- name: generate_blog_outline
type: http
config:
method: POST
url: https://api.anthropic.com/v1/messages
headers:
x-api-key: ${ANTHROPIC_API_KEY}
anthropic-version: "2023-06-01"
Content-Type: application/json
body: |
{
"model": "claude-3-5-sonnet-20241022",
"max_tokens": 2048,
"messages": [{
"role": "user",
"content": "Generate a detailed outline for a blog post about: ${TOPIC}. Target audience: ${TARGET_AUDIENCE}. Include SEO keywords and key points."
}]
}
output: outline
- name: generate_full_article
type: http
config:
method: POST
url: https://api.anthropic.com/v1/messages
headers:
x-api-key: ${ANTHROPIC_API_KEY}
anthropic-version: "2023-06-01"
Content-Type: application/json
body: |
{
"model": "claude-3-5-sonnet-20241022",
"max_tokens": 4096,
"messages": [{
"role": "user",
"content": "Write a complete blog post based on this outline:\n\n${outline.content[0].text}\n\nMake it engaging, include examples, and optimize for SEO. Format in markdown."
}]
}
output: article
- name: generate_social_posts
type: http
config:
method: POST
url: https://api.anthropic.com/v1/messages
headers:
x-api-key: ${ANTHROPIC_API_KEY}
anthropic-version: "2023-06-01"
body: |
{
"model": "claude-3-5-sonnet-20241022",
"max_tokens": 1024,
"messages": [{
"role": "user",
"content": "Based on this blog post, create:\n1. A Twitter thread (5 tweets)\n2. A LinkedIn post\n3. A Facebook post\n\nBlog content:\n${article.content[0].text}"
}]
}
output: social
- name: publish_to_cms
type: http
config:
method: POST
url: https://your-cms.com/api/posts
headers:
Authorization: Bearer ${CMS_API_KEY}
Content-Type: application/json
body: |
{
"title": "${TOPIC}",
"content": "${article.content[0].text}",
"status": "draft",
"tags": ["${TAGS}"]
}
output: cms_post
- name: store_social_content
type: http
config:
method: POST
url: https://your-project.supabase.co/rest/v1/social_queue
headers:
apikey: ${SUPABASE_KEY}
Content-Type: application/json
body: |
{
"blog_post_id": "${cms_post.id}",
"twitter_thread": "${social.content[0].text}",
"linkedin_post": "${social.content[0].text}",
"scheduled_for": "${timestamp + 86400}"
}
- name: notify_content_team
type: http
config:
method: POST
url: ${SLACK_WEBHOOK_URL}
body: |
{
"text": "📝 AI-generated content ready for review",
"blocks": [
{
"type": "section",
"text": {
"type": "mrkdwn",
"text": "*New Blog Post Generated*\n• Topic: ${TOPIC}\n• Status: Draft\n• <${cms_post.preview_url}|Review Post>\n• Social posts queued for tomorrow"
}
}
]
}
Setup Instructions
-
Create the workflow:
loopcli loop create ai-blog-content-pipeline -
Set your secrets:
loopcli loop secrets set ANTHROPIC_API_KEY loopcli loop secrets set CMS_API_KEY loopcli loop secrets set SUPABASE_KEY -
Deploy with schedule:
loopcli loop deploy ai-blog-content-pipeline --activate
AI-Powered Data Enrichment
Enrich customer data using AI: extract company info, categorize industries, predict churn risk, and update CRM.
Use Case
When new leads are added to your CRM, use AI to research the company, categorize their industry, analyze fit score, and enrich with additional data points.
Workflow Configuration
name: ai-lead-enrichment
description: AI-powered lead data enrichment
trigger:
type: webhook
path: /webhooks/new-lead
steps:
- name: research_company
type: http
config:
method: POST
url: https://api.anthropic.com/v1/messages
headers:
x-api-key: ${ANTHROPIC_API_KEY}
anthropic-version: "2023-06-01"
body: |
{
"model": "claude-3-5-sonnet-20241022",
"max_tokens": 1024,
"messages": [{
"role": "user",
"content": "Research this company and provide:\n1. Industry category\n2. Estimated company size\n3. Key products/services\n4. Tech stack (if visible)\n5. Potential use cases for our product\n\nCompany: ${webhook.company}\nWebsite: ${webhook.website}"
}]
}
output: research
- name: calculate_fit_score
type: http
config:
method: POST
url: https://api.openai.com/v1/chat/completions
headers:
Authorization: Bearer ${OPENAI_API_KEY}
Content-Type: application/json
body: |
{
"model": "gpt-4",
"messages": [{
"role": "system",
"content": "You are a lead scoring expert. Analyze the company data and return a fit score from 0-100 and a brief explanation."
}, {
"role": "user",
"content": "Company data:\n${research.content[0].text}\n\nOur ideal customer profile:\n- Industry: ${ICP_INDUSTRY}\n- Size: ${ICP_SIZE}\n- Tech stack: ${ICP_TECH}"
}],
"temperature": 0.3
}
output: fit_score
- name: enrich_with_clearbit
type: http
config:
method: GET
url: https://company.clearbit.com/v2/companies/find?domain=${webhook.website}
headers:
Authorization: Bearer ${CLEARBIT_API_KEY}
output: clearbit
- name: update_crm
type: http
config:
method: PATCH
url: https://your-project.supabase.co/rest/v1/leads?id=eq.${webhook.lead_id}
headers:
apikey: ${SUPABASE_KEY}
Content-Type: application/json
body: |
{
"industry": "${research.content[0].text}",
"company_size": "${clearbit.metrics.employees}",
"fit_score": ${fit_score.choices[0].message.content},
"enriched": true,
"tech_stack": "${clearbit.tech}",
"updated_at": "${timestamp}"
}
- name: notify_sales_high_fit
type: http
condition: fit_score.choices[0].message.content > 75
config:
method: POST
url: ${SLACK_WEBHOOK_SALES}
body: |
{
"text": "🎯 High-fit lead enriched!",
"blocks": [
{
"type": "section",
"text": {
"type": "mrkdwn",
"text": "*High-Fit Lead Alert*\n• Company: ${webhook.company}\n• Fit Score: ${fit_score.choices[0].message.content}/100\n• Industry: ${research.content[0].text}\n• Size: ${clearbit.metrics.employees} employees\n• Recommended action: Immediate outreach"
}
}
]
}
Sentiment Analysis & Customer Support Routing
Analyze customer support tickets with AI, classify sentiment, detect urgency, and route to the right team.
Use Case
When support tickets arrive, use AI to analyze sentiment, detect urgent issues, categorize by topic, and route to specialized teams.
Workflow Configuration
name: ai-support-ticket-routing
description: AI-powered support ticket analysis and routing
trigger:
type: webhook
path: /webhooks/new-ticket
steps:
- name: analyze_ticket
type: http
config:
method: POST
url: https://api.anthropic.com/v1/messages
headers:
x-api-key: ${ANTHROPIC_API_KEY}
anthropic-version: "2023-06-01"
body: |
{
"model": "claude-3-5-sonnet-20241022",
"max_tokens": 512,
"messages": [{
"role": "user",
"content": "Analyze this support ticket and return JSON with:\n1. sentiment (positive/neutral/negative/angry)\n2. urgency (low/medium/high/critical)\n3. category (billing/technical/feature-request/bug)\n4. suggested_team (support/engineering/sales/success)\n5. summary (1 sentence)\n\nTicket:\n${webhook.subject}\n${webhook.message}"
}]
}
output: analysis
- name: create_ticket_in_system
type: http
config:
method: POST
url: https://your-project.supabase.co/rest/v1/tickets
headers:
apikey: ${SUPABASE_KEY}
Content-Type: application/json
body: |
{
"customer_email": "${webhook.email}",
"subject": "${webhook.subject}",
"message": "${webhook.message}",
"sentiment": "${analysis.content[0].text.sentiment}",
"urgency": "${analysis.content[0].text.urgency}",
"category": "${analysis.content[0].text.category}",
"assigned_team": "${analysis.content[0].text.suggested_team}",
"created_at": "${timestamp}"
}
output: ticket
- name: alert_on_critical
type: http
condition: analysis.content[0].text.urgency == 'critical'
config:
method: POST
url: ${PAGERDUTY_WEBHOOK_URL}
body: |
{
"routing_key": "${PAGERDUTY_KEY}",
"event_action": "trigger",
"payload": {
"summary": "Critical support ticket: ${webhook.subject}",
"severity": "critical",
"source": "support-ai",
"custom_details": {
"customer": "${webhook.email}",
"sentiment": "${analysis.content[0].text.sentiment}",
"ticket_id": "${ticket.id}"
}
}
}
- name: notify_team
type: http
config:
method: POST
url: ${SLACK_WEBHOOK_URL}
body: |
{
"text": "New ticket: ${webhook.subject}",
"blocks": [
{
"type": "section",
"text": {
"type": "mrkdwn",
"text": "*New Support Ticket*\n• Customer: ${webhook.email}\n• Sentiment: ${analysis.content[0].text.sentiment}\n• Urgency: ${analysis.content[0].text.urgency}\n• Category: ${analysis.content[0].text.category}\n• Routed to: ${analysis.content[0].text.suggested_team}\n• Summary: ${analysis.content[0].text.summary}"
}
}
]
}
- name: send_auto_response
type: http
config:
method: POST
url: https://api.resend.com/emails
headers:
Authorization: Bearer ${RESEND_API_KEY}
body: |
{
"from": "support@yourapp.com",
"to": ["${webhook.email}"],
"subject": "Re: ${webhook.subject}",
"html": "<p>Thanks for reaching out! We've received your ${analysis.content[0].text.category} request and our ${analysis.content[0].text.suggested_team} team will respond within ${analysis.content[0].text.urgency == 'critical' ? '1 hour' : '24 hours'}.</p>"
}
AI Code Review Assistant
Automate code review with AI: analyze pull requests, provide feedback, check for security issues, and comment on PRs.
Workflow Configuration
name: ai-code-review
description: AI-powered code review for pull requests
trigger:
type: webhook
path: /webhooks/github-pr
steps:
- name: fetch_pr_diff
type: http
config:
method: GET
url: https://api.github.com/repos/${webhook.repository.full_name}/pulls/${webhook.number}/files
headers:
Authorization: token ${GITHUB_TOKEN}
output: diff
- name: ai_code_review
type: http
config:
method: POST
url: https://api.anthropic.com/v1/messages
headers:
x-api-key: ${ANTHROPIC_API_KEY}
anthropic-version: "2023-06-01"
body: |
{
"model": "claude-3-5-sonnet-20241022",
"max_tokens": 2048,
"messages": [{
"role": "user",
"content": "Review this code diff and provide:\n1. Security issues\n2. Performance concerns\n3. Code quality suggestions\n4. Best practice violations\n\nDiff:\n${JSON.stringify(diff)}\n\nFocus on critical issues only."
}]
}
output: review
- name: comment_on_pr
type: http
config:
method: POST
url: https://api.github.com/repos/${webhook.repository.full_name}/issues/${webhook.number}/comments
headers:
Authorization: token ${GITHUB_TOKEN}
Content-Type: application/json
body: |
{
"body": "## AI Code Review\n\n${review.content[0].text}\n\n---\n*Automated review by Claude Code*"
}
- name: check_security_issues
type: cli
config:
command: |
echo "${review.content[0].text}" | grep -i "security" | wc -l
output: security_count
- name: request_security_review
type: http
condition: security_count.stdout > 0
config:
method: POST
url: https://api.github.com/repos/${webhook.repository.full_name}/pulls/${webhook.number}/requested_reviewers
headers:
Authorization: token ${GITHUB_TOKEN}
body: |
{
"reviewers": ["security-team-lead"]
}
AI Image Generation & Asset Pipeline
Generate marketing assets with AI image generation (DALL-E/Midjourney), optimize, and upload to CDN.
Workflow Configuration
name: ai-image-generation-pipeline
description: Generate and deploy AI images
trigger:
type: manual
steps:
- name: generate_images
type: http
config:
method: POST
url: https://api.openai.com/v1/images/generations
headers:
Authorization: Bearer ${OPENAI_API_KEY}
Content-Type: application/json
body: |
{
"model": "dall-e-3",
"prompt": "${IMAGE_PROMPT}",
"n": 1,
"size": "1024x1024",
"quality": "hd"
}
output: image
- name: download_image
type: cli
config:
command: |
wget -O /tmp/generated-image.png "${image.data[0].url}"
- name: optimize_image
type: cli
config:
command: |
convert /tmp/generated-image.png -quality 85 -strip /tmp/optimized-image.webp
- name: upload_to_cdn
type: http
config:
method: POST
url: https://api.cloudflare.com/client/v4/accounts/${CF_ACCOUNT_ID}/images/v1
headers:
Authorization: Bearer ${CF_API_KEY}
body_file: /tmp/optimized-image.webp
output: cdn
- name: store_metadata
type: http
config:
method: POST
url: https://your-project.supabase.co/rest/v1/assets
headers:
apikey: ${SUPABASE_KEY}
body: |
{
"prompt": "${IMAGE_PROMPT}",
"cdn_url": "${cdn.result.variants[0]}",
"created_at": "${timestamp}"
}
Getting Started
-
Install LoopCLI:
npm install -g loopcli -
Get API keys:
- Anthropic (Claude): https://console.anthropic.com
- OpenAI (GPT-4): https://platform.openai.com
-
Create your AI workflow:
loopcli loop create my-ai-workflow -
Set your AI API keys:
loopcli loop secrets set ANTHROPIC_API_KEY loopcli loop secrets set OPENAI_API_KEY -
Deploy and run:
loopcli loop deploy my-ai-workflow --activate