Skip to content

The moment it happens

Track focus sessions from Telegram in a sheet

Start and stop focus sessions with a Telegram message and every session is logged with its duration, with today's total in the reply.

Runs
The moment it happens
Apps
Google Sheets, Telegram
AI
Not needed
Access
Telegram bot token; Sheets read+write

Send this to your assistant

Create a ClickRuntime automation: when I send /start <task> or /stop to my Telegram bot, log the session with its duration in my Pomodoro sheet and reply with today's total.

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

A freelance designer bills by the hour and tries to work in focused blocks. Timer apps reset, forget what the block was for, or keep the history somewhere it cannot be exported. At the end of the week she guesses how long each client project took.

Typing /start and a task name into Telegram costs nothing, and the log ends up in a sheet she already uses for invoicing. The daily total in each reply also shows whether the day is on track.

What you get out of it

  • Time tracked against real tasks

    Each session carries the task name you typed. Invoices and project reviews are based on logged minutes, not estimates.

  • A running total for the day

    The reply after each /stop shows how much focused time you have done today. That small number is a useful nudge to start the next block.

  • History in a sheet you own

    Sessions are plain rows you can filter, chart or share. Nothing is locked in a timer app.

  • Works from any device

    Phone, laptop or tablet, the same chat starts and stops the clock. You do not need to remember which device the timer is running on.

How it works

What happens, step by step

  1. You send /start followed by a task name to your Telegram bot, and ClickRuntime remembers the start time.

  2. When you send /stop, it works out how long the session lasted.

  3. A row with the date, task and minutes is added to your Pomodoro sheet.

  4. The bot replies with the session length and your total focus time for today.

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
Track focus sessions from Telegram in a sheetjust nowSucceeded
Telegram · Focus botContoso logo revisions: 25 min. Today: 2 h 10 min.

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
  • Add an AI step, for example to summarize, sort or draft a reply
  • 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.
pomodoro_tracker.pyexample
from datetime import datetime, timezone
from google.oauth2.credentials import Credentials
from googleapiclient.discovery import build
from clickruntime import on_event, credentials, http, state

SHEET_ID = "your-spreadsheet-id"

@on_event
def handle(event):
    msg = (event.json or {}).get("message") or {}
    text, chat = (msg.get("text") or "").strip(), msg.get("chat", {}).get("id")
    api = f"https://api.telegram.org/bot{credentials.secret('TELEGRAM_BOT_TOKEN')}"
    now = datetime.now(timezone.utc)
    if text.startswith("/start"):
        state.set("open", {"task": text[6:].strip() or "focus", "at": now.isoformat()})
        reply = "Started."
    elif text.startswith("/stop") and state.get("open"):
        s = state.get("open")
        mins = round((now - datetime.fromisoformat(s["at"])).total_seconds() / 60)
        sheets = build("sheets", "v4", credentials=Credentials(credentials.connection("google", "work")), cache_discovery=False).spreadsheets()
        sheets.values().append(spreadsheetId=SHEET_ID, range="Sessions!A:C", valueInputOption="USER_ENTERED",
                               body={"values": [[now.date().isoformat(), s["task"], mins]]}).execute()
        rows = sheets.values().get(spreadsheetId=SHEET_ID, range="Sessions!A:C").execute().get("values", [])
        total = sum(int(r[2]) for r in rows if len(r) > 2 and r[0] == now.date().isoformat() and r[2].isdigit())
        state.delete("open")
        reply = f"{s['task']}: {mins} min. Today: {total} min."
    else:
        reply = "Send /start <task> or /stop."
    http.post(f"{api}/sendMessage", json={"chat_id": chat, "text": reply})
    return {"reply": reply}

FAQ

Common questions

What happens if I forget to send /stop?
The session stays open until you stop it, so the duration will be long. You can edit the row in the sheet, or send /start for the next task, which you can set to close the previous one.
Can I track breaks as well?
Yes. Start a session with a task name such as "break" and it is logged like any other. Filtering by task then shows focus time and break time separately.
How is today's total calculated?
It adds up the durations of all rows dated today in your sheet, so any edits you make there are reflected in the next reply.
What permissions does it need?
Telegram bot token; Sheets read+write. Nothing else in your accounts is used.
Does it need AI?
No. It runs without AI, so it doesn't use your plan's 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 “Track focus sessions from Telegram in a sheet” from your assistant

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