Skip to content

The moment it happens

Chat with a Telegram assistant that remembers you

Your Telegram bot answers using the notes in your Memory Google Doc, and adds anything new you tell it to that doc.

Runs
The moment it happens
Apps
Google Docs, Telegram
AI
Yes, uses the built-in AI allowance
Access
doc shared with service account (edit); bot token

Send this to your assistant

Create a ClickRuntime automation: when I message my Telegram bot, reply with AI using the notes in my Memory Google Doc, and append any new fact I tell it to that doc.

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 self-employed designer wants a quick assistant on his phone for things like which clients pay on 30-day terms, his preferred supplier for printing, or the dimensions he always uses for social posts. General chat tools forget these details between conversations, so he keeps repeating himself.

Keeping the assistant's memory in a plain Google Doc means he can read, correct and reorganise what it knows at any time. Freelancers, small business owners and anyone who wants a personal assistant in Telegram use it to keep useful facts in one place they control.

What you get out of it

  • It remembers what you told it

    Facts you mention are saved to the doc and used in later answers. You stop repeating the same context every time you ask a question.

  • You can see and edit its memory

    The memory is an ordinary Google Doc. If something is wrong or out of date, you change or delete the line, and the next answer reflects it.

  • Answers in the app you have open

    Telegram is already on your phone and laptop. Asking a quick question takes a few seconds, without logging in to another site.

  • Your notes become a reference

    Over time the doc turns into a tidy list of your preferences, contacts and routines. It is useful on its own, even when you are not chatting with the bot.

How it works

What happens, step by step

  1. When you send a message to your Telegram bot, it reaches ClickRuntime straight away.

  2. ClickRuntime reads the notes in your Memory Google Doc.

  3. AI writes a reply using those notes and picks out any new fact worth keeping.

  4. New facts are added to the end of the doc with the date, and the reply is sent back to you in Telegram.

Before it runs live

  • Connect Google Docs
  • Connect Telegram
  • Paste your automation's link into the other app's webhook settings

What you get

RunsThe moment it happens
Chat with a Telegram assistant that remembers youjust nowSucceeded
Telegram · Assistant botNorthwind Traders pays on 30-day terms, and you asked to invoice them on the 1st. Noted: Contoso Print is now your preferred printer.

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

DOC_ID, MY_CHAT_ID = "your-doc-id", 123456789

@on_event
def handle(event):
    msg = (event.json or {}).get("message") or {}
    if msg.get("chat", {}).get("id") != MY_CHAT_ID or not msg.get("text"):
        return {"skipped": True}
    docs = build("docs", "v1", credentials=Credentials(credentials.connection("google", "work")), cache_discovery=False).documents()
    doc = docs.get(documentId=DOC_ID).execute()
    memory = "".join(r["textRun"]["content"] for c in doc["body"]["content"] for r in c.get("paragraph", {}).get("elements", []) if "textRun" in r)
    out = ai.generate(f"Notes about me:\n{memory[-20000:]}\n\nMy message: {msg['text']}",
                      system="You are my personal assistant. Answer using the notes. If my message states a lasting fact, return it as new_fact, else empty.",
                      max_output_tokens=700, json_schema={"type": "object", "properties": {"reply": {"type": "string"}, "new_fact": {"type": "string"}},
                                                          "required": ["reply", "new_fact"]}).json
    if out["new_fact"]:
        end = doc["body"]["content"][-1]["endIndex"] - 1
        docs.batchUpdate(documentId=DOC_ID, body={"requests": [{"insertText": {"location": {"index": end},
                         "text": f"\n{date.today().isoformat()}: {out['new_fact']}"}}]}).execute()
    http.post(f"https://api.telegram.org/bot{credentials.secret('TELEGRAM_BOT_TOKEN')}/sendMessage",
              json={"chat_id": MY_CHAT_ID, "text": out["reply"]})
    return {"remembered": bool(out["new_fact"])}

FAQ

Common questions

How does it decide what to remember?
When your message contains a lasting fact, such as a preference, a date or a detail about a client, it is added to the doc as a short dated line. Passing questions and small talk are not saved.
Can other people use my bot?
The bot can be limited to your own Telegram account so nobody else can read your notes through it. Messages from any other account are ignored.
What happens when the doc gets very long?
The most recent notes are always used, and older ones are included as space allows. Tidying the doc now and then, by merging or removing old lines, keeps answers focused.
What permissions does it need?
doc shared with service account (edit); bot token. 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 “Chat with a Telegram assistant that remembers you” from your assistant

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