Every 15 min + incoming webhook
Approve supplier invoices from Telegram
Each supplier invoice email is sent to your Telegram with supplier, amount and due date, and replying 'ok' marks it Approved in Gmail.
- Runs
- Every 15 min + incoming webhook
- Apps
- Gmail, Telegram
- AI
- Yes, uses the built-in AI allowance
- Access
- Gmail gmail.modify; Telegram bot token
Send this to your assistant
Create a ClickRuntime automation: when a supplier invoice email arrives, send me the supplier, amount and due date on Telegram; when I reply 'ok', label the email Approved.
First time? Adding ClickRuntime to your assistant takes about two minutes.
Why use it
Why teams use this automation
The owner of a restaurant gets invoices from a dozen suppliers: produce, wine, linen, cleaning. She is on the floor most of the day, not at a desk, and invoices wait in her inbox until the weekend. Her bookkeeper cannot pay anything until she has looked at it, so payments go out late.
Getting the essentials of each invoice on your phone and approving it with a one-word reply means bills are checked the day they arrive. Owners who are rarely at a computer use it to keep suppliers paid on time and give their bookkeeper a clear list of what is approved.
What you get out of it
Approve from your phone in seconds
Supplier, amount and due date in one message is enough to decide. Replying 'ok' is all it takes.
Suppliers get paid on time
Invoices are approved the day they arrive instead of piling up, which avoids late fees and keeps good terms with suppliers.
Your bookkeeper knows what to pay
The Approved label in Gmail gives whoever handles payments a clear list to work from.
Unexpected amounts stand out
Seeing each total as it arrives makes it easy to spot a price rise or a duplicate charge before it is paid.
How it works
What happens, step by step
Every few minutes ClickRuntime checks your Gmail for new emails with an invoice attached.
It skips emails it has already sent to you.
AI reads each invoice and picks out the supplier, amount and due date, which are sent to you on Telegram.
When you reply 'ok' to one of those messages, the matching email is labelled Approved in Gmail.
Before it runs live
- Connect Google through your own Google app (a one-time, 10-minute setup), so it works with your own Gmail
- Connect Telegram
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
- 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 Gmail and Telegram steps into one automation
Under the hood
The code that runs this automation
import base64, io; from pypdf import PdfReader
from google.oauth2.credentials import Credentials
from googleapiclient.discovery import build
from clickruntime import on_trigger, credentials, http, state, ai, report_fetched
CHAT_ID, APPROVED_LABEL = "your-chat-id", "Label_Approved"
SCHEMA = {"type": "object", "properties": {k: {"type": "string"} for k in ["supplier", "amount", "due_date"]}}
@on_trigger
def run(event):
tg = f"https://api.telegram.org/bot{credentials.secret('TELEGRAM_BOT_TOKEN')}"
gmail = build("gmail", "v1", credentials=Credentials(credentials.connection("google", "work")), cache_discovery=False).users()
pending, sent = state.get("pending") or {}, set(state.get("sent") or [])
msgs = [m for m in gmail.messages().list(userId="me", q="has:attachment filename:pdf invoice newer_than:3d").execute().get("messages", []) if m["id"] not in sent]
updates = http.get(f"{tg}/getUpdates", params={"offset": state.get("offset") or 0}).json()["result"]
report_fetched(len(msgs) + len(updates))
if not msgs and not updates:
return {"summary": "Nothing new"}
for u in updates:
reply = u.get("message", {}); orig = str(reply.get("reply_to_message", {}).get("message_id"))
if reply.get("text", "").strip().lower() == "ok" and orig in pending:
gmail.messages().modify(userId="me", id=pending.pop(orig), body={"addLabelIds": [APPROVED_LABEL]}).execute()
state.set("offset", u["update_id"] + 1)
for m in msgs:
part = next(p for p in gmail.messages().get(userId="me", id=m["id"]).execute()["payload"].get("parts", []) if p.get("filename", "").lower().endswith(".pdf"))
pdf = base64.urlsafe_b64decode(gmail.messages().attachments().get(userId="me", messageId=m["id"], id=part["body"]["attachmentId"]).execute()["data"])
text = "".join(p.extract_text() or "" for p in PdfReader(io.BytesIO(pdf)).pages)[:5000]
f = ai.generate(f"From this invoice extract supplier, amount with currency and due date:\n{text}", json_schema=SCHEMA, max_output_tokens=100).json
r = http.post(f"{tg}/sendMessage", json={"chat_id": CHAT_ID, "text": f"{f['supplier']}: {f['amount']}, due {f['due_date']}. Reply ok to approve."}).json()
pending[str(r["result"]["message_id"])] = m["id"]; sent.add(m["id"])
state.set("pending", pending); state.set("sent", list(sent)[-1000:])
return {"sent": len(msgs), "replies": len(updates)}FAQ
Common questions
How does it tell supplier invoices apart from other email?
What happens if I reply something other than 'ok'?
Can someone else approve as well?
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
Sort your inbox with AI and get urgent emails on Telegram
New emails are labelled and newsletters archived for you, and only the urgent ones reach your phone as a Telegram message.
See how it worksAnswer support emails from your FAQ and escalate the rest to Telegram
Routine support questions get a reply from your FAQ within minutes, and anything the AI is unsure about is sent to you on Telegram instead.
See how it worksReply to new lead emails fast and get a Telegram ping
Each new lead email gets a personal first reply within minutes, and you get a Telegram message with the lead and how promising it looks.
See how it worksKeep exploring
Set up “Approve supplier invoices from Telegram” from your assistant
Copy the prompt above, or connect your assistant first. Free plan, no credit card.