Skip to content

The moment it happens

Log expenses from Telegram messages to Google Sheets

Type "12.50 lunch" to your bot and a row with the date, amount, category and note is added to your Google Sheet, with this month's total in the reply.

Runs
The moment it happens
Apps
Google Sheets, Telegram
AI
Optional
Access
Sheets write (spreadsheets); bot token

Send this to your assistant

Create a ClickRuntime automation: when I send my Telegram bot a message like "12.50 lunch with Sam", add a row to my Expenses Google Sheet with the date, amount, a category and the note, then reply with my total for this month.

Paste it into your assistant. It tells you what it will send or change before it runs live.

First time? Adding ClickRuntime to your assistant takes about two minutes.

Why use it

Why teams use this automation

Budget apps ask you to open them, pick a category and tap through a form, so small expenses get skipped and the month's numbers never add up. A Google Sheet is easier to trust but painful to edit on a phone.

This automation makes logging an expense as quick as sending a message. You type the amount and a few words to your bot, a row lands in your Google Sheet, and the reply tells you what you have spent this month so far.

It suits individuals, couples and freelancers who keep their budget in Google Sheets and want to log spending the moment it happens.

What you get out of it

  • Log in a few seconds

    Amount and a word or two is all it takes, from a chat you already have open.

  • Your data stays in your sheet

    Rows go into a normal Google Sheet you can chart, filter and share.

  • Running total in every reply

    You see the month's spending each time you log, which is often enough to change a habit.

  • Categories without tapping

    Keywords sort expenses for you, and anything unusual lands in Other to fix later.

  • No receipt needed

    Works for cash, tips and small buys where there is nothing to photograph.

How it works

What happens, step by step

  1. You send your bot an amount followed by a few words, like "12.50 lunch with Sam" or "60 fuel".

  2. ClickRuntime reads the amount and picks a category from the words, such as Food or Transport.

  3. It adds a row to your Google Sheet with the date, amount, category and note.

  4. The bot replies with the category it chose and your running total for the month.

Before it runs live

  • Connect your Google Sheets account and pick the spreadsheets it may use
  • Connect Telegram
  • Paste your automation's link into the other app's webhook settings

What you get

RunsThe moment it happens
Log expenses from Telegram messages to Google Sheetsjust nowSucceeded
Telegram · your botAdded 12.50 · Food · lunch with Sam November so far: 842.30

Build your own

Need it to work differently?

This template is a starting point. Copy the prompt and change it, or describe a different automation from scratch, with your own conditions, more apps or an AI step. Your assistant writes it, tests it and runs it on ClickRuntime.
  • Your own rules

    Conditions, thresholds, filters and exceptions, written the way you'd explain them to a colleague.

  • Any number of apps

    One automation can read from one app and update several others. Over 248 apps are ready, and anything with an API works too.

  • AI where it helps

    Summaries, classification, extraction and drafts use ClickRuntime's built-in AI, with no extra key.

  • On a schedule or on each event

    Runs as often as every 5 minutes, or the moment an app sends an event, and keeps track of what it already handled.

Changes you can ask for

  • Act only on the items that match your own rules, and skip the rest
  • Change what the AI looks for, or how it writes the result
  • Add another app, for example also send it to Slack
  • Combine it with other Google Sheets and Telegram steps into one automation

Under the hood

The code that runs this automation

This is the Python script that runs each time the automation starts. Your AI assistant writes it for you when you send the prompt, and you allow each step in your assistant. To change how the automation works, describe the change to your assistant and it updates the script for you. For every function it can use, see the script reference.
log_expenses_from_telegram_messages_to_google_sheets.pyexample
import re
from datetime import datetime, timezone
from google.oauth2.credentials import Credentials
from googleapiclient.discovery import build
from clickruntime import on_event, credentials, http

SHEET_ID, OWNER = "your-sheet-id", 123456789
CATS = {"Food": ["lunch", "dinner", "coffee", "grocer"], "Transport": ["fuel", "taxi", "uber", "train", "parking"],
        "Home": ["rent", "power", "internet"], "Fun": ["cinema", "concert", "game"]}

def tg(method, **params):
    r = http.post(f"https://api.telegram.org/bot{credentials.secret('TELEGRAM_BOT_TOKEN')}/{method}", json=params)
    r.raise_for_status()
    return r.json()["result"]

@on_event
def handle(event):
    msg = (event.json or {}).get("message", {})
    chat, text = msg.get("chat", {}).get("id"), (msg.get("text") or "").strip()
    m = re.match(r"^(\d+(?:[.,]\d{1,2})?)\s+(.+)$", text)
    if chat != OWNER or not m:
        if chat == OWNER:
            tg("sendMessage", chat_id=chat, text="Send an amount then a note, e.g. 12.50 lunch")
        return {"skipped": True}
    amount, note = float(m[1].replace(",", ".")), m[2]
    cat = next((c for c, words in CATS.items() if any(w in note.lower() for w in words)), "Other")
    day = datetime.fromtimestamp(msg["date"], timezone.utc).strftime("%Y-%m-%d")
    values = build("sheets", "v4", credentials=Credentials(credentials.connection("google", "work")), cache_discovery=False).spreadsheets().values()
    values.append(spreadsheetId=SHEET_ID, range="Expenses!A:D", valueInputOption="USER_ENTERED",
                  body={"values": [[day, amount, cat, note]]}).execute()
    rows = values.get(spreadsheetId=SHEET_ID, range="Expenses!A2:B").execute().get("values", [])
    total = sum(float(r[1]) for r in rows if len(r) > 1 and r[0][:7] == day[:7])
    tg("sendMessage", chat_id=chat, text=f"Added {amount:.2f} · {cat} · {note}\n{datetime.strptime(day, '%Y-%m-%d'):%B} so far: {total:,.2f}")
    return {"amount": amount, "category": cat}

FAQ

Common questions

How are categories chosen?
By keywords you set, such as "fuel" or "taxi" for Transport. Anything that does not match goes to Other. Ask your assistant to use ClickRuntime's AI for categories instead if you prefer not to keep a word list.
Can I log an expense for a different day?
Yes. Ask your assistant to accept a date at the start, like "yesterday 30 dinner" or "8/11 30 dinner", and use it instead of today.
Can two people log to the same sheet?
Yes. Add both chat IDs and the script can add a column with the name of whoever sent the expense.
What permissions does it need?
Sheets write (spreadsheets); bot token. Nothing else in your accounts is used.
Does it need AI?
No, but you can ask for an AI step (for example a summary). It then uses ClickRuntime's built-in AI allowance.
How many runs does it use?
One run for each event the app sends.
Can I change how it works?
Yes. Describe the change to your AI assistant, for example a different schedule, channel or filter. It updates the automation, tests it and tells you what changed.

Set up “Log expenses from Telegram messages to Google Sheets” from your assistant

Copy the prompt above, or connect your assistant first. Free plan, no credit card.