Skip to content

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.

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

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

  1. Every few minutes ClickRuntime checks your Gmail for new emails with an invoice attached.

  2. It skips emails it has already sent to you.

  3. AI reads each invoice and picks out the supplier, amount and due date, which are sent to you on Telegram.

  4. 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

RunsEvery 15 min + incoming webhook
Approve supplier invoices from Telegramtoday, 9:00Succeeded
Telegram · InvoicesAcme Produce: 1,240.50 EUR, due 31 Oct. Reply ok to approve.

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 Gmail 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.
supplier_invoice_emails_flagged_on_telegram.pyexample
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?
It looks at emails with a PDF attachment and checks whether the content is an invoice. Newsletters and order confirmations without an amount due are skipped.
What happens if I reply something other than 'ok'?
Only a reply of 'ok' to the invoice message approves it. Anything else is ignored, so you can leave an invoice for later and deal with it at your desk.
Can someone else approve as well?
Yes. The messages can go to a Telegram group, and a reply of 'ok' from anyone in the group approves the invoice.
What permissions does it need?
Gmail gmail.modify; Telegram 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 each time it checks. Checks that find nothing new and stop right away aren't counted.
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 “Approve supplier invoices from Telegram” from your assistant

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