ClawKit Logo
ClawKitReliability Toolkit

Use Case: Data Analysis & Reporting

pull metrics ยท run Python ยท generate summaries ยท post on schedule

What you'll build

An agent that pulls data from an API or CSV, runs a Python script to process it, and posts a formatted summary to Slack or Telegram on a schedule โ€” without you touching any code.

Skills you need

SkillWhat it unlocksRequired?
python-runnerExecute Python scripts inline โ€” pandas, numpy, matplotlib all workCore
file-readerRead CSV, JSON, or text files from the local filesystemCore
http-requestCall REST APIs to pull live metrics โ€” JSON or CSV responsesCore
file-writerSave analysis output to CSV, JSON, or MarkdownRecommended
chart-generatorProduce PNG charts from data using matplotlib โ€” embeds in reportsOptional
notion-writerPush summaries to a Notion database as structured pagesOptional

SOUL.md template

SOUL.md โ€” data analysis agent
# Data Analysis Agent

You pull data from files or APIs, analyse it with Python, and produce clear summaries.

## Identity
- Name: DataBot
- Role: Automated data analysis and reporting

## Analysis process
1. Fetch the data (file path or API endpoint)
2. Write a Python script to process it โ€” use pandas for tabular data
3. Execute the script and capture the output
4. Produce a report: key numbers first, then trends, then anomalies
5. Post the report to the configured channel

## Report format
- Lead with the 3 most important numbers in bold
- Use a markdown table for comparisons (max 5 rows, add "Top 5" label if truncated)
- Flag anomalies: anything >2 standard deviations from the past 4-week average
- End with one sentence: what to watch next week

## Python rules
- Use pandas, numpy โ€” do not install new packages
- Handle missing values explicitly (dropna or fillna, state which)
- Print results clearly โ€” the script output becomes the report source
- Save charts to ~/reports/charts/ if generated

Config setup

Python must be installed with pandas and numpy. The python-runner skill uses the system Python.

openclaw.json โ€” data analysis agent
{
  "skills": [
    "official-python-runner",
    "official-file-reader",
    "official-http-request",
    "official-file-writer"
  ],
  "model": "claude-sonnet-4-5",
  "soulPath": "./SOUL.md",
  "channel": {
    "type": "slack",
    "botToken": "xoxb-your-bot-token",
    "appToken": "xapp-your-app-token"
  }
}
Install Python dependencies
pip install pandas numpy matplotlib

Example: weekly metrics report

A complete example โ€” pulling data from a JSON API and producing a weekly summary. Send this prompt to the agent:

"Fetch this week's data from https://api.myapp.com/metrics?range=7d (API key in env: METRICS_API_KEY), analyse daily active users and revenue, flag any days below the 4-week average, and post a summary to Slack"

The agent will write and run a Python script like this internally:

Example Python script the agent generates
import pandas as pd
import numpy as np
import json, os, requests

# Fetch data
resp = requests.get(
    "https://api.myapp.com/metrics",
    params={"range": "7d"},
    headers={"Authorization": f"Bearer {os.environ['METRICS_API_KEY']}"}
)
data = resp.json()
df = pd.DataFrame(data["days"])
df["date"] = pd.to_datetime(df["date"])

# Key metrics
avg_dau = df["dau"].mean()
total_rev = df["revenue"].sum()
peak_day = df.loc[df["dau"].idxmax(), "date"].strftime("%a %b %d")

# Anomalies (below 4-week avg would need more data; flag below this week's avg)
low_days = df[df["dau"] < avg_dau * 0.8]

print(f"**Weekly Summary**")
print(f"Avg DAU: {avg_dau:,.0f} | Total Revenue: ${total_rev:,.2f} | Peak: {peak_day}")
if not low_days.empty:
    for _, row in low_days.iterrows():
        print(f"โš  Low DAU on {row['date'].strftime('%a')}: {row['dau']:,} (80% threshold)")

Scheduled reports

Add to openclaw.json โ€” weekly report every Monday 9am
{
  "crons": [
    {
      "name": "Weekly metrics report",
      "schedule": "0 9 * * 1",
      "task": "Fetch last 7 days from https://api.myapp.com/metrics?range=7d using METRICS_API_KEY. Analyse DAU and revenue, flag anomalies, post a markdown summary to Slack."
    },
    {
      "name": "Daily CSV check",
      "schedule": "0 8 * * *",
      "task": "Read ~/data/daily-export.csv, check if row count is within 10% of yesterday's file in the same folder. If not, post an alert to Slack."
    }
  ]
}

Common issues

โš  Python script fails silently

The agent catches script errors and includes them in the response. Ask: "Run the script and show me the full output including any errors." Add explicit print() statements for intermediate values.

โš  pandas not found

The python-runner skill uses your system Python. Run: pip install pandas numpy matplotlib โ€” or specify the virtualenv path in your SOUL.md: "Python path: /path/to/venv/bin/python".

โš  API returns paginated data but agent only reads first page

Specify in your prompt: "The API paginates โ€” fetch all pages using the next_cursor field until it is null." The agent will write a loop in the Python script.

โš  Report posts to wrong Slack channel

Add channel ID to your cron task: "post to #data-reports (channel ID C012AB3CD)". The Slack skill needs the channel ID, not the display name.

Did this guide solve your problem?

Need Help?

Try our automated tools to solve common issues instantly.