Frequently Asked Questions
Use the Infobip Node.js SDK and the `/api/send-sms` endpoint. Send a POST request to this endpoint with a JSON body containing the recipient's number (`to`) and the message text (`text`). The server uses your configured Infobip credentials to send the SMS.
The @infobip-api/sdk is Infobip's official Node.js library, simplifying interaction with the Infobip API. It handles authentication and provides methods for sending SMS messages and other communication services.
Socket.IO enables real-time, bidirectional communication between the server and the frontend. It allows the server to push updates about sent and received messages instantly to the user interface, creating a dynamic chat-like experience without constant polling.
ngrok is recommended for local development to expose your local server to the internet, allowing Infobip to send webhooks to your development machine. In production, replace the ngrok URL with your application's public URL.
Yes, you can use yarn. The instructions use npm, but yarn is a compatible package manager. After creating the project, use yarn commands (like `yarn add`, `yarn dev`) instead of their npm equivalents.
Set up a webhook endpoint (`/webhooks/infobip` in this project) and configure this URL in your Infobip number settings. When someone replies to your Infobip number, Infobip will send the message data as a POST request to your webhook, which then pushes the message to the frontend via Socket.IO.
The project uses a monorepo structure with `backend` and `frontend` directories at the root. The backend contains the Node.js/Express server code, while the frontend contains the Vite/React application.
Cross-Origin Resource Sharing (CORS) is essential for the frontend (running on a potentially different port) to communicate with the backend API. The `cors` middleware enables this communication by specifying allowed origins.
Use ngrok to expose your local server, then paste the HTTPS ngrok forwarding URL followed by `/webhooks/infobip` into the webhook settings in your Infobip number configuration.
The `.env` file stores sensitive configuration data, like your Infobip API Key, Base URL, and sender number. This approach keeps secrets out of version control.
Basic security can be added with a shared secret header. For stronger security in production, use IP whitelisting and consider Infobip's signature verification methods if available. Do not rely solely on the obscurity of the webhook URL.
A `messages` table could include columns for sender, recipient, message content, direction (inbound/outbound), Infobip status/DLR information, and timestamps. Indexing is crucial for efficient queries. Consider using a trigger to automatically update timestamps.
Error handling is essential for robustness. It includes validation of inputs, managing potential Infobip API errors, logging important events, and handling invalid or incomplete data. This enables appropriate responses and debugging.
Infobip's SDK handles long SMS messages by automatically splitting them into multiple parts. Be aware of the higher credit cost for these concatenated SMS, and ensure the UI provides visibility if needed.
Content Loading Error
We encountered an error while processing this content.