The moment it happens
Sell with Telegram Stars and log every payment in a sheet
Customers buy from your bot with Telegram Stars, and every payment and refund lands in your Google Sheet.
- 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 a user sends /buy to my bot, send a Telegram Stars invoice; when they pay, log it in my Payments sheet and confirm. Handle /refund too.
First time? Adding ClickRuntime to your assistant takes about two minutes.
Why use it
Why teams use this automation
A developer runs a Telegram bot that offers premium features, guides or digital downloads. Telegram requires digital goods to be sold in Stars, and the payment flow involves several messages that have to be answered quickly and correctly. Without a record outside Telegram, it is hard to know who paid, for what, and what has been refunded.
This automation handles the full flow: it sends the invoice, approves the checkout, confirms the purchase and records it. Refund requests are processed the same way, so the sheet is an accurate ledger you can reconcile and report from.
What you get out of it
A ledger you can actually read
Every payment and refund is a row with the user, amount and payment reference. Monthly revenue, top buyers and refund rates are a simple sheet formula away.
Checkout is answered in time
Telegram expects a quick answer before it charges the user. Handling it automatically means buyers are not left with a failed payment because nobody responded.
Refunds without digging
The payment reference needed for a refund is already in the sheet. A /refund request uses it, and a refund row is added so your totals stay correct.
Buyers get an instant confirmation
A confirmation message right after paying reassures the buyer. It also cuts down on "did my payment go through?" messages.
How it works
What happens, step by step
When someone sends /buy to your bot, it sends them an invoice priced in Telegram Stars.
When they tap Pay, ClickRuntime approves the checkout straight away.
Once the payment succeeds, a row with the buyer, amount and payment reference is added to the Payments tab, and the buyer gets a confirmation.
If a refund is requested with /refund, the payment is refunded and the refund is logged in 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
Build your own
Need it to work differently?
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
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):
u = event.json or {}
tg = f"https://api.telegram.org/bot{credentials.secret('TELEGRAM_BOT_TOKEN')}"
if "pre_checkout_query" in u:
http.post(f"{tg}/answerPreCheckoutQuery", json={"pre_checkout_query_id": u["pre_checkout_query"]["id"], "ok": True})
return {"precheckout": "ok"}
msg = u.get("message") or {}
chat, uid, text = msg.get("chat", {}).get("id"), msg.get("from", {}).get("id"), msg.get("text", "")
sheets = build("sheets", "v4", credentials=Credentials(credentials.connection("google", "work")), cache_discovery=False)
log_row = lambda row: sheets.spreadsheets().values().append(spreadsheetId=SHEET_ID, range="Payments!A:E",
valueInputOption="USER_ENTERED", body={"values": [row]}).execute()
if text == "/buy":
http.post(f"{tg}/sendInvoice", json={"chat_id": chat, "title": "Pro access", "description": "30 days of Pro",
"payload": "pro-30", "currency": "XTR", "prices": [{"label": "Pro", "amount": 100}]})
elif "successful_payment" in msg:
p = msg["successful_payment"]
log_row([event.received_at, uid, p["total_amount"], p["telegram_payment_charge_id"], "paid"])
http.post(f"{tg}/sendMessage", json={"chat_id": chat, "text": "Payment received, Pro is active."})
elif text.startswith("/refund "):
charge = text.split(" ", 1)[1]
http.post(f"{tg}/refundStarPayment", json={"user_id": uid, "telegram_payment_charge_id": charge})
log_row([event.received_at, uid, 0, charge, "refunded"])
return {"handled": True}FAQ
Common questions
What are Telegram Stars?
Can I sell more than one product?
Who can trigger a refund?
What permissions does it need?
Does it need AI?
How many runs does it use?
Can I change how it works?
Related
You might also like
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.
See how it worksRecord 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.
See how it worksTurn Telegram ideas into short videos logged in a sheet
Message your bot an idea and get back a finished short video, with every video tracked in your Google Sheet.
See how it worksKeep exploring
Set up “Sell with Telegram Stars and log every payment in a sheet” from your assistant
Copy the prompt above, or connect your assistant first. Free plan, no credit card.