Send Resend emails when a Better Stack monitor goes down
A Better Stack + Resend agent flow
A monitor flips to down and the right person is the one not in the on-call chat: a customer's account manager, a vendor's NOC, an exec who wants a heads-up when checkout is unreachable. This recipe lets your agent read Better Stack's Uptime monitors and email the people who belong on a specific incident, with wording you control, rather than the generic alert everyone tunes out. It calls uptime_list_monitors, finds the ones currently down, and sends a message per affected monitor with Resend's send-email: which check failed, since when, and a link to the monitor. The Better Stack server replies when asked, not on a push, so the agent runs on a tight loop and the email goes out shortly after a check starts failing.
The flow
uptime_list_monitorsLists Uptime monitors, with filtering options.
send-emailSends a single transactional email immediately or scheduled, with HTML/text, attachments, CC/BCC, and tags.
Step by step
- Decide who hears about what
Map monitors, or groups of them, to recipients and a from address. The checkout monitor might email the revenue lead; the API monitor might email a partner. Set a verified sending domain in Resend first.
- Read the monitors
The agent calls uptime_list_monitors and inspects each one's status, reading which are down, when they last changed, and the monitor's name and URL.
- Send the email
For each newly-down monitor it calls send-email with the mapped recipients, a subject naming the check, and a body with the failure time and the monitor link. Use a tag so these are filterable in Resend.
- Email on the edges, not every poll
Track each monitor's last-known status. Email when one transitions down, and again when it recovers, instead of resending while it stays down, so a long outage is two emails, not forty.
Tell your agent
Every minute, list Better Stack Uptime monitors and find any that just went from up to down. For each, send a Resend email from alerts@acme.com to the owner mapped for that monitor, subject 'DOWN: <monitor name>', body with the time it failed and the monitor link, tagged 'uptime'. Send a recovery email when it comes back up. Don't resend while it stays down.
Setup
This flow needs both servers connected to your agent. Follow each install guide:
Worth knowing
- send-email needs a verified sending domain in Resend with SPF and DKIM, or the mail won't deliver. Set the from address to that domain and confirm verification before relying on it.
- uptime_list_monitors reports current status, not a stream of changes. The agent must compare against the status it saw last run to detect a real down or recovery edge.
- Add a confirmation rule for who can be emailed. Pin the recipient mapping in the prompt so a misread monitor name can't send a real outage notice to the wrong customer.
Questions
- How is this different from Better Stack's built-in notifications?
- Built-in alerts route to fixed channels. Here the agent decides the recipient and the wording per monitor, so a specific failure reaches a specific person, with copy you write, without standing up a separate escalation policy for each case.
- Will a long outage spam the recipient?
- Not if you track status. The agent emails on the down edge and again on recovery, and stays quiet in between, so one outage produces one alert and one all-clear.
- How fast does the email go out?
- Within your polling interval. The server answers the agent's call rather than pushing, so a one-minute loop means the email lands about a minute after a check starts failing.