Send a formatted ops alert to an on-call engineer via LINE
Wann einsetzen: You want Sentry/Prometheus alerts to ping specific engineers on LINE with a tidy Flex card, not a wall of text.
Voraussetzungen
- LINE Official Account + channel access token — developers.line.biz → Channel → Messaging API → Issue token
- The engineer's userId (from your bot's webhook events) — Capture userId from a
followormessageevent; store in your user DB
Ablauf
-
Design the Flex bubbleDesign a Flex Message bubble for a Sentry alert: header (issue title), body (event count, release, affected users), buttons (Open in Sentry, Ack).✓ Kopiert→ Valid Flex JSON Claude can validate
-
Push to the on-call userPush this Flex message to userId U1234567890abcdef with altText 'Sentry alert: <title>'.✓ Kopiert→ messageId returned, no 400
-
Handle fallback if user blocked the botIf the push fails with 400 (user blocked), multicast to the secondary on-call userIds instead and log the original failure.✓ Kopiert→ Graceful fallback path
Ergebnis: A polished, actionable alert in LINE within 2 seconds of the underlying event.
Fallstricke
- altText required and capped at 400 chars — pushes fail silently without it — Always include altText; keep it under 400 chars summarizing the Flex
- Pushing without the user being a friend of the bot fails 400 — Only push to userIds you captured from a real webhook event — you can't guess them