Automated Weekly Brief Spec β Last updated: 2026-02-21
The Piqki Performance Reporting System is an automated Monday morning brief that pulls data from GA4, Klaviyo, GoAffPro, and Shopify into a single Telegram message for Gin. It replaces manual data pulls and ensures Gin sees the right metrics every week without logging into anything.
The Monday morning Telegram message will look exactly like this:
π PIQKI WEEKLY PERFORMANCE β [DATE]
MER: [X.X]x (Revenue Γ· Ad Spend) β Target: β₯2.0x | Last week: [X.X]x
Contribution Margin: $[XX.XX]/order β Revenue - COGS - Ad Spend Γ· Orders
π Top Performer:
π§ Klaviyo Revenue:
π€ Affiliate Revenue:
π¬ Email List:
β‘ Kill/Scale Flags:
π‘ MAX'S RECOMMENDATION: [One sentence β e.g., "Double budget on Concept C, kill Concept A, continue testing Concept B."]
What we need:
API Endpoint:
runReport methodsessionSource, sessionMediumtotalRevenue, sessions, conversions, purchaseRevenueField names:
totalRevenue / purchaseRevenue β total ecommerce revenuesessions β total sessionsconversions β purchase conversionsconversionRate β sessions Γ· conversionsTime window: Last 7 days (dynamic, calculated at runtime)
Confidence: High β GA4 Data API is well-documented and stable.
Reference: Google Analytics 4 Ecommerce measurement (developers.google.com/analytics/devguides/collection/ga4/ecommerce)
What we need:
API Endpoints:
List Size + Growth:
GET /api/lists β returns all lists with member countsmember_count for the main listRevenue Attribution:
GET /api/metric-export β use the "Placed Order" metricGET /api/report with metric_id for conversion eventsinterval: daily, start_date: [7 days ago], end_date: [today]Flow vs. Campaign breakdown:
attributed_message dimension toεΊε flows vs. campaignsConfidence: Medium β Klaviyo's API is comprehensive but revenue attribution requires the correct metric ID. Must find the "Placed Order" metric ID in the specific Piqki Klaviyo account.
Reference: Klaviyo Developer Docs β Metrics API, Export API (developers.klaviyo.com)
What we need:
API Endpoint:
GET /api/admin/affiliates/saleshttps://[store-name].goaffpro.com/api/admin/Specific endpoints:
/affiliates β list all affiliates with status/affiliates/sales β sales data by affiliate (supports date filters)/orders β all orders with affiliate attributionField names:
sale_amount β revenue from affiliate salescommission β affiliate commission paidorder_count β number of ordersDate filter: Query parameters start_date and end_date (format: YYYY-MM-DD)
Confidence: Medium β GoAffPro API exists but documentation is limited. The Swagger UI (api.goaffpro.com/docs/admin/) provides the most reliable endpoint list.
Reference: GoAffPro API Documentation (docs.goaffpro.com), Swagger UI (api.goaffpro.com/docs/admin/)
What we need:
API Endpoint:
GET /admin/api/2024-01/orders.jsonorders query with totalPrice, totalLineItemsPriceQuery parameters:
status=any (include all orders)created_at_min=[7 days ago] β filter by datelimit=250 β paginate if neededfields=id,total_price,created_at,line_items β specify fieldsField names:
total_price β total order amount (includes shipping, taxes)subtotal_price β product total onlytotal_line_items_price β sum of line itemsorder_number β readable order IDCalculations:
total_price in date rangeConfidence: High β Shopify API is mature, well-documented, and stable.
Reference: Shopify Admin API β Orders (shopify.dev/docs/api/admin-graphql/latest/queries/orders)
What we need:
Options:
Option A β GA4 (recommended):
sessionSource = 'google/cpc' or sessionSource = 'facebook/cpc'adSpend (if available), sessions, conversionsOption B β Meta Ads API:
GET /v18.0/[ad-account-id]/insightsspend, impressions, clicks, ctr, cpccampaign_name, ad_nametime_range={'since':'[7 days ago]','until':'[today]'}Confidence: Medium β Meta API requires a Meta app with ads_read permission. Gin must grant access.
Reference: Meta Marketing API β Insights Edge (developers.facebook.com/docs/marketing-api/insights)
skills/
βββ piqki-weekly-brief/
β βββ SKILL.md # This file
β βββ fetch_data.py # API calls to all platforms
β βββ format_message.py # Telegram message formatting
β βββ skill.yaml # OpenClaw skill definition
skill: piqki-weekly-brief
trigger:
type: cron
schedule: "0 9 * * 1" # Every Monday at 9am PT
timezone: America/Los_Angeles
env:
GA4_PROPERTY_ID: [env var]
GA4_CLIENT_EMAIL: [env var]
GA4_PRIVATE_KEY: [env var]
KLAVIYO_PRIVATE_API_KEY: [env var]
GOAFFPRO_API_KEY: [env var]
SHOPIFY_STORE: piqki
SHOPIFY_ACCESS_TOKEN: [env var]
TELEGRAM_CHAT_ID: [env var]
TELEGRAM_BOT_TOKEN: [env var]
| Scenario | Response |
|---|---|
| One API fails | Send partial brief with available data. Note: "β οΈ [Platform] unavailable β using [date] data" |
| All APIs fail | Send error message to Telegram: "β Weekly brief failed β APIs unreachable. Check manually." |
| Partial data (no sales) | Send: "β οΈ No sales data this week β possible tracking issue" |
| Rate limit hit | Retry once after 30s. If still failing, skip and note in message. |
| Platform | Credential | How to Get |
|---|---|---|
| GA4 | Service Account | Google Cloud Console β IAM β Create Service Account β Generate JSON key |
| GA4 | Property ID | GA4 Admin β Property Settings β Property ID |
| Klaviyo | Private API Key | Klaviyo β Account β API Keys β Create Private API Key |
| GoAffPro | API Key | GoAffPro Admin β Settings β Advanced β Access Tokens β New API Key |
| Shopify | Admin API Access Token | Shopify Admin β Settings β Apps β Develop Apps β Create App β Configure Admin API scopes |
| Meta | Ad Account ID | Meta Business Manager β Ad Accounts |
| Meta | Access Token | Meta for Developers β Marketing API β Access Token (or use long-lived token) |
| Telegram | Bot Token | @BotFather on Telegram β /newbot |
| Telegram | Chat ID | @userinfobot or forward message to @my_id_bot |
GA4:
Klaviyo:
metrics:read, lists:readGoAffPro:
Shopify:
read_orders, read_products, read_analyticsMeta:
ads_read)Create GA4 Service Account:
Generate Klaviyo API Key:
Generate GoAffPro API Key:
Set up Shopify Admin App:
Set up Telegram Bot:
Add environment variables to OpenClaw:
The following decisions are needed before this system can be fully built:
The spec uses these defaults from the Creative Testing System:
Gin decides:
Current formula: (Revenue - COGS - Ad Spend) Γ· Orders
Gin decides:
Two options:
Gin decides:
If any API is unavailable:
Gin decides:
| Metric | Formula | Source |
|---|---|---|
| MER | Total Revenue Γ· Total Ad Spend | Shopify + Meta |
| Contribution Margin/order | (Revenue - COGS - Ad Spend) Γ· Orders | Shopify + Meta + Est. COGS |
| Klaviyo Revenue | Attributed revenue (7 days) | Klaviyo API |
| Klaviyo % of Total | Klaviyo Revenue Γ· Total Revenue | Calculated |
| Affiliate Revenue | GoAffPro sales (7 days) | GoAffPro API |
| Email List Size | Total subscribers | Klaviyo API |
| Weekly List Growth | (Current - 7 days ago) Γ· 7 days ago | Klaviyo API |
| Top Creative | Highest CTR at β₯$50 spend | Meta/GA4 |
| Kill Flag | CTR <0.8% after $50 spend | Meta |
| Scale Flag | CTR >2.5% | Meta |
[1] GA4 Ecommerce API β revenue tracking Source: Google Analytics 4 Developer Documentation (developers.google.com/analytics/devguides/collection/ga4/ecommerce) Status: High confidence β Official Google documentation. Standard ecommerce implementation.
[2] Klaviyo Metrics API β revenue attribution Source: Klaviyo Community discussions + Developer Docs Status: Medium confidence β API exists and is documented. Requires finding specific metric IDs in Piqki account. Use /export endpoint with "Placed Order" metric.
[3] GoAffPro API β affiliate sales Source: GoAffPro documentation (docs.goaffpro.com) + Swagger UI (api.goaffpro.com/docs/admin/) Status: Medium confidence β API exists. Documentation is sparse. Swagger UI is the most reliable reference.
[4] Shopify Orders API Source: Shopify Admin API Documentation (shopify.dev/docs/api/admin-graphql/latest/queries/orders) Status: High confidence β Mature, well-documented API.
[5] MER (Marketing Efficiency Ratio) Source: DTC practitioner methodology β popularized by Taylor Holiday / Common Thread Collective Status: Industry standard β Widely used in DTC circles. Target β₯2.0 is directional; actual target depends on margin structure.
[6] Kill/Scale thresholds Source: Piqki Creative Testing System (piqki-creative-testing-system.md) Status: Internal standard β Based on DTC best practices. $50 minimum spend threshold ensures statistical significance.
projects/piqki-weekly-briefs/ for trend analysisDocument ends. Next step: Build the OpenClaw skill once Gin approves setup and provides credentials.