Bird
Email, SMS and WhatsApp via Bird
Bird notifications for Medusa
Send email, SMS, and WhatsApp notifications from your Medusa v2 application with Bird. This notification provider runs in your Medusa server and uses your workspace's Bird API key. It supports Medusa 2.21.2 and later v2 releases.
Install and configure
Install the Bird notification provider from npm:
1npm install @messagebird/bird-plugin-medusa
Set your Bird credentials in your hosting platform's environment settings. For local development, add them to Copy to clipboard.env and keep that file out of version control:
123BIRD_API_KEY=your_bird_access_keyBIRD_EMAIL_FROM=notifications@example.comBIRD_SMS_FROM=YourShop
Set Copy to clipboardBIRD_WHATSAPP_FROM to your connected WhatsApp number when sending from it. Omit sender variables for channels you do not use.
Add the provider to the Notification Module in your existing Copy to clipboardmedusa-config.ts. Keep its other application settings and environment loading:
1234567891011121314151617181920import { defineConfig, loadEnv } from "@medusajs/framework/utils";loadEnv(process.env.NODE_ENV || "development", process.cwd());module.exports = defineConfig({modules: [{resolve: "@medusajs/medusa/notification",options: {providers: [{resolve: "@medusajs/medusa/notification-local",id: "local",options: { channels: ["feed"] },},{resolve: "@messagebird/bird-plugin-medusa/providers/bird",id: "bird",options: {channels: ["email", "sms", "whatsapp"],
Keep the local Copy to clipboardfeed provider for Medusa admin notifications such as product and order exports. Configuring Copy to clipboardproviders replaces Medusa's default provider list. Medusa routes each channel to one provider: remove a channel from an existing provider before assigning it to Bird. Register this package in the Notification Module; it needs no entry in Copy to clipboardplugins.
Restart or redeploy Medusa after changing the configuration. On Medusa Cloud, enable the Build flag for the environment variables used here. Credentials and defaults are server configuration; this package adds no admin settings page or OAuth connection form.
Create an API key in your Bird workspace with send permissions for the channels you enable: Copy to clipboardemails:write, Copy to clipboardsms:write, and Copy to clipboardwhatsapp:write. Keep it in server environment variables. The provider derives the API region from the key; no workspace ID or region setting is needed. Use a Copy to clipboardbk_<region>_… API key. Short-lived OAuth tokens (Copy to clipboardbt_…) are not supported.
Use a verified email domain for Copy to clipboardBIRD_EMAIL_FROM and a configured SMS sender for Copy to clipboardBIRD_SMS_FROM. Configure only the channels you use. A notification's Copy to clipboardfrom overrides its channel's default sender. For WhatsApp, use a connected number as Copy to clipboardBIRD_WHATSAPP_FROM. For built-in SMS and WhatsApp templates, use their Copy to clipboardbird_… slug and omit Copy to clipboardnotification.from; the provider skips the configured default sender. When referring to a built-in template by ID instead, use a provider configuration without that channel's default sender.
Send an order notification
Create and publish an email template with the slug Copy to clipboardorder-confirmation in Bird, including an Copy to clipboardorder_id variable. Add Copy to clipboardsrc/subscribers/order-placed.ts:
1234567891011121314151617181920import type { SubscriberArgs, SubscriberConfig } from "@medusajs/framework";import { Modules } from "@medusajs/framework/utils";type OrderEvent = SubscriberArgs<{ id: string }>;export default async function orderPlaced(args: OrderEvent) {const container = args.container;const data = args.event.data;const order = await container.resolve(Modules.ORDER).retrieveOrder(data.id);if (!order.email) return;await container.resolve(Modules.NOTIFICATION).createNotifications({to: order.email,channel: "email",template: "order-confirmation",data: { order_id: order.display_id },idempotency_key: `order-confirmation/${order.id}`,provider_data: { idempotency_key: `order-confirmation/${order.id}` },});}
Copy to clipboardtemplate accepts a Bird email template ID (Copy to clipboardemt_…) or SMS template ID (Copy to clipboardsmt_…), or a published template slug. For email and SMS, Copy to clipboarddata becomes the template's Copy to clipboardparameters. Pass Copy to clipboardprovider_data.language when the template requires a language.
Send SMS through the same Notification Module:
123456await notificationModuleService.createNotifications({to: "+31612345678",channel: "sms",template: "order-shipped",data: { order_id: "123", tracking_url: "https://shop.example/track/123" },});
Create and publish Copy to clipboardorder-shipped as an SMS template first. Its category comes from the template; do not pass Copy to clipboardprovider_data.category for SMS template sends.
WhatsApp uses Copy to clipboardchannel: "whatsapp" and accepts approved template IDs (Copy to clipboardwat_…) or slugs. Pass template components in Copy to clipboarddata.components. See WhatsApp templates and text for examples and sender requirements.
Inline content and provider options
When Copy to clipboardcontent is present, it takes precedence over Copy to clipboardtemplate. Medusa still requires a Copy to clipboardtemplate string; use a descriptive label such as Copy to clipboardorder-receipt. Email requires Copy to clipboardcontent.subject and Copy to clipboardcontent.html or Copy to clipboardcontent.text. SMS and WhatsApp accept only Copy to clipboardcontent.text. Inline email and SMS messages default to Copy to clipboardtransactional; use Copy to clipboardprovider_data.category: "marketing" for marketing content.
Email Copy to clipboarddata maps to Bird's inline Liquid parameters. Render SMS and WhatsApp text in your app or use a stored template; their inline text does not interpolate Copy to clipboarddata. WhatsApp text requires an open customer service window.
Supported Copy to clipboardprovider_data fields:
- Copy to clipboard
language: Stored template language tag, such as Copy to clipboardnl. - Copy to clipboard
category: Email accepts Copy to clipboardtransactionalor Copy to clipboardmarketing; inline SMS also accepts Copy to clipboardauthenticationor Copy to clipboardservice. - Copy to clipboard
cc, Copy to clipboardbcc, Copy to clipboardreply_to: Email address arrays. - Copy to clipboard
preview_url: Boolean for inline WhatsApp link previews, disabled by default. - Copy to clipboard
idempotency_key: Stable key for retries of the same message, at most 255 characters.
Medusa email attachments map to Bird attachments without re-encoding their base64 Copy to clipboardcontent. For an inline image, set Copy to clipboarddisposition: "inline" and Copy to clipboardid, then reference Copy to clipboardcid:<id> in the HTML. SMS and WhatsApp notifications do not accept Medusa attachments; WhatsApp template media belongs in Copy to clipboarddata.components.
The returned ID confirms API acceptance. Delivery is asynchronous; use Bird's message APIs or webhooks to track the outcome. Medusa's notification success state does not confirm delivery to an inbox or handset.
The provider makes one request with a 30-second timeout. It does not retry an uncertain send. Medusa's notification idempotency key is separate from Bird's; set Copy to clipboardprovider_data.idempotency_key too when retrying. Bird retains responses for three hours by default, with the limits described in the API reference.
Develop
Run Copy to clipboardpnpm lint, Copy to clipboardpnpm test, and Copy to clipboardpnpm build in this package. Lint uses Medusa's module-provider ESLint preset and checks TypeScript types. Tests mock Bird's HTTP responses and send no messages. Run Copy to clipboardpnpm test:integration for the real Medusa Notification Module and PostgreSQL checks; see integration test prerequisites and database cleanup. Copy to clipboardnpm pack creates an installable package for testing in a Medusa application before publication; integration tests are included in source mirrors and excluded from npm packages.
Source changes live in the Bird monorepo. The release repository is a mirror; versions and releases follow Bird's surface release process. Publishing and Medusa catalog visibility are separate steps. This package includes Medusa's documented notification integration discovery keywords.
