Send transactional email and SMS via Sweego from Convex with durable workpool delivery, per-recipient webhook tracking, and HMAC-verified events.
npm install @christian-ek/sweegoSweego is a Convex component that sends transactional email and SMS through the Sweego REST API with durable background delivery via a workpool. It handles automatic retries on transient failures (429s, 5xx), records permanent failures without retrying, and maintains per-recipient delivery state updated through HMAC-SHA256 verified webhooks. The component covers the full Sweego send surface: templates, attachments, bulk personalized email, custom headers, and campaign metadata.
The Sweego Convex component enqueues email sends via a workpool and retries automatically on transient failures. Call sweego.sendEmail(ctx, { from, to, subject, text }) from any mutation or action and the component handles durable delivery in the background, returning a MessageId immediately.
Mount sweego.handleSweegoWebhook in convex/http.ts, register the URL in the Sweego dashboard, and set SWEEGO_WEBHOOK_SECRET. The component verifies Sweego's HMAC-SHA256 signatures and updates per-recipient delivery state. Register an onEvent mutation to react to events like delivered, hard_bounce, or email_opened.
The Sweego component exposes sweego.sendSms(ctx, { to, region, campaignType, text }) for transactional or marketing SMS. Recipients can be bare strings with a top-level region or structured objects with per-recipient region. You can also call sweego.estimateSms from an action to get cost and segment estimates before sending.
Use sweego.sendBulkEmail(ctx, { from, subject, templateId, recipients }) where each recipient object carries its own variables map for template interpolation. Bulk sends require at least two recipients and call Sweego's /send/bulk/email endpoint; cc, bcc, and replyTo are not supported on bulk sends.
No. The Sweego Convex component calls the Sweego REST API directly using fetch and verifies HMAC-SHA256 webhook signatures with the Web Crypto API. There is no dependency on the Sweego SDK or the Svix webhook library.
The Sweego component runs sends through a Convex workpool and retries automatically on 429 and 5xx responses. Permanent 4xx failures are recorded without further retries. You can configure retryAttempts and initialBackoffMs when constructing the Sweego instance.
sweego.sendEmail and sweego.sendSms return a MessageId. Pass it to sweego.status(ctx, messageId) to get the send status, transaction ID, credit balance, and an array of per-recipient delivery records. If webhooks are not yet configured, sweego.refreshStatus(ctx, messageId) can be called from an action to poll Sweego's logs directly.
Yes. Pass templateId and a variables object to sweego.sendEmail for single-recipient sends. For per-recipient personalization across multiple recipients, use sweego.sendBulkEmail where each entry in the recipients array carries its own variables map. You cannot combine templateId with html on a single send.
The Sweego component exposes two built-in mutations: components.sweego.lib.cleanupOldMessages removes finalized messages older than a given cutoff, and components.sweego.lib.cleanupAbandonedMessages removes messages that never finalized. Schedule both as Convex cron jobs, typically hourly, to control storage growth.