Every 5 minutes
Answer 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.
- Runs
- Every 5 minutes
- 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: every 5 minutes, reply to new support emails with an answer from my FAQ; if you're not confident, don't reply and send the email to me on Telegram.
First time? Adding ClickRuntime to your assistant takes about two minutes.
Why use it
Why teams use this automation
A two-person online shop gets the same support questions every day: where is my order, how do I return this, do you ship to Canada. The owner answers them between packing orders, and customers wait half a day for a two-line reply.
Answering the routine questions straight from your own FAQ, while passing anything unusual to a person, gets customers a quick reply and keeps the tricky cases in human hands.
What you get out of it
Customers hear back in minutes
Common questions are answered quickly, even in the evening or at the weekend.
Answers come from your own FAQ
Replies use the policies and wording you wrote, not guesses, so customers get consistent information.
Unsure cases go to a person
When the question is not covered or the customer is upset, no reply is sent and you get the email on Telegram to handle yourself.
Your time goes to the hard ones
With routine questions handled, the emails you see are the ones that need judgement.
How it works
What happens, step by step
Every 5 minutes ClickRuntime checks your support inbox for new emails.
It skips emails it has already handled.
AI compares each question with your FAQ and drafts an answer, noting whether the FAQ really covers it.
Confident answers are sent as a reply in the same email thread. Everything else is sent to you on Telegram to answer yourself.
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
from email.message import EmailMessage
from clickruntime import on_trigger, credentials, http, state, ai, report_fetched
G = "https://gmail.googleapis.com/gmail/v1/users/me"
FAQ = "Orders ship within 2 working days. Returns are free within 30 days. We ship to the UK, EU, US and Canada."
SCHEMA = {"type": "object", "properties": {"confident": {"type": "boolean"}, "reply": {"type": "string"}}, "required": ["confident", "reply"]}
@on_trigger
def run(event):
h = {"Authorization": f"Bearer {credentials.connection('google', 'work')}"}
seen = set(state.get("seen") or [])
msgs = [m for m in http.get(f"{G}/messages", headers=h, params={"q": "to:support@ newer_than:1d -from:me"}).json().get("messages", []) if m["id"] not in seen]
report_fetched(len(msgs))
if not msgs:
return {"new": 0}
for m in msgs:
msg = http.get(f"{G}/messages/{m['id']}", headers=h, params={"format": "metadata", "metadataHeaders": ["From", "Subject", "Message-ID"]}).json()
hdr = {x["name"]: x["value"] for x in msg["payload"]["headers"]}
r = ai.generate([f"FAQ:\n{FAQ}", f"Customer email:\n{msg['snippet']}", "Answer only from the FAQ. confident=false if it is not covered or the customer is upset."],
json_schema=SCHEMA, max_output_tokens=300).json
if r["confident"]:
e = EmailMessage(); e["To"] = hdr["From"]; e["Subject"] = "Re: " + hdr.get("Subject", ""); e["In-Reply-To"] = hdr.get("Message-ID", ""); e.set_content(r["reply"])
http.post(f"{G}/messages/send", headers=h, json={"raw": base64.urlsafe_b64encode(e.as_bytes()).decode(), "threadId": msg["threadId"]})
else:
bot = credentials.secret("TELEGRAM_BOT_TOKEN")
http.post(f"https://api.telegram.org/bot{bot}/sendMessage", json={"chat_id": credentials.secret("TELEGRAM_CHAT_ID"),
"text": f"Needs you: {hdr['From']}\n{hdr.get('Subject')}\n{msg['snippet']}"})
seen.add(m["id"])
state.set("seen", list(seen)[-1000:])
return {"handled": len(msgs)}FAQ
Common questions
How does it decide whether it is confident?
Which mailbox does it watch?
Can I see what was sent?
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 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 worksApprove 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.
See how it worksKeep exploring
Set up “Answer support emails from your FAQ and escalate the rest to Telegram” from your assistant
Copy the prompt above, or connect your assistant first. Free plan, no credit card.