Skip to main content
Understanding Zavu’s core concepts will help you build more effective messaging applications.

Channels

A channel is a communication medium through which messages are sent and received. Zavu supports multiple channels:
ChannelDescriptionBest For
SMSTraditional text messagesUniversal reach, critical alerts
WhatsAppWhatsApp Business APIRich media, high engagement
TelegramTelegram Bot APICost-effective, tech-savvy users
Each channel has different costs, delivery characteristics, and capabilities. Zavu’s Smart Routing helps you choose the optimal channel automatically.

Messages

Messages in Zavu are categorized by their direction:

Outbound Messages

Messages initiated by your application to users.
  • Marketing campaigns
  • Transactional notifications (order confirmations, OTPs)
  • Proactive alerts
  • Appointment reminders
Smart Routing applies to outbound messages, automatically selecting the best channel.

Inbound Messages

Messages received from users.
  • Customer inquiries
  • Support requests
  • Replies to your messages
  • User-initiated conversations
Inbound messages always use the channel the customer chose. When replying, you should use the same channel to maintain conversation context.
Use the message.inbound webhook event to receive real-time notifications when users message you.

Smart Routing

Smart Routing is Zavu’s ML-powered system that automatically selects the optimal channel for each outbound message.

How It Works

  1. Filters viable channels - Considers WhatsApp 24-hour window rules and sender configurations
  2. Sorts by cost - Orders channels from cheapest to most expensive
  3. Checks success rates - Selects the cheapest channel with 80%+ delivery success
  4. Falls back intelligently - If no channel meets the threshold, uses the one with best historical success

Channel Costs

ChannelCost per message
Telegram$0.005
WhatsApp$0.01
SMS$0.05

Exploration vs Exploitation

Smart Routing uses an epsilon-greedy strategy:
  • Exploration: For contacts with fewer than 3 attempts on a channel, it tries that channel to gather data
  • Exploitation: For contacts with sufficient data, it uses the cheapest channel that meets the success threshold
This ensures the system continuously learns while optimizing for cost and delivery.

Fallback

Fallback is automatic retry on a different channel when a message fails to deliver.
Message sent via WhatsApp → Delivery failed → Retry via SMS → Delivered

How It Works

  1. You send a message via the selected channel
  2. If delivery fails (unreachable, blocked, etc.), Zavu automatically tries the next available channel
  3. This continues until the message is delivered or all channels are exhausted

Configuration

Fallback is configured per Sender. When creating a Sender with multiple channels, fallback is enabled by default.
const sender = await zavu.senders.create({
  name: "Notifications",
  routingPolicy: "smart",
  channels: {
    whatsapp: { phoneNumber: "+1234567890" },
    sms: { phoneNumber: "+1234567890" }  // Fallback channel
  }
});
Configure SMS as a fallback channel for critical messages. SMS has the highest reach but is also the most expensive.

WhatsApp 24-Hour Window

WhatsApp has a strict messaging policy: you can only send free-form text within 24 hours of the last message received from the customer.

Window States

StateConditionAllowed Messages
OpenCustomer messaged within 24hFree-form text or templates
ClosedNo customer message in 24hTemplates only

Impact on Routing

Smart Routing automatically considers the window state:
  • Window open → WhatsApp is viable for any message
  • Window closed → WhatsApp is only viable if you’re sending a template

Best Practices

  1. Use templates for cold outreach - If contacting customers who haven’t messaged recently
  2. Respond quickly - Reply within 24 hours to keep the window open
  3. Re-engage with templates - Use approved templates to restart conversations

Senders

A Sender is a configuration that defines how messages are sent. It includes:
  • Name - Identifier for the sender (e.g., “Marketing”, “Support”)
  • Routing Policy - How channels are selected (smart or manual)
  • Channels - Phone numbers configured for each channel

Multi-Channel Senders

A single Sender can be configured with multiple channels:
const sender = await zavu.senders.create({
  name: "Customer Support",
  routingPolicy: "smart",
  channels: {
    sms: { phoneNumber: "+1234567890" },
    whatsapp: { phoneNumber: "+1234567890" },
    telegram: { botToken: "123456:ABC..." }
  }
});
When sending a message through this Sender, Smart Routing will automatically select the optimal channel.

Contacts

A Contact represents a person you communicate with. Zavu automatically creates and manages contacts based on message activity.

Automatic Contact Creation

When you send a message to a new phone number, Zavu automatically creates a contact record.

Channel Metrics

For each contact, Zavu tracks per-channel delivery metrics:
MetricDescription
Success CountDelivered messages
Failure CountFailed deliveries
Total AttemptsAll delivery attempts
Avg Delivery TimeTime from send to delivery
Last SuccessTimestamp of last successful delivery
These metrics power Smart Routing decisions, ensuring messages are sent through the most reliable channel for each contact.

Last Inbound Tracking

Zavu tracks the last inbound message timestamp per channel for each contact. This is used to determine WhatsApp window state:
lastInboundAt: {
  sms: 1705312200000,
  whatsapp: 1705398600000,  // Recent - window open
  telegram: null
}

Templates

Templates are pre-approved message formats required for certain channels and use cases.

WhatsApp Templates

WhatsApp requires templates for:
  • Messages outside the 24-hour window
  • Marketing campaigns
  • Transactional notifications at scale
Templates must be submitted to Meta for approval before use.

Template Components

ComponentDescription
HeaderOptional text, image, video, or document
BodyMain message content with variables
FooterOptional footer text
ButtonsOptional quick reply or call-to-action buttons

Variables

Templates support dynamic variables for personalization:
Hello {{1}}, your order #{{2}} has been shipped!
When sending, you provide the variable values:
await zavu.messages.send({
  to: "+1234567890",
  templateId: "order_shipped",
  variables: ["John", "12345"]
});

Summary

ConceptDescription
ChannelsSMS, WhatsApp, Telegram - different ways to reach users
MessagesOutbound (you → user) or Inbound (user → you)
Smart RoutingML-powered automatic channel selection
FallbackAutomatic retry on different channel
24-Hour WindowWhatsApp’s free-form text time limit
SendersMulti-channel message configurations
ContactsUser records with per-channel metrics
TemplatesPre-approved message formats