Action Mailbox: broadcast incoming emails into a feed

9928
0

For apps that ingest emails (support inbox, replies), Action Mailbox is a natural fit. When a message arrives, I create a record and broadcast it into a Turbo Stream feed so the UI updates in realtime. This is essentially “email as an event source”. The mailbox extracts metadata (from, subject, body), persists it, and then broadcasts a prepend to the appropriate stream (scoped to the account/team). The UI subscribes with turbo_stream_from and renders the message partial. The benefit is that operators can watch incoming mail live without polling. The key considerations are deduplication (Message-ID), security (only authorized users subscribe), and sanitization (render email body safely). Hotwire keeps it simple: rendered partials, no bespoke websocket protocol.