Send multichannel notifications in Medusa
A flexible notification plugin for MedusaJS using Apprise, enabling multichannel notifications with ease.
Install the package using npm:
npm install @vymalo/medusa-appriseOr using yarn:
yarn add @vymalo/medusa-appriseAdd the plugin to the section of your MedusaJS configuration:
1modules: [2 {3 resolve: "@medusajs/medusa/notification",4 options: {5 providers: [6 {7 resolve: `@vymalo/medusa-apprise`,8 id: "apprise",9 options: {10 client: {11 baseURL: 'http://localhost:8000/notify', // Apprise API service URL12 headers: {13 "Content-Type": "application/json"14 }15 },16 handlers: {17 email: (notification: ProviderSendNotificationDTO) => [18 {19 urls: [20 `mailgun:///noreply@example.com/4b4f2918fd-dk5f-8f91f/${notification.to}`,21 `ses://test@test.com/<access-key>/<secret-key>/<aws-region>/admin@email.com`,22 ],23 body: `[${notification.template}] ${JSON.stringify(notification.data, null, 4)}`24 }25 ],26 // More channel handlers...27 },28 },29 },30 ],31 },32 },33 // Other modules...34]The option uses axios configuration, allowing full customization of the HTTP client.
Define custom handlers for different notification channels:
1type AppriseNotificationPayload = {2 urls: string[]; // Notification destination URLs3 body: string; // Notification body4 title?: string; // Optional notification title5 type?: 'info' | 'warning' | 'failure'; // Notification type6 format?: 'text' | 'markdown' | 'html'; // Notification format7 tag?: string; // Optional tag for notification8}Contributions are welcome! Please feel free to submit a Pull Request.