Frequently Asked Questions
Use the Infobip Node.js SDK within a Fastify application. Create a service to handle Infobip interactions, a controller to manage requests and responses, and a route to expose the functionality via an API endpoint like '/send-sms'. This structure promotes modularity and maintainability.
Fastify is a high-performance Node.js web framework chosen for its speed and plugin architecture. It handles routing, request handling, input validation (using JSON Schema), and provides a structure for building scalable API endpoints.
Dotenv loads environment variables from a '.env' file, separating configuration from code. This enhances security by keeping API keys out of version control and simplifies managing settings across different environments (development, production).
10DLC registration is required for sending Application-to-Person (A2P) SMS to US numbers using standard 10-digit long codes. Register your brand and campaigns with The Campaign Registry (TCR) through Infobip to comply with US regulations and avoid message filtering.
Yes, you can use an Alphanumeric Sender ID (your brand name) but it requires configuration within your Infobip account and might need registration, depending on the country. Use the optional 'senderId' parameter when sending messages, adhering to local regulations.
Pino-pretty is a development dependency used to format Fastify's default JSON logs into a more human-readable form during development. It simplifies debugging and monitoring during the development process.
Implement try...catch blocks in both the service and controller layers. Log errors with context using 'request.log' in the controller, including any Infobip-specific error details. Return appropriate HTTP status codes (like 500) and generic error messages to the client.
You'll need an Infobip account (free or paid), your Infobip API Key and Base URL, Node.js and npm installed, and a basic understanding of JavaScript, Node.js, REST APIs, and terminal commands. For US traffic, 10DLC registration is often recommended.
A client (web app, CLI) sends requests to the Fastify API server. The server interacts with the Infobip API to send SMS messages. The server includes routes, controllers, services, configuration, and logging components.
A functional Fastify API endpoint ('/send-sms') that can accept a destination phone number and message content, send the SMS through Infobip, and return the status of the message delivery attempt.
Infobip automatically handles splitting long messages into multiple segments (concatenated SMS). Be aware of per-segment costs. Standard SMS allows 160 characters; using non-standard characters reduces this to 70 per segment.
Store the API key in a '.env' file locally (included in '.gitignore') and use secure secret management solutions (like AWS Secrets Manager or HashiCorp Vault) in production. Never hardcode API keys in your source code.
The Infobip Node.js SDK simplifies interacting with the Infobip API. It streamlines authentication, request formatting, and response handling compared to making raw HTTP calls, making development more efficient.
Infobip can manage standard opt-out keywords (like STOP) automatically with proper configuration. Your application should also respect opt-outs recorded in your database and avoid sending to unsubscribed numbers, ensuring compliance with regulations like TCPA.
The '/health' endpoint allows monitoring tools and load balancers to check if the server is running and responding. It returns a simple JSON response like '{ "status": "ok" }' to confirm server health.
Content Loading Error
We encountered an error while processing this content.