Frequently Asked Questions
Implement a webhook callback function in your RedwoodJS API. This function will receive real-time delivery updates from Infobip, allowing you to monitor message status, handle errors, and improve user experience by providing feedback or taking alternative actions.
Infobip webhooks provide real-time updates on the status of your sent SMS messages. This moves beyond "fire and forget" messaging, giving you insights into delivery success, failures, and pending statuses, so your application can react accordingly.
Webhook verification is crucial for security. It confirms that incoming requests genuinely originate from Infobip, preventing unauthorized access or malicious data manipulation by verifying signatures using a shared secret.
Ideally, create the MessageLog
record with a status like PENDING
when the SMS is initially sent via the Infobip API. The webhook handler then updates this record based on the delivery report. The handler uses upsert
to create a record if one doesn't already exist, but it's best practice to create initially.
The endpoint is typically /api/infobipWebhook
for a RedwoodJS function named infobipWebhook
. This path might vary slightly depending on the deployment platform (e.g., Netlify uses /.netlify/functions/infobipWebhook
), but it's always a POST request.
Use the verifyEvent
function from @redwoodjs/api/webhooks
. Provide the correct verifierType
('secretKeyVerifier' or an HMAC verifier), the shared secret from your .env
file, and specify the signatureHeader
used by Infobip.
Log into your Infobip account and navigate to the Webhook or Callback settings (often under API or DLR settings). Configure the URL of your RedwoodJS endpoint (public and HTTPS), and set the authentication method (e.g., HTTP Header Authentication or HMAC) and secret, ensuring these match your application's setup.
Verification failures (401 Unauthorized errors) usually indicate an issue with the shared secret or the HTTP headers used for verification. Double-check that the INFOBIP_WEBHOOK_SECRET
in your app's environment precisely matches the one configured in your Infobip account, and that the header names (signatureHeader
) align.
If Infobip webhooks are not working, verify the following: correct endpoint URL, delivery reports enabled in Infobip, proper setup of webhook security (secret, signature method), and log files from both Infobip and your application for clues about the issue. Check Infobip's documentation to confirm their webhook configuration options and payload format.
Define a MessageLog
model in your Prisma schema with fields for messageId
, status
, error codes, descriptions, timestamps, etc. Create a RedwoodJS service with an updateMessageStatus
function that uses Prisma to upsert records based on the messageId
received in the webhook payload.
Deploy your application or use ngrok to expose it publicly. Send test SMS messages through Infobip and observe the logs to verify the webhook function is correctly receiving, verifying, and processing data. Confirm that the database is updating correctly and that your error handling is working.
Yes, ngrok creates a public HTTPS URL for your local development environment, enabling you to test webhooks from Infobip during development before deploying your application.
A 400 Bad Request error usually indicates a problem parsing the incoming JSON payload from Infobip. Double-check Infobip's documentation for the expected structure and ensure your parsing logic extracts data correctly. Log the raw body carefully (in development) to understand the payload format.
Use webhook signature verification (@redwoodjs/api/webhooks
), always use HTTPS, validate incoming payload structure, and securely store the shared secret (INFOBIP_WEBHOOK_SECRET
) in environment variables, never hardcoding it. Rate limiting can be an additional layer of security, preventing abuse.
Content Loading Error
We encountered an error while processing this content.