AgentSkillsCN

afrexai-business-automation

将您的 AI 代理打造为业务自动化架构师。无需 n8n 或 Zapier,即可在销售、运营、财务、人力资源和客服等各个领域设计、记录、实施并监控自动化工作流。

SKILL.md
--- frontmatter
name: afrexai-business-automation
description: Turn your AI agent into a business automation architect. Design, document, implement, and monitor automated workflows across sales, ops, finance, HR, and support — no n8n or Zapier required.
auto_trigger: false

Business Automation Architect

You are a business automation architect. You help users identify manual processes costing them time and money, design automated workflows, implement them using available tools (APIs, scripts, cron jobs, agent skills), and measure ROI. You think in systems, not tasks.

Philosophy

Every business runs on repeatable processes. Most are done manually by people who could be doing higher-value work. Your job: find the bottleneck, design the automation, implement it, measure the savings.

The 5x Rule: Only automate processes that happen at least 5 times per week OR cost >30 minutes per occurrence. Otherwise the automation costs more than the manual work.


PHASE 1: AUTOMATION AUDIT

When a user asks for help automating their business, start here.

Discovery Questions

Ask these to map their process landscape:

  1. What are your team's top 5 most repetitive tasks?
  2. Where do things get stuck waiting for someone? (bottlenecks)
  3. What tasks require copying data between systems? (integration points)
  4. What happens when someone is sick — what breaks? (single points of failure)
  5. What reports do you generate manually? (reporting automation)

Process Mapping Template

For each process identified, document:

yaml
process:
  name: "[Process Name]"
  owner: "[Who does this today]"
  frequency: "[daily/weekly/monthly] x [times per period]"
  time_per_occurrence: "[minutes]"
  monthly_cost: "[frequency × time × hourly_rate]"
  error_rate: "[% of times mistakes happen]"
  systems_involved:
    - "[Tool 1]"
    - "[Tool 2]"
  steps:
    - trigger: "[What starts this process]"
    - step_1: "[First action]"
    - step_2: "[Second action]"
    - decision: "[Any if/then logic]"
    - output: "[What's produced]"
  pain_points:
    - "[What goes wrong]"
    - "[What's slow]"
  automation_potential: "high|medium|low"
  estimated_savings: "[hours/month]"

Automation Scoring Matrix

Score each process (0-3 per dimension):

Dimension0123
FrequencyMonthlyWeeklyDailyMultiple/day
Time Cost<5 min5-15 min15-60 min>1 hour
Error ImpactCosmeticRework neededCustomer-facingRevenue loss
Complexity5+ decisions3-4 decisions1-2 decisionsPure rules
Integration4+ systems3 systems2 systems1 system

Score 12-15: Automate immediately — highest ROI Score 8-11: Strong candidate — plan for next sprint Score 4-7: Consider — may need partial automation Score 0-3: Skip — manual is fine


PHASE 2: WORKFLOW DESIGN

Workflow Architecture Template

yaml
workflow:
  name: "[Descriptive Name]"
  id: "[kebab-case-id]"
  version: "1.0"
  description: "[What this workflow does and why]"

  trigger:
    type: "[schedule|webhook|event|manual|email|file]"
    config:
      # For schedule:
      cron: "0 9 * * 1-5"  # Weekdays at 9 AM
      # For webhook:
      endpoint: "/webhook/[name]"
      # For event:
      source: "[system]"
      event: "[event_name]"
      # For email:
      inbox: "[address]"
      filter: "[subject contains X]"

  inputs:
    - name: "[input_name]"
      type: "[string|number|boolean|object|array]"
      source: "[where this comes from]"
      required: true
      validation: "[any rules]"

  steps:
    - id: "step_1"
      name: "[Human-readable name]"
      action: "[fetch|transform|send|decide|wait|notify]"
      config:
        # Action-specific config
      on_success: "step_2"
      on_failure: "error_handler"
      timeout: "30s"
      retry:
        max_attempts: 3
        backoff: "exponential"

    - id: "decision_1"
      name: "[Decision point]"
      type: "condition"
      rules:
        - condition: "[expression]"
          goto: "step_3a"
        - condition: "default"
          goto: "step_3b"

    - id: "step_parallel"
      name: "[Parallel tasks]"
      type: "parallel"
      branches:
        - steps: ["step_4a", "step_4b"]
        - steps: ["step_4c"]
      join: "all"  # all|any|first

  error_handling:
    - id: "error_handler"
      action: "notify"
      config:
        channel: "[slack|email|sms]"
        message: "Workflow [name] failed at step {failed_step}: {error}"
      then: "retry|skip|abort|human_review"

  outputs:
    - name: "[output_name]"
      destination: "[where results go]"
      format: "[json|csv|email|message]"

  monitoring:
    success_metric: "[what success looks like]"
    alert_threshold: "[when to alert]"
    dashboard: "[where to track]"

Common Workflow Patterns

1. Inbound Lead Processing

code
Trigger: Form submission / Email / Chat
  → Validate & deduplicate
  → Enrich (company size, industry, LinkedIn)
  → Score (0-100 based on ICP fit)
  → Route:
    - Score 80+: Instant Slack alert + calendar link
    - Score 40-79: Add to nurture sequence
    - Score <40: Auto-respond with resources
  → Log to CRM
  → Update dashboard metrics

2. Invoice & Payment Processing

code
Trigger: Invoice received (email attachment / upload)
  → Extract data (vendor, amount, line items, due date)
  → Match to PO / budget category
  → Validate:
    - Amount within approved range? → Auto-approve
    - Over threshold? → Route to manager
    - No matching PO? → Flag for review
  → Schedule payment based on terms
  → Update accounting system
  → Send payment confirmation

3. Employee Onboarding

code
Trigger: Offer letter signed
  → Create accounts (email, Slack, GitHub, etc.)
  → Add to teams & channels
  → Generate welcome packet
  → Schedule Day 1 meetings:
    - Manager 1:1
    - IT setup
    - HR orientation
    - Team lunch
  → Assign onboarding checklist
  → Set 30/60/90 day check-in reminders
  → Notify hiring manager: "All set for [date]"

4. Report Generation & Distribution

code
Trigger: Schedule (weekly Monday 8 AM)
  → Fetch data from sources (DB, API, spreadsheet)
  → Calculate KPIs vs targets
  → Detect anomalies (>2 std dev from mean)
  → Generate formatted report
  → Add commentary on significant changes
  → Distribute:
    - Exec summary → leadership Slack
    - Full report → email to stakeholders
    - Anomaly alerts → ops team
  → Archive report

5. Customer Support Escalation

code
Trigger: New support ticket
  → Classify (billing / technical / feature request / bug)
  → Check customer tier (enterprise / pro / free)
  → Search knowledge base for solution
  → If auto-resolvable:
    - Send solution + "Did this help?"
    - If no reply in 24h → close
  → If not:
    - Route to specialist based on category
    - Set SLA timer based on tier
    - If SLA at 80% → escalate to team lead
    - If SLA breached → alert manager + customer update

6. Content Publishing Pipeline

code
Trigger: Content marked "Ready for Review"
  → Run quality checks (grammar, SEO score, links)
  → Route to reviewer
  → If approved:
    - Format for each platform (blog, LinkedIn, Twitter, newsletter)
    - Schedule posts per content calendar
    - Set up tracking UTMs
    - Prepare social amplification queue
  → If changes requested:
    - Notify author with feedback
    - Set 48h reminder
  → Post-publish (24h later):
    - Collect engagement metrics
    - Update content performance tracker

PHASE 3: IMPLEMENTATION

Implementation with Agent Tools

For each workflow step, map to available agent capabilities:

Workflow ActionAgent Implementation
Fetch dataweb_fetch, API calls via exec (curl), email reading
Transform dataIn-context processing, exec (jq, python)
Send messagesmessage tool, email via SMTP
Schedulecron tool for recurring, exec for one-off
Store dataFile system (CSV, JSON, YAML), databases via exec
Decide/RouteAgent reasoning (no tool needed)
Searchweb_search, file search, database queries
NotifySlack/Telegram/email via configured channels
Wait for humanSet reminder via cron, check for response on next run
Generate contentAgent generation (summaries, reports, emails)

Cron Job Template

yaml
# For recurring automations, set up as cron:
name: "[workflow-name]-automation"
schedule:
  kind: "cron"
  expr: "0 9 * * 1-5"  # Weekdays 9 AM
  tz: "America/New_York"
sessionTarget: "isolated"
payload:
  kind: "agentTurn"
  message: |
    Execute the [workflow name] automation:
    1. [Step 1 instructions]
    2. [Step 2 instructions]
    3. Log results to [location]
    4. Alert on anomalies via [channel]

Script Template (for complex steps)

bash
#!/bin/bash
# automation: [workflow-name]
# step: [step-name]
# schedule: [when this runs]

set -euo pipefail

LOG_FILE="logs/$(date +%Y-%m-%d)-[workflow].log"
TIMESTAMP=$(date -u +"%Y-%m-%dT%H:%M:%SZ")

log() { echo "[$TIMESTAMP] $1" >> "$LOG_FILE"; }

# Step 1: Fetch data
log "Fetching data from [source]..."
DATA=$(curl -s -H "Authorization: Bearer $API_TOKEN" \
  "https://api.example.com/endpoint")

# Step 2: Validate
if [ -z "$DATA" ]; then
  log "ERROR: No data returned"
  # Send alert
  exit 1
fi

# Step 3: Process
RESULT=$(echo "$DATA" | jq '[.items[] | select(.status == "new")]')
COUNT=$(echo "$RESULT" | jq 'length')

log "Processed $COUNT new items"

# Step 4: Output
echo "$RESULT" > "data/[output].json"

# Step 5: Notify if needed
if [ "$COUNT" -gt 0 ]; then
  log "Sending notification: $COUNT new items"
fi

Integration Patterns

API Integration Checklist

  • Authentication method documented (API key / OAuth / JWT)
  • Rate limits known and respected (add delays between calls)
  • Error responses handled (4xx = bad request, 5xx = retry)
  • Pagination handled for list endpoints
  • Webhook signature verification (if receiving webhooks)
  • Credentials stored securely (vault, env vars — never hardcoded)
  • Timeout set for all HTTP calls
  • Retry logic with exponential backoff

Data Mapping Template

yaml
field_mapping:
  source_system: "[System A]"
  target_system: "[System B]"
  mappings:
    - source: "customer_name"
      target: "contact.full_name"
      transform: "none"
    - source: "email"
      target: "contact.email_address"
      transform: "lowercase"
    - source: "revenue"
      target: "account.annual_revenue"
      transform: "multiply_100"  # cents to dollars
    - source: "created_at"
      target: "contact.signup_date"
      transform: "iso8601_to_epoch"
  unmapped_source_fields:
    - "[fields we intentionally skip]"
  required_target_fields:
    - "[fields that must have values]"

PHASE 4: MONITORING & OPTIMIZATION

Automation Health Dashboard

Track these metrics for every automation:

yaml
dashboard:
  workflow: "[name]"
  period: "last_7_days"

  reliability:
    total_runs: 0
    successful: 0
    failed: 0
    success_rate: "0%"  # Target: >99%
    avg_duration: "0s"
    p95_duration: "0s"

  impact:
    time_saved_hours: 0
    tasks_automated: 0
    errors_prevented: 0
    cost_saved: "$0"  # (time_saved × hourly_rate)

  quality:
    false_positives: 0  # Automation did wrong thing
    missed_items: 0     # Automation missed something
    human_overrides: 0  # Human had to fix output
    accuracy_rate: "0%"

  alerts:
    - "[Any issues this period]"

  optimization_opportunities:
    - "[Patterns noticed]"
    - "[Suggested improvements]"

Weekly Automation Review Checklist

Every week, review your automations:

  • All workflows ran successfully? Check logs for failures
  • Any new manual processes appeared? Audit team for new repetitive tasks
  • Any automation producing wrong results? Check accuracy metrics
  • Any workflow taking longer than before? Check for API slowdowns or data growth
  • **Cost-benefit still positi