Skip to content

The moment it happens

Give your Telegram bot a long-term memory

Tell your Telegram bot things as they come up and ask about them later; it remembers what you said and keeps a running notes Doc.

Runs
The moment it happens
Apps
Google Docs, Pinecone
AI
Yes, uses the built-in AI allowance
Access
Pinecone key; Docs edit

Send this to your assistant

Create a ClickRuntime automation: when I message my Telegram bot, remember what I tell it in Pinecone and a Google Doc, and answer my questions using what it remembers.

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 consultant juggling several clients picks up small facts all day: a client's preferred meeting time, the name of a new contact, a decision made on a call. They end up in scattered notes apps and chat threads, and a month later the one detail needed is impossible to find.

This automation gives you a Telegram bot that remembers. Anything you send is stored as a memory and added to a notes Google Doc. When you ask a question, the bot looks up the most relevant memories and answers from them.

What you get out of it

  • Capture in seconds

    Sending a message to a bot is quicker than opening a notes app and picking a folder. More things get written down.

  • Ask in plain words

    You do not need to remember how you phrased something. Searching by meaning finds the note about the Acme kickoff even when you ask about the project start.

  • A readable record in Google Docs

    Every note is also added to a Doc with the date. You can scroll, search or share it like any other document.

  • Your memory, your accounts

    Memories are stored in your own Pinecone index and your own Google Doc. You can inspect, export or delete them at any time.

How it works

What happens, step by step

  1. When you message your Telegram bot, ClickRuntime receives the message.

  2. A note is saved to your Pinecone memory index and added to your notes Google Doc with the date.

  3. A question is matched against your saved memories to find the most relevant ones.

  4. AI answers using only those memories, and the reply is sent back to you on Telegram.

Before it runs live

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

What you get

RunsThe moment it happens
Give your Telegram bot a long-term memoryjust nowSucceeded
Telegram · Memory botAcme prefers Tuesday morning calls, and their new contact for billing is in finance (noted 3 Oct).

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 Pinecone 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.
chat_assistant_with_long_term_memory.pyexample
from datetime import date
from clickruntime import on_event, credentials, http, ai

INDEX_HOST = "https://your-index.svc.your-env.pinecone.io"
DOC_ID = "your-notes-doc-id"

@on_event
def handle(event):
    msg = (event.json or {}).get("message") or {}
    text = msg.get("text", "").strip()
    if not text:
        return {"skipped": True}
    pc = {"Api-Key": credentials.secret("PINECONE_API_KEY"), "X-Pinecone-API-Version": "2025-01"}
    if text.endswith("?"):
        hits = http.post(f"{INDEX_HOST}/records/namespaces/notes/search", headers=pc,
                         json={"query": {"inputs": {"text": text}, "top_k": 8}, "fields": ["text"]}).json()["result"]["hits"]
        notes = "\n".join(h["fields"]["text"] for h in hits)
        try:
            reply = ai.generate(f"Notes:\n{notes}\n\nQuestion: {text}", system="Answer from the notes only.", max_output_tokens=300).text
        except ai.AIError:
            reply = "Closest notes:\n" + notes[:1500]
    else:
        http.post(f"{INDEX_HOST}/records/namespaces/notes/upsert", headers=pc, json={"_id": str(event.event_id), "text": text})
        http.post(f"https://docs.googleapis.com/v1/documents/{DOC_ID}:batchUpdate", headers={"Authorization": f"Bearer {credentials.connection('google', 'work')}"},
                  json={"requests": [{"insertText": {"endOfSegmentLocation": {}, "text": f"\n{date.today()}: {text}"}}]})
        reply = "Noted."
    http.post(f"https://api.telegram.org/bot{credentials.secret('TELEGRAM_BOT_TOKEN')}/sendMessage", json={"chat_id": msg["chat"]["id"], "text": reply})
    return {"question": text.endswith("?")}

FAQ

Common questions

How does it tell a note from a question?
Messages ending in a question mark are treated as questions and answered. Everything else is stored as a note, and the bot confirms with a short reply.
What do I need in Pinecone?
An index set up with the integrated embedding model, so text can be stored and searched without a separate embedding service. The free Pinecone tier is enough for personal notes.
Can I make it forget something?
Yes. Delete the line from the Google Doc and the record from your Pinecone index, or send a forget command that the script removes by matching text.
What permissions does it need?
Pinecone key; Docs edit. 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 “Give your Telegram bot a long-term memory” from your assistant

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