Skip to content

The moment it happens

Record every Telegram bot user in a sheet

Each new person who messages your Telegram bot is added to a sheet and greeted, and returning users get their last-seen date updated.

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 someone messages my Telegram bot, add them to my Users sheet with name, username and date if they are new, otherwise update their last-seen date, and greet them.

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 small online language school uses a Telegram bot for lesson reminders and quick questions. The bot works, but nobody knows how many people use it, who joined this month or who has gone quiet. Telegram itself gives a bot no list of its users, so the team cannot follow up or send an announcement to everyone.

Keeping a simple register in a sheet turns the bot into something the team can manage. Schools, shops, clubs and support teams that run a bot use it to know their audience and to build the chat list for later announcements.

What you get out of it

  • A list of your audience you own

    Every person who writes to the bot is recorded with their name, username and chat ID. That list is yours to sort, filter and use, rather than something only Telegram knows.

  • See who is active and who has gone quiet

    The last-seen date shows who used the bot recently. You can follow up with people who have not been back for a month, or report on how many are active each week.

  • New users feel welcomed

    A first message gets a greeting, and a returning user gets a different one. It is a small touch that makes the bot feel looked after.

  • Ready for announcements later

    The chat IDs in the sheet are exactly what you need to send a message to everyone. When you have news, the audience list already exists.

How it works

What happens, step by step

  1. When someone sends a message to your Telegram bot, Telegram passes it straight to ClickRuntime.

  2. ClickRuntime looks for that person in the Users sheet.

  3. A new person is added as a row with their name, username and today's date; for someone already listed, only their last-seen date is updated.

  4. The bot replies with a welcome for new users or a short hello for returning ones.

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
Record every Telegram bot user in a sheetjust nowSucceeded
Google Sheets · UsersNew row: 58201934 · Sam · @sam_contoso · first seen 2026-10-19 · last seen 2026-10-19

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.
bot_user_registry.pyexample
from datetime import date
from google.oauth2.credentials import Credentials
from googleapiclient.discovery import build
from clickruntime import on_event, credentials, http

SHEET_ID = "your-spreadsheet-id"

@on_event
def handle(event):
    msg = (event.json or {}).get("message")
    if not msg:
        return {"skipped": True}
    user, today = msg["from"], date.today().isoformat()
    values = build("sheets", "v4", credentials=Credentials(credentials.connection("google", "work")),
                   cache_discovery=False).spreadsheets().values()
    ids = [r[0] if r else "" for r in values.get(spreadsheetId=SHEET_ID, range="Users!A2:A").execute().get("values", [])]
    if str(user["id"]) in ids:
        row = ids.index(str(user["id"])) + 2
        values.update(spreadsheetId=SHEET_ID, range=f"Users!E{row}", valueInputOption="RAW", body={"values": [[today]]}).execute()
        text = f"Welcome back, {user.get('first_name', '')}!"
    else:
        values.append(spreadsheetId=SHEET_ID, range="Users!A:E", valueInputOption="RAW", body={"values": [[
            str(user["id"]), user.get("first_name", ""), user.get("username", ""), today, today]]}).execute()
        text = f"Hi {user.get('first_name', '')}, thanks for getting in touch!"
    http.post(f"https://api.telegram.org/bot{credentials.secret('TELEGRAM_BOT_TOKEN')}/sendMessage",
              json={"chat_id": msg["chat"]["id"], "text": text})
    return {"new": str(user["id"]) not in ids}

FAQ

Common questions

What details are recorded about each user?
Their Telegram ID, first name, username if they have one, the date of their first message and the date they were last seen. Telegram does not share phone numbers or email addresses with bots unless the person chooses to send them.
Does it work in group chats?
It records whoever sends the message the bot receives. In groups, bots usually only see commands or messages that mention them, unless privacy mode is turned off in the bot's settings.
Can I change the greeting?
Yes. The welcome for new users and the message for returning ones are plain text you can edit, for example to include a link to your timetable or help page.
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 “Record every Telegram bot user in a sheet” from your assistant

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