Skip to content

Every 5 minutes

Reply to new leads on WhatsApp in a matching tone

New leads saved in Supabase get a WhatsApp reply chosen to match the tone of their message, and the lead is marked as contacted.

Runs
Every 5 minutes
Apps
Supabase, WhatsApp Business
AI
Yes, uses the built-in AI allowance
Access
Supabase read+write; WhatsApp messaging

Send this to your assistant

Create a ClickRuntime automation: every 5 minutes, find new leads in our Supabase leads table, judge whether each message is keen, neutral or frustrated, send the matching approved WhatsApp template, and mark the lead contacted.

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

Leads arrive in very different moods: some are ready to buy, some are just browsing, some are frustrated with their current provider. A single generic reply fits none of them well.

Choosing the right approved template for each lead's tone, and sending it within minutes, makes the first contact feel more personal and more likely to get a reply.

What you get out of it

  • Fast first contact

    Leads hear from you within minutes.

  • The right tone

    Keen leads get a booking link, frustrated ones get reassurance.

  • Approved wording only

    Only your approved templates are used, so nothing unexpected is sent.

  • Clear status

    Each lead is marked contacted with the template used.

How it works

What happens, step by step

  1. Every 5 minutes it looks for leads in Supabase that haven't been contacted.

  2. AI reads each lead's message and judges whether they sound keen, neutral or frustrated.

  3. The approved WhatsApp template for that tone is sent with their name.

  4. The lead is marked contacted, with the template used, so it isn't sent again.

Before it runs live

  • Connect Supabase
  • Connect WhatsApp Business

What you get

RunsEvery 5 minutes
Reply to new leads on WhatsApp in a matching tonetoday, 9:00Succeeded
WhatsApp · TemplateHi Jamie, sorry to hear your current setup is causing trouble. We help teams like Acme switch in a week. Can we call you?

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 Supabase 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_new_leads_on_whatsapp_based_on_sentiment.pyexample
from clickruntime import on_trigger, credentials, http, ai, report_fetched

TEMPLATES = {"keen": "lead_book_call", "neutral": "lead_intro", "frustrated": "lead_reassure"}
SUPABASE_URL = "https://your-project.supabase.co"
sb = lambda: {"apikey": credentials.secret("SUPABASE_SECRET_KEY"), "Authorization": f"Bearer {credentials.secret('SUPABASE_SECRET_KEY')}"}
WA = "https://graph.facebook.com/v20.0/your-phone-number-id/messages"

def wa_template(to, name, params):
    body = {"messaging_product": "whatsapp", "to": to, "type": "template", "template": {"name": name, "language": {"code": "en"},
            "components": [{"type": "body", "parameters": [{"type": "text", "text": str(p)} for p in params]}]}}
    return http.post(WA, headers={"Authorization": f"Bearer {credentials.secret('WHATSAPP_TOKEN')}"}, json=body).json()

@on_trigger
def run(event):
    leads = http.get(f"{SUPABASE_URL}/rest/v1/leads", headers=sb(),
                     params={"contacted": "is.false", "phone": "not.is.null", "select": "id,name,phone,message", "limit": 20}).json()
    report_fetched(len(leads))
    if not leads:
        return {"summary": "No new leads"}
    for lead in leads:
        tone = ai.generate((lead.get("message") or "")[:1000], system="Reply with one word: keen, neutral or frustrated.",
                           max_output_tokens=5).text.strip().lower()
        template = TEMPLATES.get(tone, "lead_intro")
        wa_template(lead["phone"], template, [lead.get("name") or "there"])
        http.patch(f"{SUPABASE_URL}/rest/v1/leads", headers=sb(), params={"id": f"eq.{lead['id']}"},
                   json={"contacted": True, "template": template})
    return {"contacted": len(leads)}

FAQ

Common questions

Why templates instead of free text?
WhatsApp only lets businesses start a conversation with approved templates. You create one per tone.
What columns does the table need?
Phone, name, message and a contacted flag. The template used is written back.
What if the lead has no phone number?
It's skipped and left for your team to follow up another way.
What permissions does it need?
Supabase read+write; WhatsApp messaging. 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 “Reply to new leads on WhatsApp in a matching tone” from your assistant

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