Skip to content

Every 5 minutes

Reply to WhatsApp customers by replying to an email

When you reply in Gmail to a "WhatsApp from … (+number)" email, your reply text is sent to that customer on WhatsApp from your business number within 5 minutes.

Runs
Every 5 minutes
Apps
Gmail, WhatsApp Business
AI
Not needed
Access
Gmail read + modify; WhatsApp messaging

Send this to your assistant

Create a ClickRuntime automation: every 5 minutes, find emails I've sent in Gmail that reply to 'WhatsApp from … (+number)' threads, and send my reply text to that number on WhatsApp from my business number, then label the email Sent to WhatsApp.

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

Getting WhatsApp messages into email solves half the problem. The other half is answering, and switching to a phone or a separate WhatsApp login for each reply slows the team down.

This watches your Gmail sent mail for replies to WhatsApp threads and sends the reply text to the customer on WhatsApp from your business number. The quoted part of the email is removed so the customer only sees your answer.

It suits support teams who already forward WhatsApp messages into a shared Gmail inbox and want to answer from there.

What you get out of it

  • Answer from the inbox you already use

    Agents reply in Gmail as they would to any email. The customer gets the answer on WhatsApp.

  • No shared phone

    Nobody needs to pass around a phone or a WhatsApp Business login to answer customers.

  • A copy of every answer

    Each reply stays in Gmail's sent mail, in the same thread as the customer's message, so the full conversation is in one place.

  • Told when WhatsApp says no

    Replies outside WhatsApp's 24-hour window are refused by WhatsApp. You get an email with the reason, so the customer is not left waiting without anyone knowing.

  • Sent once only

    Each handled email is labelled, so a reply is never sent to the customer twice.

How it works

What happens, step by step

  1. Every 5 minutes ClickRuntime looks in your Gmail sent mail for replies to WhatsApp message threads.

  2. It reads the customer's number from the subject line.

  3. Your reply is trimmed of the quoted text and sent to the customer on WhatsApp from your business number.

  4. The email is labelled so it is never sent twice, and you are told by email if WhatsApp refuses the message.

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 WhatsApp Business

What you get

RunsEvery 5 minutes
Reply to WhatsApp customers by replying to an emailtoday, 9:00Succeeded
WhatsApp · to +34 612 345 678Hi Maria, your oak shelf (order 10482) left our warehouse this morning. Tracking: ES4829173. It should arrive Thursday.

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
  • Add an AI step, for example to summarize, sort or draft a reply
  • Add another app, for example also send it to Slack
  • Combine it with other Gmail and WhatsApp Business 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.
reply_to_whatsapp_customers_by_replying_to_an_email.pyexample
import re, base64
from google.oauth2.credentials import Credentials
from googleapiclient.discovery import build
from clickruntime import on_trigger, credentials, http, notify, report_fetched

WA = "https://graph.facebook.com/v20.0/your-phone-number-id/messages"
gmail = lambda: build("gmail", "v1", credentials=Credentials(credentials.connection("google", "work")), cache_discovery=False).users()
LABEL = "Label_sent_to_whatsapp"  # Gmail label ID for "Sent to WhatsApp"
QUERY = 'in:sent subject:"WhatsApp from" -label:sent-to-whatsapp newer_than:2d'

def plain_body(payload):
    parts = payload.get("parts") or [payload]
    for p in parts:
        if p.get("mimeType") == "text/plain" and p["body"].get("data"):
            return base64.urlsafe_b64decode(p["body"]["data"]).decode(errors="ignore")
        if p.get("parts"):
            found = plain_body(p)
            if found:
                return found
    return ""

def strip_quote(text):
    lines = []
    for line in text.splitlines():
        if line.startswith(">") or re.match(r"^On .+wrote:$", line.strip()):
            break
        lines.append(line)
    return "\n".join(lines).strip()

@on_trigger
def run(event):
    ids = [m["id"] for m in gmail().messages().list(userId="me", q=QUERY, maxResults=20).execute().get("messages", [])]
    report_fetched(len(ids))
    sent = 0
    for i in ids:
        m = gmail().messages().get(userId="me", id=i, format="full").execute()
        subject = next(h["value"] for h in m["payload"]["headers"] if h["name"] == "Subject")
        number = re.search(r"\(\+(\d{7,15})\)", subject)
        text = strip_quote(plain_body(m["payload"]))
        if number and text:
            r = http.post(WA, headers={"Authorization": f"Bearer {credentials.secret('WHATSAPP_TOKEN')}"},
                          json={"messaging_product": "whatsapp", "to": number.group(1), "type": "text", "text": {"body": text[:4000]}})
            if r.status_code >= 400:
                notify.email_me(f"WhatsApp reply not sent to +{number.group(1)}",
                                f"WhatsApp said: {r.json().get('error', {}).get('message')}\n\nYour reply:\n{text}")
            else:
                sent += 1
        gmail().messages().modify(userId="me", id=i, body={"addLabelIds": [LABEL]}).execute()
    return {"sent": sent}

FAQ

Common questions

Why might a reply not be delivered?
WhatsApp only allows free-form replies within 24 hours of the customer's last message. After that, a business must send an approved template. If WhatsApp refuses a reply, you get an email with its reason and your text.
Do I need the forwarding automation as well?
It works best with it, because the forwarding emails have the customer's number in the subject. Any thread whose subject has the WhatsApp from and (+number) pattern will work.
Does my email signature get sent?
Everything above the quoted message is sent, which can include a signature. Ask your assistant to cut the text at your signature line, such as two dashes, if you use one.
What permissions does it need?
Gmail read + modify; WhatsApp messaging. Nothing else in your accounts is used.
Does it need AI?
No. It runs without AI, so it doesn't use your plan's 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 “Reply to WhatsApp customers by replying to an email” from your assistant

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