Recipes
On-call alerts with acknowledgement
Wake up the right person when production breaks, and escalate to the next one if they can't take it.
When an alert fires, call the on-call engineer. They acknowledge or pass it on; if nobody answers, you call the next person.
const people = ["+447700900123", "+447700900456", "+447700900789"];
export async function page(alert, index = 0) {
if (index >= people.length) return notifyEveryoneByEmail(alert);
await fetch("https://api.callhuman.es/v1/calls", {
method: "POST",
headers: {
Authorization: `Bearer ${process.env.CALLHUMAN_API_KEY}`,
"Content-Type": "application/json",
},
body: JSON.stringify({
to: people[index],
message: `${alert.title}. ${alert.summary}`,
options: [
{ label: "I'm on it", reply: "Thanks. The team knows you're on it." },
{ label: "Pass to the next person" },
],
webhook_url: "https://ops.example/hooks/oncall",
metadata: { alert_id: alert.id, index },
}),
});
}
// Webhook: escalate unless someone took it.
export async function onCallResult(call) {
const { alert_id, index } = call.metadata;
if (call.status === "answered" && call.option_label === "I'm on it") return acknowledge(alert_id, index);
return page(await getAlert(alert_id), index + 1);
}CallHuman: Production checkout is down. 37 errors in the last 5 minutes.
CallHuman: Press 1 or say “I'm on it”. Press 2 to pass it to the next person.
Person: “On it”
CallHuman: Thanks. The team knows you're on it.
Retries and urgency
Calls with options are retried twice, 5 minutes apart, before ending as not_answered. For faster escalation, call the next person as soon as you get not_answered from the first.