Every 5 minutes
Draft email replies from your knowledge base
Customer emails get an accurate draft reply in Gmail, written from the docs you keep in Pinecone.
- Runs
- Every 5 minutes
- Apps
- Gmail, Pinecone
- AI
- Yes, uses the built-in AI allowance
- Access
- gmail.modify, gmail.compose; Pinecone read
Send this to your assistant
Create a ClickRuntime automation: every 5 minutes, check Gmail for new customer emails, skip automated ones, look up the answer in my Pinecone index and save a draft reply in the thread. Label each email as processed.
First time? Adding ClickRuntime to your assistant takes about two minutes.
Why use it
Why teams use this automation
Customers ask questions your documentation already answers, but finding the right page and rewriting it as a friendly reply takes several minutes per email. Answers also drift as different people paraphrase the docs from memory.
Founders, small support teams and anyone running a product inbox use it to open Gmail and find replies already drafted from their own material.
What you get out of it
Replies already waiting
Each customer email has a draft in its thread, ready to check and send.
Accurate, not invented
Drafts use only what your knowledge base says, so answers match your docs.
Automated mail ignored
Receipts, notifications and newsletters are skipped, so drafts are only made where a reply makes sense.
Easy to see what's done
Processed emails get a label, so nothing is drafted twice.
How it works
What happens, step by step
Every 5 minutes, ClickRuntime checks Gmail for new emails that are not labelled as processed.
Automated emails such as receipts and newsletters are skipped.
Your Pinecone index is searched for the passages that best match each question.
AI writes a reply from those passages, saved as a draft in the thread, and the email is labelled as processed.
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 Pinecone
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 Pinecone steps into one automation
Under the hood
The code that runs this automation
import base64
from google.oauth2.credentials import Credentials
from googleapiclient.discovery import build
from clickruntime import on_trigger, report_fetched, credentials, http, ai
LABEL_ID = "Label_321" # "Processed"
HOST, NS = "https://kb-abc123.svc.aped-1234.pinecone.io", "help" # your index host and namespace
def search(text, k=5):
r = http.post(f"{HOST}/records/namespaces/{NS}/search", json={"query": {"inputs": {"text": text}, "top_k": k}}, headers={
"Api-Key": credentials.secret("PINECONE_API_KEY"), "X-Pinecone-API-Version": "2025-04"}).json()
return [h["fields"] for h in r["result"]["hits"]]
@on_trigger
def run(event):
gmail = build("gmail", "v1", credentials=Credentials(credentials.connection("google", "work")), cache_discovery=False).users()
q = "in:inbox -label:Processed -category:promotions -category:updates -from:noreply newer_than:1d"
new = gmail.messages().list(userId="me", q=q).execute().get("messages", [])
report_fetched(len(new))
if not new:
return {"new": 0}
for m in new:
msg = gmail.messages().get(userId="me", id=m["id"], format="metadata", metadataHeaders=["From", "Subject"]).execute()
h = {x["name"]: x["value"] for x in msg["payload"]["headers"]}
docs = "\n\n".join(d["chunk_text"] for d in search(f"{h.get('Subject')} {msg['snippet']}", 4))
reply = ai.generate(f"Write a friendly reply using only these docs. If they don't answer it, say you'll check and ask "
f"for details.\nDocs:\n{docs}\n\nEmail: {h.get('Subject')}\n{msg['snippet']}", max_output_tokens=400).text
gmail.drafts().create(userId="me", body={"message": {"threadId": msg["threadId"], "raw": base64.urlsafe_b64encode(
f"To: {h.get('From')}\r\nSubject: Re: {h.get('Subject')}\r\n\r\n{reply}".encode()).decode()}}).execute()
gmail.messages().modify(userId="me", id=m["id"], body={"addLabelIds": [LABEL_ID]}).execute()
return {"drafted": len(new)}FAQ
Common questions
Does it send the replies?
What if my docs don't cover the question?
How do I keep the knowledge base current?
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
Score job alert emails against your CV
Every hour new job alert emails are compared with your CV, and you get a short email listing the roles worth applying for, with a score and reason.
See how it worksLet visitors ask about your CV, with a daily summary by email
Visitors to your site can ask questions about your experience and get answers from your CV, and you get an email summarising each day's conversations.
See how it worksSend new sign-ups a welcome email matched to what they need
Each new customer gets a personal welcome email from your Gmail that points to the product features most relevant to them.
See how it worksKeep exploring
Set up “Draft email replies from your knowledge base” from your assistant
Copy the prompt above, or connect your assistant first. Free plan, no credit card.