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.
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
Every 5 minutes it looks for leads in Supabase that haven't been contacted.
AI reads each lead's message and judges whether they sound keen, neutral or frustrated.
The approved WhatsApp template for that tone is sent with their name.
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
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 Supabase and WhatsApp Business steps into one automation
Under the hood
The code that runs this automation
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?
What columns does the table need?
What if the lead has no phone number?
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
Answer WhatsApp questions from your Supabase knowledge base
Customers who message you on WhatsApp get an answer drawn from the docs or catalogue in your Supabase database, and you're emailed the questions it couldn't answer.
See how it worksLog WhatsApp requests in Supabase by category and urgency
Every WhatsApp request is sorted by type and urgency, saved in your Supabase table and acknowledged, with urgent ones emailed to you.
See how it worksTake WhatsApp orders into Supabase
Customers order or ask for a quote on WhatsApp, the items are priced from your Supabase menu, the order is saved and they get a summary back.
See how it worksKeep exploring
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.