Skip to content

Hourly

Get warned when your bounce rate climbs

You hear the same day if today's bounces pass your limit, once rather than every hour.

Runs
Hourly
Apps
Mailgun
AI
Not needed
Access
private API key (read)

Send this to your assistant

Create a ClickRuntime automation: every hour, check today's bounce rate for my Mailgun domain mg.example.com and email me if it's above 5%, no more than once a day.

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

Bounce rate is the number mailbox providers watch most closely when deciding whether your Mailgun domain deserves the inbox. A single bad import, a leaked signup form or a typo in a template can send hundreds of messages to dead addresses in an afternoon. When bounces climb above a few percent, deliverability suffers for every message you send, including password resets and invoices.

Each hour, ClickRuntime queries Mailgun's Metrics API for today's totals, works out the bounce rate as a share of attempted deliveries, and compares it with your limit. If the rate goes over, you get a single alert for that day, so you are warned without being flooded by repeats.

It is meant for SaaS teams and developers who send transactional and marketing email through Mailgun and cannot afford a damaged sender reputation.

What you get out of it

  • Reputation damage is stopped early

    Providers like Gmail and Yahoo respond to sustained bad sending within days. An hourly check means you can pause a faulty campaign the same afternoon, before throttling or spam-folder placement sets in.

  • Bad data is traced to its source

    When the alert fires, you know the problem started today, so you check the latest import, form or integration. Without the alert you would be hunting through weeks of logs for the cause.

  • Critical emails keep arriving

    Password resets, receipts and login codes share your sending domain with newsletters. Protecting the domain from a bounce spike protects the messages customers actually need to receive. The hourly check keeps that risk small, which matters most for the emails customers depend on.

  • One alert per day, not fifty

    Because the warning fires once per day per breach, your inbox and chat are not buried. It stays meaningful, so the team continues to read it when it appears. That keeps people reading it, and nobody learns to ignore the warnings that come from this check.

  • A dated record of incidents

    Every alert and run is logged, giving you evidence of when issues occurred and how quickly you responded. That helps in post-mortems and in conversations with Mailgun support. That record also helps when you explain an incident to management or to a customer.

How it works

What happens, step by step

  1. Every hour, ClickRuntime pulls today's delivery and bounce counts from Mailgun.

  2. It works out today's bounce rate and compares it with your limit.

  3. The first time it goes over, you get an email with the rate in the subject and the counts. You won't get another until the next day.

Before it runs live

  • Connect Mailgun

What you get

RunsHourly
Get warned when your bounce rate climbstoday, 9:00Succeeded
Email · Mailgun bounce rate 6.3%41 bounced, 610 delivered today.

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

  • Run it at a different time, more or less often, or only on weekdays
  • 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 Mailgun 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.
bounce_rate_threshold_alert.pyexample
from datetime import datetime, timezone
from email.utils import format_datetime
from clickruntime import on_trigger, credentials, http, notify, state

DOMAIN = "mg.example.com"
LIMIT = 5.0

@on_trigger
def run(event):
    now = datetime.now(timezone.utc)
    start = now.replace(hour=0, minute=0, second=0, microsecond=0)
    resp = http.post("https://api.mailgun.net/v1/analytics/metrics",
                     auth=("api", credentials.secret("MAILGUN_API_KEY")), json={
        "start": format_datetime(start), "end": format_datetime(now), "resolution": "day",
        "metrics": ["delivered_count", "bounced_count", "bounced_rate"],
        "filter": {"AND": [{"attribute": "domain", "comparator": "=", "values": [{"label": DOMAIN, "value": DOMAIN}]}]}})
    resp.raise_for_status()
    items = resp.json().get("items", [])
    m = items[0]["metrics"] if items else {}
    rate = float(m.get("bounced_rate") or 0)
    today = str(start.date())
    if rate > LIMIT and state.get("alerted_on") != today:
        notify.email_me(f"Mailgun bounce rate {rate:.1f}% on {DOMAIN}",
                        f"{m.get('bounced_count', 0)} bounced, {m.get('delivered_count', 0)} delivered today.")
        state.set("alerted_on", today)
    return {"bounce_rate": rate}

FAQ

Common questions

How is the bounce rate calculated?
It divides the number of bounced messages by the number of messages Mailgun attempted to deliver for the day so far, using figures from the Metrics API. Early in the day the sample is small, so a tiny volume can produce a high rate.
What threshold should I choose?
Many senders aim to stay below about 2 percent, and anything above 5 percent is usually a problem worth stopping for. The right figure depends on your list quality and volume, so set it based on your normal level and adjust it over time.
Does it separate hard bounces from soft bounces?
The check focuses on the overall bounce measure Mailgun reports. If you want it to track permanent failures only, which are the ones that harm reputation most, you can ask for the metric to be narrowed that way.
What permissions does it need?
private API key (read). 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 runs (hourly). Checks that find nothing to do 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 “Get warned when your bounce rate climbs” from your assistant

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