Frequently Asked Questions
You can schedule SMS messages by sending a POST request to the /sms/2/bulks endpoint of your Fastify application. This request should include the recipient's phone number, the message text, the desired send time (in ISO 8601 format), and optionally a sender ID. The application will then interact with the Infobip API to schedule the message.
Prisma acts as an Object-Relational Mapper (ORM), simplifying database interactions. It is used to define the database schema, manage migrations, and execute type-safe queries. In this project, Prisma interacts with an SQLite database to store metadata about scheduled SMS jobs, but it's compatible with other databases like PostgreSQL and MySQL as well.
Fastify is a high-performance Node.js web framework known for its speed, extensibility, and developer-friendly features. It offers built-in validation, logging, and a plugin-based architecture, making it a suitable choice for building robust and efficient backend services like this SMS scheduler.
A unique bulk ID, generated using the uuid library, should be created client-side before making the API call to Infobip to schedule a message. This bulkId helps to track and manage the scheduled message within your system and correlate it with Infobip's responses.
Create a .env file in the project's root directory. Store sensitive information like the Infobip API key and base URL, database URL, and port number. Use the @fastify/env module along with a schema defined in src/config/environment.js for secure loading and validation.
You can retrieve the status of a scheduled message by sending a GET request to the /sms/2/bulks/status endpoint with the bulkId as a query parameter. The response from the Infobip API, routed through your Fastify app, will indicate whether the message is pending, canceled, or sent.
The ScheduledSmsJob model, managed via Prisma, stores key information about scheduled SMS jobs: a unique internal id, the Infobip bulkId, current status, scheduledAt timestamp, recipient phone number, message content, and timestamps for creation and updates.
While optional, Sentry integration is recommended for production applications. Include your Sentry DSN in the .env file and configure Sentry within your Fastify application to automatically capture and report errors, enhancing monitoring and debugging capabilities.
The system follows a client-server architecture where a client (e.g., UI or Postman) interacts with a Fastify backend application. The backend communicates with an Infobip API for sending and scheduling SMS messages and a database (SQLite) for storing scheduling metadata.
Yes, you can reschedule SMS messages through a PUT request to the /sms/2/bulks endpoint. Supply the bulkId and the new desired send time (sendAt in ISO 8601 format) in the request body.
The databaseService.js file contains functions for interacting with the database. These functions, built upon Prisma, allow you to save job details, retrieve jobs by their bulkId, and update job status information.
You need Node.js (v18 or later is recommended), npm or yarn, an active Infobip account (signup is available online), basic understanding of JavaScript and RESTful APIs, a code editor, and optionally, Docker and Postman or cURL for testing.
Axios is a promise-based HTTP client used for making API requests to the Infobip platform from your Node.js application. It simplifies the process of sending HTTP requests and handling responses within the project.
Pino is the high-performance logger employed within this project. It automatically formats logs in JSON for improved analysis and debugging. For human-readable logs during development, Pino Pretty can be used through npm scripts.
Content Loading Error
We encountered an error while processing this content.