Skip to content

The moment it happens

Answer Telegram questions from a Google Sheet

People message your Telegram bot and get answers drawn from your sheet, with every question and reply logged.

Runs
The moment it happens
Apps
Google Sheets, Telegram
AI
Yes, uses the built-in AI allowance
Access
Telegram bot token; Sheets read+write

Send this to your assistant

Create a ClickRuntime automation: when someone messages my Telegram bot, answer using the data in my Events sheet and log the question and answer in a Log tab.

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 events organiser keeps the schedule, venues and ticket prices in one Google Sheet. Every week the same questions arrive by message: what time does the workshop start, is there parking, can I still buy a ticket. Answering them one by one eats evenings, and replies given from memory are sometimes out of date.

With this automation your Telegram bot reads the sheet each time someone writes and answers from what is in it. Update a row and the next answer reflects the change. Every question and answer is logged, so you can see what people ask most and fill the gaps.

What you get out of it

  • Answers stay in step with your data

    The bot reads the sheet at the moment of the question, so a changed time or price is used straight away. There is no separate FAQ to keep in sync.

  • Fewer repeat messages for you

    Routine questions about times, places and prices are handled without you. You step in only for the unusual ones that the sheet cannot answer.

  • A record of what people ask

    The log tab shows every question and reply with a time. Recurring questions point to information you should add to the sheet or your event page.

  • Follow-up questions make sense

    Recent messages from the same person are kept, so a reply like 'and on Sunday?' is understood in context. Conversations feel natural rather than one-shot.

  • Works at any hour

    Attendees often check details late the night before. The bot replies right away, even when nobody on the team is online.

How it works

What happens, step by step

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

  2. It reads the rows in your Events sheet and the last few messages from that chat.

  3. AI writes a short reply using only what is in the sheet, and the bot sends it back.

  4. The question and answer are added as a new row in the Log tab of the sheet.

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
Answer Telegram questions from a Google Sheetjust nowSucceeded
Telegram · Northwind Events botThe Saturday pottery workshop starts at 10:00 at the Northwind Studio. Tickets are still available at 25 EUR.

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.
telegram_bot_that_answers_from_a_sheet.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, ai

SHEET_ID = "your-spreadsheet-id"

@on_event
def handle(event):
    msg = (event.json or {}).get("message") or {}
    chat, text = msg.get("chat", {}).get("id"), msg.get("text")
    if not chat or not text:
        return {"skipped": True}
    sheets = build("sheets", "v4", credentials=Credentials(credentials.connection("google", "work")), cache_discovery=False).spreadsheets()
    rows = sheets.values().get(spreadsheetId=SHEET_ID, range="Events!A1:F200").execute().get("values", [])
    history = state.get(f"chat:{chat}") or []
    data = "\n".join(" | ".join(r) for r in rows)
    try:
        answer = ai.generate(f"Data:\n{data}\n\nRecent chat:\n" + "\n".join(history[-6:]) + f"\n\nQuestion: {text}",
                             system="Answer briefly using only the data. If it is not there, say so.", max_output_tokens=300).text.strip()
    except ai.AIError:
        answer = "Sorry, I can't answer right now. Please try again later."
    token = credentials.secret("TELEGRAM_BOT_TOKEN")
    http.post(f"https://api.telegram.org/bot{token}/sendMessage", json={"chat_id": chat, "text": answer})
    state.set(f"chat:{chat}", (history + [f"Q: {text}", f"A: {answer}"])[-10:])
    sheets.values().append(spreadsheetId=SHEET_ID, range="Log!A:D", valueInputOption="USER_ENTERED",
                           body={"values": [[datetime.now(timezone.utc).isoformat(timespec="minutes"), str(chat), text, answer]]}).execute()
    return {"answered": True}

FAQ

Common questions

What kind of sheet works best?
A tab with one row per item and clear column headings, such as Event, Date, Time, Venue and Price. Short, factual cells give the most reliable answers.
What happens when the answer is not in the sheet?
The bot says it does not know and suggests contacting you, rather than guessing. You will see the question in the log and can add the missing detail.
Can several people use the bot at once?
Yes. Each chat keeps its own short history, so answers to one person do not mix with another conversation.
What permissions does it need?
Telegram bot token; Sheets read+write. Nothing else in your accounts is used.
Does it need AI?
Yes. It uses ClickRuntime's built-in AI, so you don't need an OpenAI or Anthropic key. Every plan includes a monthly 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 “Answer Telegram questions from a Google Sheet” from your assistant

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