AI Workflow Automation
Create intelligent, automated workflows that combine AI reasoning with external tool execution. This skill enables the construction of robust pipelines for data processing, content generation, and system integration, moving beyond simple scripts to adaptive, state-aware agents.
When to Use
- Complex Pipelines: User wants to connect multiple APIs (e.g., "fetch data from X, process with Y, send to Z").
- Intelligent Automation: User wants to "automate a daily report", "build a news digest bot", or "triage customer emails".
- Background Tasks: User asks for a "background worker" or "cron job" with AI capabilities.
- Decision Support: User wants to streamline a repetitive manual process involving decision making (e.g., "approve if score > 80, else review").
Decision Flow
Determine the complexity and requirements of the automation.
User Request for Automation
│
Analyze Complexity
│
┌────┴─────────────────┐
Simple Complex
(Linear Sequence) (Branching/Looping/State)
│ │
Script Agent / Graph
Based Based
│ │
│ Need Human Approval?
│ ┌───┴───┐
│ Yes No
│ │ │
│ Human-in- Fully
│ the-loop Autonomous
│ │ │
└──────┬───────────┴───────┘
│
Select Tools & APIs
│
Define State Schema
│
Implement Logic
│
Test & Deploy
Core Concepts
- Triggers: Events that initiate the workflow (e.g., Schedule/Cron, Webhook, Manual Input, File Upload).
- Steps (Nodes): Discrete units of work.
- Action: Executing a tool or API call (deterministic).
- Reasoning: LLM processing (summarization, decision making, extraction).
- State: The shared context passed between steps (e.g.,
messages, current_data, errors).
- Routing (Edges): Logic to determine the next step based on current state (e.g., "if error, go to retry; else go to finish").
- Human-in-the-loop: Pausing execution for human review before proceeding with critical actions.
Implementation Guide
Step 1: Define the Workflow
Clearly outline the inputs, processing steps, decision points, and desired outputs.
Example: Daily Tech News Digest
- Input: RSS feeds or NewsAPI query.
- Process:
- Fetch latest articles.
- Filter for relevance (e.g., "AI", "LLM").
- Summarize each article into 3 bullet points.
- Generate an HTML email template.
- Output: Send email via SMTP or SendGrid.
Step 2: Select Tools & Manage Secrets
Identify necessary integrations and ensure API keys are managed securely (e.g., .env file).
- Data Source:
requests (Python), NewsAPI, Tavily.
- Processing:
OpenAI or Anthropic (via SpoonOS).
- Output:
smtplib, SendGrid, Slack Webhook.
Security Note: Never hardcode API keys. Use os.getenv("API_KEY").
Step 3: Build the Agent (SpoonReactSkill)
For simpler, tool-using agents, use SpoonReactSkill.
import os
from spoon_ai.agents import SpoonReactSkill
from spoon_ai.tools import Tool
from spoon_ai.llm import ChatBot
class NewsDigestAgent(SpoonReactSkill):
def __init__(self):
super().__init__(
name="news_digest_bot",
description="Fetches and summarizes tech news.",
llm=ChatBot(model="gpt-4o"),
tools=[self.fetch_news, self.send_email]
)
@Tool
def fetch_news(self, topic: str) -> str:
"""Fetches latest news about a topic. Returns JSON string of articles."""
# Mock implementation
return f"Found 5 articles about {topic}..."
@Tool
def send_email(self, recipient: str, subject: str, content: str) -> str:
"""Sends the summarized content via email."""
print(f"Sending email to {recipient}: {subject}")
return "Email sent successfully."
# Usage
async def run_agent():
agent = NewsDigestAgent()
await agent.initialize()
result = await agent.run("Send me a digest of today's AI news to user@example.com")
print(result)
Step 4: Orchestration (StateGraph)
For complex workflows with strict control flow, loops, or state management, use StateGraph.
from typing import TypedDict, Annotated
from langgraph.graph import StateGraph, END
class AgentState(TypedDict):
topic: str
articles: list
summary: str
def fetch_node(state: AgentState):
# Fetch logic
return {"articles": ["Article 1", "Article 2"]}
def summarize_node(state: AgentState):
# LLM summarization logic
summary = f"Summary of {len(state['articles'])} articles..."
return {"summary": summary}
def notify_node(state: AgentState):
# Send notification
print(f"Sending: {state['summary']}")
return {}
# Define Graph
workflow = StateGraph(AgentState)
workflow.add_node("fetch", fetch_node)
workflow.add_node("summarize", summarize_node)
workflow.add_node("notify", notify_node)
workflow.set_entry_point("fetch")
workflow.add_edge("fetch", "summarize")
workflow.add_edge("summarize", "notify")
workflow.add_edge("notify", END)
app = workflow.compile()
Example Workflows
1. Automated Code Reviewer
Goal: Automatically review new Pull Requests and post comments.
- Trigger: GitHub Webhook (PR Created).
- Step 1 (Fetch): Get PR diff using GitHub API.
- Step 2 (Analyze): Send diff to LLM with prompt "Identify bugs and security risks".
- Step 3 (Filter): Ignore minor style issues if configured.
- Step 4 (Post): Post review comments to GitHub PR.
2. Customer Support Triage
Goal: Categorize and draft responses for support tickets.
- Trigger: New ticket in Zendesk/Jira.
- Step 1 (Read): Extract ticket subject and body.
- Step 2 (Classify): LLM classifies intent (Billing, Technical, Feature Request).
- Step 3 (RAG): Retrieve relevant documentation based on classification.
- Step 4 (Draft): Generate response using retrieved docs.
- Step 5 (Human Review): Save as "Draft" status for human agent approval.
3. Social Media Content Calendar
Goal: Generate and schedule posts from a blog RSS feed.
- Trigger: New item in RSS feed.
- Step 1 (Extract): Get title, content, and URL.
- Step 2 (Generate): Create variations for Twitter (short), LinkedIn (professional), and Facebook.
- Step 3 (Image): Generate a thumbnail using DALL-E / Midjourney API.
- Step 4 (Schedule): Post to Buffer/Hootsuite API.
Tools & Integrations
| Category |
Common Tools |
Use Case |
| Communication |
Slack, Discord, Telegram, Email (SMTP/IMAP) |
Notifications, Chatbots, Alerts |
| Development |
GitHub, GitLab, Jira, Linear |
Code review, Issue tracking |
| Data/Docs |
Notion, Google Sheets, Airtable, Vector DBs |
Knowledge base, CRM, structured data |
| Social |
Twitter (X), LinkedIn, Reddit |
Content publishing, monitoring |
| Search |
Tavily, Google Search, Bing |
Real-time information retrieval |
Debugging & Monitoring
- Traceability: Use tools like LangSmith or Arize Phoenix to trace LLM calls and agent steps.
- Verbose Mode: Enable verbose logging in your agent framework to see intermediate thoughts and tool outputs.
- Dry Run: Implement a "dry run" flag that mocks side-effect actions (like sending emails or deleting files).
Security & Privacy
- Least Privilege: Give the agent only the permissions it needs (e.g., read-only access to production DBs).
- PII Redaction: Detect and redact Personally Identifiable Information before sending data to LLM providers.
- Human Approval: Always require human confirmation for high-stakes actions (e.g., transferring funds, deploying code).
Best Practices
- Idempotency: Ensure steps can be retried without side effects.
- Graceful Degradation: If a non-critical tool fails (e.g., image generation), the workflow should continue or notify the user rather than crashing.
- Modular Design: Create reusable tools (e.g., a generic
send_slack_message tool) that can be used across multiple agents.
1---2name: workflow-automation3description: Automate complex workflows and repetitive tasks using AI agents and tool integration. Use when user wants to create automated pipelines, integrate multiple services, or build task-specific agents.4license: MIT5---67# AI Workflow Automation89Create intelligent, automated workflows that combine AI reasoning with external tool execution. This skill enables the construction of robust pipelines for data processing, content generation, and system integration, moving beyond simple scripts to adaptive, state-aware agents.1011## When to Use1213- **Complex Pipelines**: User wants to connect multiple APIs (e.g., "fetch data from X, process with Y, send to Z").14- **Intelligent Automation**: User wants to "automate a daily report", "build a news digest bot", or "triage customer emails".15- **Background Tasks**: User asks for a "background worker" or "cron job" with AI capabilities.16- **Decision Support**: User wants to streamline a repetitive manual process involving decision making (e.g., "approve if score > 80, else review").1718## Decision Flow1920**Determine the complexity and requirements of the automation.**2122```23User Request for Automation24 │25 Analyze Complexity26 │27 ┌────┴─────────────────┐28 Simple Complex29 (Linear Sequence) (Branching/Looping/State)30 │ │31 Script Agent / Graph32 Based Based33 │ │34 │ Need Human Approval?35 │ ┌───┴───┐36 │ Yes No37 │ │ │38 │ Human-in- Fully39 │ the-loop Autonomous40 │ │ │41 └──────┬───────────┴───────┘42 │43 Select Tools & APIs44 │45 Define State Schema46 │47 Implement Logic48 │49 Test & Deploy50```5152## Core Concepts53541. **Triggers**: Events that initiate the workflow (e.g., Schedule/Cron, Webhook, Manual Input, File Upload).552. **Steps (Nodes)**: Discrete units of work.56 - _Action_: Executing a tool or API call (deterministic).57 - _Reasoning_: LLM processing (summarization, decision making, extraction).583. **State**: The shared context passed between steps (e.g., `messages`, `current_data`, `errors`).594. **Routing (Edges)**: Logic to determine the next step based on current state (e.g., "if error, go to retry; else go to finish").605. **Human-in-the-loop**: Pausing execution for human review before proceeding with critical actions.6162## Implementation Guide6364### Step 1: Define the Workflow6566Clearly outline the inputs, processing steps, decision points, and desired outputs.6768_Example: Daily Tech News Digest_6970- **Input**: RSS feeds or NewsAPI query.71- **Process**:72 1. Fetch latest articles.73 2. Filter for relevance (e.g., "AI", "LLM").74 3. Summarize each article into 3 bullet points.75 4. Generate an HTML email template.76- **Output**: Send email via SMTP or SendGrid.7778### Step 2: Select Tools & Manage Secrets7980Identify necessary integrations and ensure API keys are managed securely (e.g., `.env` file).8182- **Data Source**: `requests` (Python), `NewsAPI`, `Tavily`.83- **Processing**: `OpenAI` or `Anthropic` (via SpoonOS).84- **Output**: `smtplib`, `SendGrid`, `Slack Webhook`.8586**Security Note**: Never hardcode API keys. Use `os.getenv("API_KEY")`.8788### Step 3: Build the Agent (SpoonReactSkill)8990For simpler, tool-using agents, use `SpoonReactSkill`.9192```python93import os94from spoon_ai.agents import SpoonReactSkill95from spoon_ai.tools import Tool96from spoon_ai.llm import ChatBot9798class NewsDigestAgent(SpoonReactSkill):99 def __init__(self):100 super().__init__(101 name="news_digest_bot",102 description="Fetches and summarizes tech news.",103 llm=ChatBot(model="gpt-4o"),104 tools=[self.fetch_news, self.send_email]105 )106107 @Tool108 def fetch_news(self, topic: str) -> str:109 """Fetches latest news about a topic. Returns JSON string of articles."""110 # Mock implementation111 return f"Found 5 articles about {topic}..."112113 @Tool114 def send_email(self, recipient: str, subject: str, content: str) -> str:115 """Sends the summarized content via email."""116 print(f"Sending email to {recipient}: {subject}")117 return "Email sent successfully."118119# Usage120async def run_agent():121 agent = NewsDigestAgent()122 await agent.initialize()123 result = await agent.run("Send me a digest of today's AI news to user@example.com")124 print(result)125```126127### Step 4: Orchestration (StateGraph)128129For complex workflows with strict control flow, loops, or state management, use `StateGraph`.130131```python132from typing import TypedDict, Annotated133from langgraph.graph import StateGraph, END134135class AgentState(TypedDict):136 topic: str137 articles: list138 summary: str139140def fetch_node(state: AgentState):141 # Fetch logic142 return {"articles": ["Article 1", "Article 2"]}143144def summarize_node(state: AgentState):145 # LLM summarization logic146 summary = f"Summary of {len(state['articles'])} articles..."147 return {"summary": summary}148149def notify_node(state: AgentState):150 # Send notification151 print(f"Sending: {state['summary']}")152 return {}153154# Define Graph155workflow = StateGraph(AgentState)156workflow.add_node("fetch", fetch_node)157workflow.add_node("summarize", summarize_node)158workflow.add_node("notify", notify_node)159160workflow.set_entry_point("fetch")161workflow.add_edge("fetch", "summarize")162workflow.add_edge("summarize", "notify")163workflow.add_edge("notify", END)164165app = workflow.compile()166```167168## Example Workflows169170### 1. Automated Code Reviewer171172**Goal**: Automatically review new Pull Requests and post comments.1731741. **Trigger**: GitHub Webhook (PR Created).1752. **Step 1 (Fetch)**: Get PR diff using GitHub API.1763. **Step 2 (Analyze)**: Send diff to LLM with prompt "Identify bugs and security risks".1774. **Step 3 (Filter)**: Ignore minor style issues if configured.1785. **Step 4 (Post)**: Post review comments to GitHub PR.179180### 2. Customer Support Triage181182**Goal**: Categorize and draft responses for support tickets.1831841. **Trigger**: New ticket in Zendesk/Jira.1852. **Step 1 (Read)**: Extract ticket subject and body.1863. **Step 2 (Classify)**: LLM classifies intent (Billing, Technical, Feature Request).1874. **Step 3 (RAG)**: Retrieve relevant documentation based on classification.1885. **Step 4 (Draft)**: Generate response using retrieved docs.1896. **Step 5 (Human Review)**: Save as "Draft" status for human agent approval.190191### 3. Social Media Content Calendar192193**Goal**: Generate and schedule posts from a blog RSS feed.1941951. **Trigger**: New item in RSS feed.1962. **Step 1 (Extract)**: Get title, content, and URL.1973. **Step 2 (Generate)**: Create variations for Twitter (short), LinkedIn (professional), and Facebook.1984. **Step 3 (Image)**: Generate a thumbnail using DALL-E / Midjourney API.1995. **Step 4 (Schedule)**: Post to Buffer/Hootsuite API.200201## Tools & Integrations202203| Category | Common Tools | Use Case |204| :---------------- | :------------------------------------------ | :----------------------------------- |205| **Communication** | Slack, Discord, Telegram, Email (SMTP/IMAP) | Notifications, Chatbots, Alerts |206| **Development** | GitHub, GitLab, Jira, Linear | Code review, Issue tracking |207| **Data/Docs** | Notion, Google Sheets, Airtable, Vector DBs | Knowledge base, CRM, structured data |208| **Social** | Twitter (X), LinkedIn, Reddit | Content publishing, monitoring |209| **Search** | Tavily, Google Search, Bing | Real-time information retrieval |210211## Debugging & Monitoring212213- **Traceability**: Use tools like LangSmith or Arize Phoenix to trace LLM calls and agent steps.214- **Verbose Mode**: Enable verbose logging in your agent framework to see intermediate thoughts and tool outputs.215- **Dry Run**: Implement a "dry run" flag that mocks side-effect actions (like sending emails or deleting files).216217## Security & Privacy218219- **Least Privilege**: Give the agent only the permissions it needs (e.g., read-only access to production DBs).220- **PII Redaction**: Detect and redact Personally Identifiable Information before sending data to LLM providers.221- **Human Approval**: Always require human confirmation for high-stakes actions (e.g., transferring funds, deploying code).222223## Best Practices224225- **Idempotency**: Ensure steps can be retried without side effects.226- **Graceful Degradation**: If a non-critical tool fails (e.g., image generation), the workflow should continue or notify the user rather than crashing.227- **Modular Design**: Create reusable tools (e.g., a generic `send_slack_message` tool) that can be used across multiple agents.