TL;DR — Executive Summary
Learn how to write resilient Node.js code to handle automated transactional messaging failovers, ensuring 100% delivery rates in Brazil.
For critical transactions, your application backend must be designed to route alternative messaging channels if the subscriber's phone is offline.
---
Node.js Implementation Example
Below is a Node.js workflow executing a primary WhatsApp alert, with a dynamic fallback to SMS A2P if the delivery fails:
javascript const axios = require('axios');
async function sendTransactionalAlert(userId, phoneNumber, messageText) { const apiKey = 'bsms_live_key_99001122'; try { const response = await axios.post('https://api.bulksms.com.br/v1/whatsapp/send', { to: phoneNumber, message: messageText }, { headers: { 'Authorization': Bearer ${apiKey} } });
if (response.data.status !== 'delivered') { throw new Error('WhatsApp delivery failed'); } } catch (error) { console.log('WhatsApp failed. Triggering SMS Fallback...'); await axios.post('https://api.bulksms.com.br/v1/sms/send', { to: phoneNumber, message: messageText, sender: '28555' }, { headers: { 'Authorization': Bearer ${apiKey} } }); } }
Explore APIs endpoints on Verify APIs and examine current rates on Pricing.
Camila Rodrigues
CTO, Bulk SMS
Senior specialist in mobile telecommunications infrastructure, high-performance enterprise messaging, and LGPD compliance for smart communication platforms and APIs in Brazil.