# Your weekly numbers, added to a Google Sheet on their own

Source: https://clickruntime.com/use-cases/weekly-metrics-to-google-sheets

> Tell your assistant which numbers you track and where they come from. Every week ClickRuntime pulls them from the APIs and appends a row to your sheet, so the chart and history keep themselves up to date.

## Can ChatGPT or Claude update a Google Sheet with my numbers every week?

Not by themselves: they can edit a sheet while you chat, but nothing happens next Monday unless you ask again. With ClickRuntime connected, your assistant sets up an automation that pulls the numbers from your tools every week and appends a row to the sheet you picked.

### Why the assistant can't do this on its own

- A weekly row needs a weekly clock. Assistants have none outside a chat.
- The numbers live in other tools (Stripe, your database, an analytics API). Fetching them needs your keys, kept somewhere safe between runs, not pasted into a chat.
- Google access that keeps working week after week needs a stored connection that refreshes itself. ClickRuntime keeps it.

## Set it up from your AI assistant

Prompt to copy:

> Create a ClickRuntime automation: every Monday at 7:00 America/New_York, add a row to the KPIs tab of my sheet “Company metrics” with the week start date, last week's Stripe revenue (succeeded charges minus refunds), number of new customers and number of refunds.

1. **Connect ClickRuntime to your assistant.** Add ClickRuntime as a connector (MCP server) in ChatGPT, Claude, Cursor or another MCP client, using https://clickruntime.com/api/mcp. You sign in with Google or email; there is no API key to copy. This is done once per assistant.
2. **Paste the prompt.** Start a new chat and paste: “Create a ClickRuntime automation: every Monday at 7:00 America/New_York, add a row to the KPIs tab of my sheet “Company metrics” with the week start date, last week's Stripe revenue (succeeded charges minus refunds), number of new customers and number of refunds.” Change the details (times, channels, addresses) to yours.
3. **Read the draft.** The assistant restates what will happen, asks for anything missing, such as your timezone or which channel to post to, and saves a draft automation. A draft never runs on its own, so nothing happens until you agree.
4. **Connect accounts and save keys.** The assistant asks you to connect Google with the picked-files option, and to pick the “Company metrics” sheet, so the automation can open only that file. The Stripe restricted key (read-only) is saved as a secret in the ClickRuntime dashboard.
5. **Test it.** The assistant runs it once and shows the row it added. If the columns don't match your header, it adjusts and you delete the test row.
6. **Turn it on.** The assistant tells you what will run, when, and which services it will contact, then asks your permission to turn it on. From then on it runs on ClickRuntime's servers, and you can close the chat.
7. **Check it in the ClickRuntime dashboard.** Each run shows the values written and the row number. The connections page shows which Google account and which sheet the automation can open.

Connector setup for each assistant: https://clickruntime.com/assistants

## What the assistant writes

`weekly_kpis_to_sheets.py`

```python
from datetime import datetime, timedelta, timezone
import stripe
from google.oauth2.credentials import Credentials
from googleapiclient.discovery import build
from clickruntime import on_trigger, credentials

SHEET_ID = "your-spreadsheet-id"
TAB = "KPIs"

@on_trigger
def run(event):
    today = datetime.now(timezone.utc).date()
    start = today - timedelta(days=today.weekday() + 7)          # last Monday
    end = start + timedelta(days=7)
    window = {"gte": int(datetime(start.year, start.month, start.day, tzinfo=timezone.utc).timestamp()),
              "lt": int(datetime(end.year, end.month, end.day, tzinfo=timezone.utc).timestamp())}

    stripe.api_key = credentials.secret("STRIPE_RESTRICTED_KEY")
    charges = [c for c in stripe.Charge.list(created=window, limit=100).auto_paging_iter() if c.status == "succeeded"]
    refunds = list(stripe.Refund.list(created=window, limit=100).auto_paging_iter())
    customers = sum(1 for _ in stripe.Customer.list(created=window, limit=100).auto_paging_iter())
    revenue = (sum(c.amount for c in charges) - sum(r.amount for r in refunds)) / 100

    sheets = build("sheets", "v4", credentials=Credentials(credentials.connection("cr_google_sheets_picked", "work")),
                   cache_discovery=False).spreadsheets()
    sheets.values().append(spreadsheetId=SHEET_ID, range=f"{TAB}!A:D", valueInputOption="USER_ENTERED",
                           body={"values": [[start.isoformat(), revenue, customers, len(refunds)]]}).execute()
    return {"week": start.isoformat(), "revenue": revenue, "customers": customers, "refunds": len(refunds)}
```

- The Google connection is the picked-files app, so the automation can open only the sheet you picked.
- Totals are plain code. No AI is needed for sums, so none is used.
- Amounts from Stripe are in cents; the script converts to your currency's units. One currency is assumed; ask the assistant to split by currency if you sell in several.

## A schedule, not a trigger link

A weekly schedule. For a daily row, ask for “every day at 6:00”; for monthly, “on the 1st at 6:00”.

## Limits

- The automation opens only the sheets you pick when connecting Google. A 403 or 404 means the sheet wasn't picked; the dashboard gives you the link to pick it.
- Very large data pulls should be summarised in the script, not written row by row.

## Troubleshooting

### The run fails with 404 on the sheet.

The sheet wasn't picked for the connection. Open the automation's connection in the ClickRuntime dashboard, choose files, and pick the sheet.

### Numbers don't match Stripe's dashboard.

Stripe's dashboard may use your local timezone and net of fees. Tell your assistant which definition you want and it adjusts the window or the sum.

## Related

- [Google Sheets automations](https://clickruntime.com/apps/google-sheets)
- [Stripe automations](https://clickruntime.com/apps/stripe)
- [Shopify automations](https://clickruntime.com/apps/shopify)
- [weekly-stripe-revenue](https://clickruntime.com/templates/weekly-stripe-revenue)
- [stripe-payments-to-sheets](https://clickruntime.com/templates/stripe-payments-to-sheets)
- [Sync data between apps](https://clickruntime.com/use-cases/sync-data-between-apps)
- [Daily Slack message](https://clickruntime.com/use-cases/daily-slack-message)
- [Cron jobs without a server](https://clickruntime.com/use-cases/cron-jobs-without-a-server)
- [Google Apps Script alternative](https://clickruntime.com/alternatives/google-apps-script)
- [Zapier alternative](https://clickruntime.com/alternatives/zapier)
- [Docs: connections-and-secrets](https://clickruntime.com/docs/connections-and-secrets)

## Extend it: what you can add next

The first version is rarely the last. Because the automation is a Python script with memory, AI and any API available, you grow it by asking your assistant for the change. Each change is a new version, and a failed deploy never replaces the working one.

- **Add Shopify orders and average order value to the same row** (Any app or API)
  Prompt: "Add to my weekly KPIs automation: Shopify order count and average order value for the same week, in new columns."
- **Write a two-line commentary on the week in the last column** (Built-in AI)
  Prompt: "Change my weekly KPIs automation so it adds a two-line comment comparing this week with the last four weeks."
- **Highlight a drop of more than 20% and email you** (Multi-step logic)
  Prompt: "Change my weekly KPIs automation so if revenue is more than 20% below last week, it emails me."
- **Add a monthly summary tab on the 1st** (Schedules)
  Prompt: "Add to my weekly KPIs automation: on the 1st of each month, add a row to a Monthly tab with last month's totals."
- **Fill in missed weeks if a run ever fails** (Memory between runs)
  Prompt: "Change my weekly KPIs automation so it remembers the last week written and fills in any missed weeks on the next run."
- **Post the new row to Slack when it's added** (Any app or API)
  Prompt: "Add to my weekly KPIs automation: post the week's numbers to #leadership in Slack after adding the row."

## Questions

### Can ChatGPT update a Google Sheet automatically?

With ClickRuntime connected, yes. ChatGPT sets up an automation that adds rows on a schedule, after the chat is closed.

### Can Claude pull data into Google Sheets every week?

Yes, through ClickRuntime. Claude writes the automation; it runs on ClickRuntime's servers.

### Does it get access to all my Google Drive?

No. With the picked-files connection it can open only the sheets you pick, plus any it creates.

### Where do my API keys go?

Into the ClickRuntime dashboard as secrets. They never go into the chat.

### How is this different from Apps Script?

Apps Script runs inside Google and you write JavaScript yourself. Here your assistant writes Python that can call any API, with keys kept out of the sheet. See the Google Apps Script comparison.

### What can I add later?

Shopify numbers, AI commentary, drop alerts or a monthly tab. See Extend it.
