KPI Alert System Skill
Automated KPI monitoring with threshold alerts for business financial health. Pulls data from QBO, Google Sheets, or CSV exports, evaluates rules, and fires alerts to Telegram/Slack/email.
Supported KPIs
| KPI | Description | Typical Alert Threshold |
|---|
| AR Aging (30/60/90+) | Outstanding receivables by age bucket | >$X in 90+ days, or >30% of AR |
| Cash Runway |
Months of runway at current burn | <3 months = red, <6 months = yellow |
| Monthly Burn Rate | Net cash outflow per month | >$X/month or >Y% above budget |
| Revenue Growth (MoM/QoQ) | Revenue trend vs prior period | <0% = alert, <5% = warning |
| Gross Margin % | (Revenue - COGS) / Revenue |
| Net Income / Loss | P&L bottom line | Negative for N consecutive months |
| DSO (Days Sales Outstanding) | AR / (Revenue / 30) | >45 days = yellow, >60 = red |
| Current Ratio | Current Assets / Current Liabilities | <1.2 = alert |
| Quick Ratio | (Cash + AR) / Current Liabilities | <1.0 = alert |
| Payroll % of Revenue | Payroll costs as % of top line | >X% = alert |
Setup Steps
1. Define Your KPI Config
Create a YAML config file for the client or firm:
CODEBLOCK0
2. Data Source Integration
QuickBooks Online (via QBO Automation skill)
CODEBLOCK1
Google Sheets (via gog skill)
CODEBLOCK2
CSV / Excel Export
Place exports at a consistent path and reference in config:
source: csv
file: "/tmp/monthly-export-2026-03.csv"
column: "AR_90plus"
row_filter: "Month=March"
3. KPI Evaluation Logic
Core algorithm (Python pseudocode for reference):
CODEBLOCK4
4. Alert Formatting
Telegram message format:
CODEBLOCK5
Slack format (with attachments):
{
"attachments": [
{
"color": "#ff0000",
"title": "🔴 AR 90+ Days — $18,500",
"text": "Collections action needed. 90+ day bucket exceeds $15,000 threshold.",
"footer": "KPI Alert System | PrecisionLedger",
"ts": 1742076000
}
]
}
5. Scheduling with OpenClaw Cron
Monthly KPI check (1st of month, 9 AM CST):
CODEBLOCK7
Weekly cash runway check (every Monday, 8 AM CST):
{
"name": "Weekly Cash Runway Check",
"schedule": {
"kind": "cron",
"expr": "0 8 * * 1",
"tz": "America/Chicago"
},
"payload": {
"kind": "agentTurn",
"message": "Check cash runway and burn rate for all active clients. Alert if any client is below 6 months runway."
},
"sessionTarget": "isolated"
}
Example Prompts
Setup
"Set up KPI alerts for my client TechStartup LLC. Alert me on Telegram when AR aging hits 90 days, burn rate exceeds $40k/month, or runway drops below 4 months."
Manual Check
"Run a KPI check on Acme Corp right now and tell me which thresholds are breached."
Threshold Adjustment
"Update the gross margin alert for TechStartup to yellow at 45% and red at 35%."
Report Generation
"Generate a weekly KPI summary for all active clients and post to the #weekly-metrics Telegram channel."
KPI Calculation Reference
Cash Runway
CODEBLOCK9
Days Sales Outstanding (DSO)
CODEBLOCK10
Burn Rate
CODEBLOCK11
Current Ratio
CODEBLOCK12
AR Aging Concentration Risk
90+ Day Concentration = AR 90+ days / Total AR × 100
Alert when concentration > 20%
Multi-Client Monitoring Pattern
For firms managing multiple clients:
CODEBLOCK14
Loop pattern:
"Check KPI thresholds for all clients in master-kpi-config.yaml. Consolidate alerts into one Telegram message grouped by client."
Negative Boundaries — When NOT to Use This Skill
- - Real-time stock/crypto price alerts → use defi-position-tracker or a dedicated market data feed
- Live BI dashboards (charts, drill-downs) → use Power BI, Looker, or Metabase
- ERP systems (SAP, Oracle, NetSuite) → requires dedicated API connectors, not this skill
- Sub-minute alerting (high-frequency trading signals) → wrong latency class
- PTIN-regulated tax analysis → use qbo-to-tax-bridge (Moltlaunch service only)
- Client-facing automated reports → requires Irfan approval before sending externally
- Write operations to QBO → read-only by default; journal entries need explicit approval
Integration Stack
| Layer | Tool |
|---|
| Data Pull (QBO) | qbo-automation skill |
| Data Pull (Sheets) |
gog skill |
| Alerting (Telegram) | message tool (channel=telegram) |
| Scheduling | cron tool |
| Storage | workspace/clients//kpi-data/ |
| Config Format | YAML (kpi-config-.yaml) |
Alert Severity Guide
| Color | Meaning | Response Time |
|---|
| 🔴 RED | Threshold critically breached — action required | Same day |
| 🟡 YELLOW |
Warning zone — monitor closely | Within 48 hours |
| ✅ GREEN | Within acceptable range | No action needed |
KPI Alert System — PrecisionLedger Skill v1.0.0
技能名称: kpi-alert-system
详细描述:
KPI 预警系统技能
通过阈值预警实现业务财务健康状况的自动化KPI监控。从QBO、Google Sheets或CSV导出文件中拉取数据,评估规则,并向Telegram/Slack/邮件发送预警。
支持的KPI
| KPI | 描述 | 典型预警阈值 |
|---|
| 应收账款账龄 (30/60/90+天) | 按账龄区间划分的未收回应收账款 | 90天以上 >X美元,或占应收账款总额 >30% |
| 现金跑道 |
按当前消耗速度计算的运营月数 | <3个月 = 红色,<6个月 = 黄色 |
| 月度烧钱率 | 每月净现金流出 | >X美元/月 或 超出预算Y% |
| 收入增长 (月环比/季环比) | 与上期相比的收入趋势 | <0% = 预警,<5% = 警告 |
| 毛利率 % | (收入 - 销售成本) / 收入 | 低于目标值X% |
| 净利润 / 亏损 | 损益表底线 | 连续N个月为负 |
| DSO (销售未清账期) | 应收账款 / (收入 / 30) | >45天 = 黄色,>60天 = 红色 |
| 流动比率 | 流动资产 / 流动负债 | <1.2 = 预警 |
| 速动比率 | (现金 + 应收账款) / 流动负债 | <1.0 = 预警 |
| 工资占收入比 | 工资成本占收入百分比 | >X% = 预警 |
设置步骤
1. 定义您的KPI配置
为客户或公司创建YAML配置文件:
yaml
kpi-config-clientname.yaml
client: Acme Corp
alert_channels:
- type: telegram
target: @irfan_dm # 或频道ID
- type: slack
webhook: https://hooks.slack.com/services/...
- type: email
to: imussa@precisionledger.io
kpis:
araging90plus:
label: 应收账款 90+天
source: qbo # 或 sheets, csv
threshold_red: 15000
threshold_yellow: 8000
message: 应收账款账龄90天以上为${value} — 需要催收行动
cashrunwaymonths:
label: 现金跑道
source: qbo
threshold_red: 3
threshold_yellow: 6
direction: below # 低于阈值时预警 (默认:高于)
message: 现金跑道为{value}个月 — 请立即审查烧钱率
revenuegrowthmom:
label: 月环比收入增长
source: sheets
sheet_id: 1BxiM...
tab: 损益汇总
cell_range: C5
threshold_red: -5
threshold_yellow: 0
direction: below
message: 月环比收入增长为{value}% — 调查销售管道
grossmarginpct:
label: 毛利率 %
source: qbo
threshold_red: 30
threshold_yellow: 40
direction: below
message: 毛利率为{value}% — 低于40%的目标
2. 数据源集成
QuickBooks Online (通过QBO自动化技能)
bash
拉取本月损益汇总
qbo report pl --period this-month --format json > /tmp/pl-current.json
拉取应收账款账龄
qbo report ar-aging --format json > /tmp/ar-aging.json
拉取资产负债表以计算流动性比率
qbo report balance-sheet --period this-month --format json > /tmp/bs-current.json
Google Sheets (通过gog技能)
bash
读取一个命名范围
gog sheets read --id SHEET_ID --range KPI Dashboard!B2:C20
CSV / Excel 导出
将导出文件放置在固定路径,并在配置中引用:
yaml
source: csv
file: /tmp/monthly-export-2026-03.csv
column: AR_90plus
row_filter: Month=March
3. KPI评估逻辑
核心算法 (Python伪代码供参考):
python
def evaluate_kpi(config, value):
direction = config.get(direction, above)
if direction == above:
if value >= config[threshold_red]:
return RED, config[message].format(value=value)
elif value >= config[threshold_yellow]:
return YELLOW, config[message].format(value=value)
else: # below
if value <= config[threshold_red]:
return RED, config[message].format(value=value)
elif value <= config[threshold_yellow]:
return YELLOW, config[message].format(value=value)
return GREEN, None
def runkpicheck(config_path):
config = loadyaml(configpath)
alerts = []
for kpiid, kpiconfig in config[kpis].items():
value = fetchkpivalue(kpi_config) # 从QBO/Sheets/CSV拉取
status, message = evaluatekpi(kpiconfig, value)
if status in [RED, YELLOW]:
alerts.append({
kpi: kpi_config[label],
status: status,
value: value,
message: message
})
return alerts
4. 预警格式化
Telegram消息格式:
🚨 KPI 预警 — Acme Corp
日期:2026年3月15日
🔴 应收账款 90+天:$18,500
→ 需要立即采取催收行动
🟡 毛利率:38%
→ 低于40%目标 — 审查销售成本
✅ 现金跑道:8.2个月
✅ 收入增长:月环比 +4.2%
执行人:Sam Ledger / PrecisionLedger
Slack格式 (带附件):
json
{
attachments: [
{
color: #ff0000,
title: 🔴 应收账款 90+天 — $18,500,
text: 需要采取催收行动。90天以上账龄区间超过$15,000阈值。,
footer: KPI预警系统 | PrecisionLedger,
ts: 1742076000
}
]
}
5. 使用OpenClaw Cron进行调度
月度KPI检查 (每月1日,中部时间上午9点):
json
{
name: 月度KPI检查 — Acme Corp,
schedule: {
kind: cron,
expr: 0 9 1 ,
tz: America/Chicago
},
payload: {
kind: agentTurn,
message: 使用kpi-config-acme.yaml对Acme Corp运行KPI预警检查。拉取QBO应收账款账龄和损益表,评估阈值,并向配置的渠道发送预警。
},
sessionTarget: isolated,
delivery: {
mode: announce
}
}
每周现金跑道检查 (每周一,中部时间上午8点):
json
{
name: 每周现金跑道检查,
schedule: {
kind: cron,
expr: 0 8 1,
tz: America/Chicago
},
payload: {
kind: agentTurn,
message: 检查所有活跃客户的现金跑道和烧钱率。如有任何客户跑道低于6个月,则发出预警。
},
sessionTarget: isolated
}
示例提示
设置
为我的客户TechStartup LLC设置KPI预警。当应收账款账龄达到90天、烧钱率超过每月$40k或跑道低于4个月时,通过Telegram向我发送预警。
手动检查
立即对Acme Corp运行KPI检查,并告诉我哪些阈值被突破。
阈值调整
将TechStartup的毛利率预警更新为黄色阈值45%,红色阈值35%。
报告生成
为所有活跃客户生成一份每周KPI摘要,并发布到#weekly-metrics Telegram频道。
KPI计算参考
现金跑道
跑道(月数)= 当前现金余额 / 平均月度烧钱率
平均月度烧钱 = (3个月前现金 - 今日现金) / 3
销售未清账期 (DSO)
DSO = (应收账款 / 收入) × 30
烧