Send SMS with optional test mode for safe messaging
A notification provider plugin that enables SMS notifications via SMSAPI.com and service for Medusa v2 projects.
1npm install @yanchesky/medusa-smsapi2# or3yarn add @yanchesky/medusa-smsapiCreate or update your file:
1SMSAPI_ACCESS_TOKEN=your_smsapi_access_token_here2SMSAPI_FROM=YourBrandAdd the plugin to your :
1import { SMSAPIOptions } from '@yanchesky/medusa-smsapi';2// ...3module.exports = {4 // ... other configurations5 modules: [6 // ... other modules7 {8 resolve: '@yanchesky/medusa-smsapi/providers/smsapi',9 dependencies: ['logger'] // Optional in test mode to log sent messages10 options: {11 channels: ['sms'], // Required: notification channels12 access_token: process.env.SMSAPI_ACCESS_TOKEN,13 from: process.env.SMSAPI_FROM,14 } satisfies SMSAPIOptions,15 },16 ],17}1import { Modules } from '@medusajs/framework/utils';2// ...3const notificationService = container.resolve(Modules.NOTIFICATION);4await notificationService.createNotifications([{5 channel: 'sms',6 to: '48123456789', // Country prefix is required7 template: 'confrimation' // This is required by Medusa but is not used by the plugin. 8 content: {9 text: "An SMS message"10 }11}])1interface SMSAPIOptions {2 // Required3 access_token: string // Your SMSAPI access token4 from: string // Sender name verified by SMSAPI5 channels: string[] // Notification channels6
7 // Optional Basic Settings8 encoding?: string // Message encoding (default: "UTF-8")9 test?: boolean // Test mode (default: false)10 api_url?: string // API endpoint (default: "https://smsapi.io/api")11
12 // Optional Advanced Settings13 flash?: boolean // Flash SMS (default: false)14 max_parts?: 1-10 // Maximum number of parts a message can be split into15 nounicode?: boolean // Prevents from sending messages containing special characters.16 normalize?: boolean // Converts special characters to regular ones. ę -> e; ć -> c17 fast?: boolean // Send SMS with the highest priority (default: false)18}Enable test mode to validate your setup without sending actual SMS. In test mode a request to API endpoint will be executed validating credentials and logging sent message.
1# Run type checking2yarn typecheck3# Run linting4yarn lint5# Format code6yarn format7# Build plugin8yarn buildAll contributions are welcome! Please follow these steps:
MIT License