PollyHub

polly-usage-report

Clean

Generate a Polly customer usage report from the PollyView API. Fetches real-time user data, analyzes spend, engagement, and alerts, saves a historical snapshot, and sends or displays an HTML report.

SKILL.md

---
name: polly-usage-report
description: Generate a Polly customer usage report from the PollyView API. Fetches real-time user data, analyzes spend, engagement, and alerts, saves a historical snapshot, and sends or displays an HTML report. Use when the user asks to run, schedule, or view a Polly usage report, customer usage stats, or daily spend summary.
metadata:
  openclaw:
    requires:
      env:
        - POLLYVIEW_API_KEY
        - POLLYVIEW_HOST
---

# Polly Usage Report Skill

Generates a daily customer usage report from the PollyView API.

## Configuration

Set via `manage_skills config polly-usage-report --env POLLYVIEW_API_KEY=<key> POLLYVIEW_HOST=<host>`:

| Env Var | Description | Example |
|---|---|---|
| `POLLYVIEW_API_KEY` | Bearer token for the API (required) | `b51043db...` |
| `POLLYVIEW_HOST` | Base URL of the PollyView service (required) | `http://your-pollyview-host` |

Additional defaults (set in task description):
- `RECIPIENT` — email to send report to
- `DATA_FILE` — path to historical snapshot JSON

**API reference:** See `references/api.md` for endpoint docs, field descriptions, and example responses.

**Full task instructions:** See `references/task-instructions.md` for the complete step-by-step execution guide to use when creating a scheduled task.

## Workflow Summary

### Step 1: Fetch Customer Data

```
GET {POLLYVIEW_HOST}/api/v1/users
Authorization: Bearer {POLLYVIEW_API_KEY}
```

Use `fetch_url` with the Authorization header. On failure, send a failure email and stop.

**Filter:** Keep only `is_internal == false` users; exclude `@placeholder.local` emails.

### Step 2: Save Snapshot

Load history JSON from `DATA_FILE`, append `{"date", "timestamp", "users": [...]}`, write back. Initialize as `[]` if missing.

### Step 3: Analyze

1. Summary — total customers, today's spend, all-time cost
2. Top Spenders Today — by `or_usage` desc
3. Near Limit Alerts — `or_usage / or_limit >= 0.70`
4. Over Limit — `or_usage > or_limit`
5. All-Time Leaders — top 5 by `total_cost`
6. Engagement — top by `total_conversations` and `total_tool_calls`
7. Inactive — `total_llm_calls == 0`
8. Trends — day-over-day `total_cost` delta; flag >50% increase
9. Anomalies — unusual patterns in real data only

### Step 4: Output

**Email:** Send HTML to RECIPIENT. Subject: `Daily Polly Customer Usage Report — {date}`. See `references/email-template.md` for CSS/dark mode and section layout.

**Chat:** Display clean markdown summary with the same sections.

## Critical Rules

- Never fabricate data. All values must come directly from the API response.
- If the API fails, notify the user/RECIPIENT and stop.
Authorhxie-polly-prod
Downloads36
Versions7
Published12d ago

Version History

v1.3.1latest

Use POST /api/v1/email/send (PollyView API) instead of Gmail to send reports. Added email endpoint docs to references/api.md.

Mar 31, 2026

Clean.zip
v1.2.2

Removed port number from dummy host placeholder.

Mar 30, 2026

Clean.zip
v1.2.1

Replaced real internal IP with dummy placeholder (your-pollyview-host) in all skill files.

Mar 30, 2026

Clean.zip
v1.3.0

Improved reliability: switched API calls from fetch_url to curl (private IP support), added installation instructions, specified DATA_FILE default path, added first-run handling for trends, documented internal IP caveat in api.md.

Mar 30, 2026

Clean.zip
v1.2.0

Added detailed task instructions (references/task-instructions.md) with complete step-by-step execution guide.

Mar 30, 2026

Clean.zip
v1.1.0

Added full API reference doc (references/api.md) with endpoint, fields, and example response.

Mar 29, 2026

Clean.zip
v1.0.0

Initial release

Mar 29, 2026

Clean.zip

SHA-256 (latest)

3bfdb69c6650bf63d8f3f7a3dba207075e93239937b46beb837953ce73de4ad5