Skip to content

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.

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

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

  1. Every 5 minutes, ClickRuntime checks Gmail for new emails that are not labelled as processed.

  2. Automated emails such as receipts and newsletters are skipped.

  3. Your Pinecone index is searched for the passages that best match each question.

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

RunsEvery 5 minutes
Draft email replies from your knowledge basetoday, 9:00Succeeded
Gmail · DraftsRe: Do you ship to Ireland? Hi Dana, yes. Orders to Ireland arrive in 3 to 5 working days and shipping is free over 50 EUR.

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 Pinecone 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.
email_auto_replies_grounded_in_my_knowledge_base.pyexample
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?
No. It saves drafts in Gmail. You read, edit and send them.
What if my docs don't cover the question?
The draft says so plainly and asks the customer for more detail, rather than guessing. You can also ask for those emails to be left without a draft.
How do I keep the knowledge base current?
Re-index documents when they change, for example with the nightly sync automation. Drafts always use the latest index.
What permissions does it need?
gmail.modify, gmail.compose; Pinecone read. 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 “Draft email replies from your knowledge base” from your assistant

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