Reducing SMS Costs with WhatsApp Business API: A Guide for E-commerce
Fintech

Reducing SMS Costs with WhatsApp Business API: A Guide for E-commerce

Ihor (Harry) ChyshkalaIhor (Harry) Chyshkala

The SMS Cost Problem for E-commerce

E-commerce businesses send millions of transactional messages every month: order confirmations, shipping notifications, delivery updates, and customer service responses. With SMS costs typically ranging from $0.01 to $0.05 per message depending on the destination country, these expenses can quickly add up to thousands of dollars monthly.

For a mid-sized e-commerce store processing 10,000 orders per month, sending an average of 4 SMS notifications per order (confirmation, shipped, out for delivery, delivered) results in 40,000 messages monthly. At $0.02 per SMS, that's $800 per month or $9,600 annually just for basic notifications.

WhatsApp Business API: A Cost-Effective Alternative

WhatsApp Business API offers significantly lower costs for transactional messages, with some types of notifications being completely free. The pricing structure is based on conversation windows rather than per-message, making it dramatically more cost-effective for businesses that send multiple messages to the same customer.

Key advantages over SMS:

• **Lower cost per conversation** (often 50-90% cheaper than SMS)
• **Free utility conversations** for certain message types
• **Rich media support** including images, PDFs, and interactive buttons
• **Higher open rates** (98% vs 20% for SMS)
• **Two-way conversations** without additional costs
• **Read receipts** and delivery confirmations

Understanding WhatsApp Pricing for Business

WhatsApp Business API uses a conversation-based pricing model with four conversation categories:

**1. Utility Conversations** (FREE in many regions): Authentication, order updates, payment updates, shipping notifications

**2. Service Conversations** (Low cost): Customer service responses within 24 hours of customer initiation

**3. Marketing Conversations** (Standard pricing): Promotional offers, abandoned cart reminders

**4. Authentication Conversations** (Lowest cost): One-time passwords, verification codes

A 24-hour conversation window allows multiple messages to be sent for the same price as one, making it ideal for order tracking with multiple updates.

Setting Up WhatsApp Business API with Twilio

Twilio provides one of the easiest ways to integrate WhatsApp Business API into your application. Here's how to get started:

1. Enable WhatsApp in your Twilio console
2. Connect your Facebook Business Manager account
3. Get approved for WhatsApp Business API
4. Create message templates for approval
5. Integrate the API into your application

npm install twilio

Creating Message Templates

Unlike SMS, WhatsApp requires pre-approved message templates for business-initiated conversations. Templates must be created in the Twilio console and approved by WhatsApp before use:

Example template for order confirmation:

Template Name: order_confirmation
Category: UTILITY
Language: English

Body:
Your order #{{1}} has been confirmed! 🎉

Order Total: {{2}}
Estimated Delivery: {{3}}

Track your order: {{4}}

Thank you for shopping with us!

Variables (like {{1}}) are placeholders that you'll fill with actual values when sending messages.

Implementation: Order Confirmation

Here's how to send a WhatsApp order confirmation using Twilio:

whatsapp-notifications.js
const twilio = require('twilio');

const accountSid = process.env.TWILIO_ACCOUNT_SID;
const authToken = process.env.TWILIO_AUTH_TOKEN;
const client = twilio(accountSid, authToken);

async function sendOrderConfirmation(order) {
  try {
    const message = await client.messages.create({
      from: 'whatsapp:+14155238886', // Your Twilio WhatsApp number
      to: `whatsapp:${order.customerPhone}`,
      body: `Your order #${order.id} has been confirmed! 🎉

Order Total: $${order.total}
Estimated Delivery: ${order.estimatedDelivery}

Track your order: ${order.trackingUrl}

Thank you for shopping with us!`
    });

    console.log('WhatsApp message sent:', message.sid);
    return { success: true, messageSid: message.sid };
  } catch (error) {
    console.error('Error sending WhatsApp message:', error);

    // Fallback to SMS if WhatsApp fails
    return await sendSMSFallback(order);
  }
}

// Fallback to SMS if customer doesn't have WhatsApp
async function sendSMSFallback(order) {
  const message = await client.messages.create({
    from: process.env.TWILIO_PHONE_NUMBER,
    to: order.customerPhone,
    body: `Your order #${order.id} has been confirmed! Track: ${order.trackingUrl}`
  });

  return { success: true, messageSid: message.sid, channel: 'sms' };
}

Using Approved Templates with Content API

For production use, you must use approved templates. Here's how to send using a template:

template-message.js
async function sendTemplatedOrderConfirmation(order) {
  try {
    const message = await client.messages.create({
      from: 'whatsapp:+14155238886',
      to: `whatsapp:${order.customerPhone}`,
      contentSid: 'HX...', // Your approved template SID
      contentVariables: JSON.stringify({
        1: order.id,
        2: `$${order.total}`,
        3: order.estimatedDelivery,
        4: order.trackingUrl
      })
    });

    return { success: true, messageSid: message.sid };
  } catch (error) {
    console.error('Error sending template message:', error);
    throw error;
  }
}

Complete E-commerce Notification System

Here's a complete notification service that handles different order stages:

notification-service.js
class WhatsAppNotificationService {
  constructor(twilioClient) {
    this.client = twilioClient;
    this.whatsappNumber = process.env.TWILIO_WHATSAPP_NUMBER;
  }

  async sendOrderConfirmation(order) {
    return this.sendMessage(order.customerPhone, {
      type: 'order_confirmation',
      params: [order.id, order.total, order.estimatedDelivery, order.trackingUrl]
    });
  }

  async sendShippingUpdate(order, trackingNumber) {
    return this.sendMessage(order.customerPhone, {
      type: 'order_shipped',
      params: [order.id, trackingNumber, order.carrier, order.estimatedDelivery]
    });
  }

  async sendOutForDelivery(order) {
    return this.sendMessage(order.customerPhone, {
      type: 'out_for_delivery',
      params: [order.id, order.estimatedDeliveryTime]
    });
  }

  async sendDelivered(order) {
    return this.sendMessage(order.customerPhone, {
      type: 'delivered',
      params: [order.id]
    });
  }

  async sendMessage(phoneNumber, messageConfig) {
    const templates = {
      order_confirmation: 'HXxxxxx',
      order_shipped: 'HXxxxxx',
      out_for_delivery: 'HXxxxxx',
      delivered: 'HXxxxxx'
    };

    try {
      const message = await this.client.messages.create({
        from: `whatsapp:${this.whatsappNumber}`,
        to: `whatsapp:${phoneNumber}`,
        contentSid: templates[messageConfig.type],
        contentVariables: JSON.stringify(
          Object.fromEntries(
            messageConfig.params.map((param, i) => [i + 1, param])
          )
        )
      });

      // Log successful delivery
      await this.logNotification({
        phoneNumber,
        type: messageConfig.type,
        messageSid: message.sid,
        channel: 'whatsapp',
        status: 'sent'
      });

      return { success: true, messageSid: message.sid };
    } catch (error) {
      console.error(`WhatsApp message failed for ${messageConfig.type}:`, error);

      // Fallback to SMS
      return this.sendSMSFallback(phoneNumber, messageConfig);
    }
  }

  async sendSMSFallback(phoneNumber, messageConfig) {
    // Implement SMS fallback logic
    console.log('Falling back to SMS for:', messageConfig.type);
    // ... SMS implementation
  }

  async logNotification(details) {
    // Log to database for analytics
    console.log('Notification logged:', details);
  }
}

module.exports = WhatsAppNotificationService;

Integration with Order Management System

Integrate the notification service into your order processing workflow:

order-webhooks.js
const WhatsAppNotificationService = require('./notification-service');
const twilioClient = require('twilio')(
  process.env.TWILIO_ACCOUNT_SID,
  process.env.TWILIO_AUTH_TOKEN
);

const notificationService = new WhatsAppNotificationService(twilioClient);

// Example: Order confirmation webhook
app.post('/webhooks/order-created', async (req, res) => {
  const order = req.body;

  try {
    // Send WhatsApp confirmation
    await notificationService.sendOrderConfirmation(order);

    res.json({ success: true });
  } catch (error) {
    console.error('Failed to send notification:', error);
    res.status(500).json({ error: 'Notification failed' });
  }
});

// Example: Shipping webhook
app.post('/webhooks/order-shipped', async (req, res) => {
  const { order, trackingNumber } = req.body;

  try {
    await notificationService.sendShippingUpdate(order, trackingNumber);
    res.json({ success: true });
  } catch (error) {
    console.error('Failed to send shipping update:', error);
    res.status(500).json({ error: 'Notification failed' });
  }
});

Cost Comparison: SMS vs WhatsApp

Let's compare the real costs for a typical e-commerce scenario:

**Scenario**: 10,000 orders/month with 4 notifications per order (40,000 messages)

**SMS Costs**:
• 40,000 messages × $0.02 = $800/month
• Annual cost: $9,600

**WhatsApp Costs**:
• 10,000 utility conversations × $0 = $0/month (utility messages are free)
• If using service conversations: 10,000 × $0.005 = $50/month
• Annual cost: $0-$600 (depending on message type)

**Savings**: $9,000 - $9,600 annually (90-94% reduction)

For larger operations processing 100,000 orders monthly, the savings exceed $90,000 per year.

Additional Benefits Beyond Cost Savings

WhatsApp offers features that improve customer experience:

**Rich Media**: Send images of packed orders, PDF invoices, or product images

// Send order confirmation with invoice PDF
await client.messages.create({
  from: 'whatsapp:+14155238886',
  to: `whatsapp:${customerPhone}`,
  body: 'Your order has been confirmed!',
  mediaUrl: [order.invoicePdfUrl]
});

**Interactive Buttons**: Allow customers to track orders or contact support with one tap

**Two-way Conversations**: Customers can reply to ask questions without additional charges

**Higher Engagement**: 98% of WhatsApp messages are opened within minutes vs 20% open rate for SMS

Best Practices for E-commerce

To maximize the benefits of WhatsApp Business API:

1. **Always maintain SMS fallback** for customers without WhatsApp
2. **Get opt-in** before sending WhatsApp messages (required by WhatsApp policies)
3. **Use utility templates** for transactional messages to get free conversations
4. **Consolidate messages** within 24-hour windows when possible
5. **Monitor delivery rates** and fallback patterns
6. **Respect customer preferences** and provide easy opt-out

Handling Opt-in and Opt-out

opt-in-management.js
// Store customer communication preferences
const customerPreferences = {
  async setWhatsAppOptIn(customerId, phoneNumber) {
    await db.customers.update(customerId, {
      whatsappOptIn: true,
      whatsappNumber: phoneNumber,
      optInDate: new Date()
    });
  },

  async checkWhatsAppOptIn(customerId) {
    const customer = await db.customers.findById(customerId);
    return customer.whatsappOptIn === true;
  },

  async optOut(customerId) {
    await db.customers.update(customerId, {
      whatsappOptIn: false,
      optOutDate: new Date()
    });
  }
};

// Check preferences before sending
async function sendNotification(order) {
  const hasWhatsAppOptIn = await customerPreferences.checkWhatsAppOptIn(order.customerId);

  if (hasWhatsAppOptIn) {
    return notificationService.sendMessage(order.customerPhone, messageConfig);
  } else {
    return notificationService.sendSMSFallback(order.customerPhone, messageConfig);
  }
}

Monitoring and Analytics

Track key metrics to optimize your notification strategy:

• Delivery rate by channel (WhatsApp vs SMS)
• Open and read rates
• Response rates to messages
• Cost per notification by channel
• Fallback frequency (WhatsApp → SMS)

Switching from SMS to WhatsApp Business API for transactional messages can reduce notification costs by 90% or more while simultaneously improving customer engagement and satisfaction. With features like rich media, interactive buttons, and two-way conversations, WhatsApp provides a superior customer experience compared to traditional SMS.

For e-commerce businesses sending thousands of notifications monthly, the cost savings alone make WhatsApp Business API a compelling choice. When combined with higher engagement rates and better customer experience, it becomes an essential tool for modern online retail operations.

By implementing a robust notification system with proper opt-in management and SMS fallback, you can ensure reliable delivery while maximizing cost savings and customer satisfaction.

Happy coding!

About the Author

Ihor (Harry) Chyshkala

Ihor (Harry) Chyshkala

Code Alchemist: Transmuting Ideas into Reality with JS & PHP. DevOps Wizard: Transforming Infrastructure into Cloud Gold | Orchestrating CI/CD Magic | Crafting Automation Elixirs