DEV Community

Ratnam Sachan
Ratnam Sachan

Posted on • Originally published at vyora.ai

How I Built an AI Voice Agent to Cut COD Returns by 40%

The Problem

If you run a D2C brand in India, COD is unavoidable. It accounts for 60–70% of all ecommerce orders. But it comes with a cost: 20–30% RTO (Return to Origin) rates that silently drain your margin.

For a brand shipping 1,000 COD orders/month at 25% RTO:

  • 250 orders bounce back
  • ₹300–500 per RTO (forward + reverse shipping + repackaging)
  • ₹75,000–1,25,000 lost every single month

The fix most people reach for: hire telecallers to manually confirm orders. This costs ₹25,000–40,000/month per agent, and they max out at 80–120 calls/day.

There's a better way.


The Architecture

Here's what I built:

Shopify/WooCommerce webhook
        ↓
  Order placed (COD)
        ↓
  POST to Vyora API
        ↓
  AI voice agent triggers (<60 seconds)
        ↓
  Hinglish/Hindi call to customer
        ↓
  Outcome logged → Confirmed / Cancelled / No Answer
        ↓
  Webhook fires back → Update OMS
Enter fullscreen mode Exit fullscreen mode

No human in the loop. Entire flow runs in under 2 minutes from order placement.


Step 1: Set Up Your Vyora Agent

Go to vyora.aiGet Started → Create a new agent.

Agent config:

  • Language: Hindi / Hinglish
  • Voice: Female (converts better for COD calls in India)
  • Goal: COD order confirmation

Script I used (Hinglish):

Namaste! Main [Brand Name] ki taraf se bol raha hoon.
Aapne abhi ek order place kiya hai — [Product Name] — ₹[Amount] ka.
Kya aap yeh order confirm karna chahte hain?

[If yes] → Bahut acha! Aapka order confirm ho gaya. 
           Delivery 3-5 din mein hogi.

[If no]  → Koi baat nahi. Main order cancel kar deta hoon.
Enter fullscreen mode Exit fullscreen mode

This runs fully automatically. The agent handles "haan", "ha", "yes", "nahi", "cancel" — all variations.


Step 2: Shopify Webhook Integration

In Shopify Admin → Settings → Notifications → Webhooks

Add webhook:

  • Event: orders/create
  • Format: JSON
  • URL: your server endpoint

Node.js handler:

const express = require('express');
const axios = require('axios');
const app = express();

app.use(express.json());

app.post('/webhook/shopify-cod', async (req, res) => {
  const order = req.body;

  // Only trigger for COD orders
  if (order.payment_gateway !== 'Cash on Delivery') {
    return res.status(200).send('skipped');
  }

  const payload = {
    phone: order.shipping_address.phone,
    variables: {
      customer_name: order.shipping_address.name,
      product_name: order.line_items[0].title,
      amount: order.total_price,
      brand_name: 'YourBrand'
    }
  };

  await axios.post('https://api.vyora.ai/v1/calls/trigger', payload, {
    headers: {
      'Authorization': `Bearer ${process.env.VYORA_API_KEY}`,
      'Content-Type': 'application/json'
    }
  });

  res.status(200).send('call triggered');
});

app.listen(3000);
Enter fullscreen mode Exit fullscreen mode

Deploy this to Railway or Render (free tier works fine for under 500 orders/day).


Step 3: WooCommerce Integration (Alternative)

If you're on WooCommerce, use a webhook trigger on woocommerce_new_order:

add_action('woocommerce_new_order', 'trigger_vyora_cod_call', 10, 1);

function trigger_vyora_cod_call($order_id) {
  $order = wc_get_order($order_id);

  if ($order->get_payment_method() !== 'cod') return;

  $phone   = $order->get_billing_phone();
  $name    = $order->get_billing_first_name();
  $product = $order->get_items();
  $total   = $order->get_total();

  $payload = json_encode([
    'phone'     => $phone,
    'variables' => [
      'customer_name' => $name,
      'amount'        => $total,
      'brand_name'    => get_bloginfo('name')
    ]
  ]);

  wp_remote_post('https://api.vyora.ai/v1/calls/trigger', [
    'headers' => [
      'Authorization' => 'Bearer ' . VYORA_API_KEY,
      'Content-Type'  => 'application/json'
    ],
    'body'    => $payload
  ]);
}
Enter fullscreen mode Exit fullscreen mode

Step 4: Handle Call Outcomes via Webhook

Vyora fires a callback when the call completes. Set your callback URL in the Vyora dashboard.

app.post('/webhook/vyora-outcome', async (req, res) => {
  const { call_id, outcome, order_id } = req.body;

  if (outcome === 'confirmed') {
    // Mark order as verified — proceed to dispatch
    await markOrderVerified(order_id);
  }

  if (outcome === 'cancelled') {
    // Cancel order in Shopify
    await cancelOrder(order_id);
  }

  if (outcome === 'no_answer') {
    // Retry logic — try again after 30 mins
    await scheduleRetry(order_id, 1800);
  }

  res.status(200).send('ok');
});
Enter fullscreen mode Exit fullscreen mode

Results After 30 Days

Running this on a fashion brand with ~800 COD orders/month:

Metric Before After
RTO rate 27% 16%
Monthly RTOs 216 128
RTOs prevented 88
Savings (₹350/RTO) ₹30,800/mo
Vyora cost ₹799/mo

ROI: 38x in month one.

The biggest drop came from impulse buyers who cancelled on the call — orders that would have shipped, failed delivery, and come back.


Why Hindi/Hinglish Matters

English IVR calls in India get ignored. Customers hang up or don't engage.

When the agent speaks in the customer's language:

  • Answer rate goes up significantly
  • Customers actually respond ("haan confirm karo")
  • Trust is established faster

For Tier 2/3 cities, this is non-negotiable. A brand in Jaipur selling to Rajasthan customers cannot run a confirmation call in English and expect results.

Vyora's agents handle Hindi, Hinglish, Tamil, Telugu, Marathi out of the box. You pick the language per agent.

For a full breakdown of the COD return problem and the data behind AI confirmation calls, read: How Indian D2C Brands Are Using AI Calls to Cut COD Returns by 40%


The Stack

  • AI voice agent: Vyora.ai (₹799/mo Builder plan)
  • Webhook server: Node.js on Railway
  • OMS: Shopify / WooCommerce
  • Language: Hindi / Hinglish

What This Doesn't Solve

  • High-intent fraud (repeat fraudsters with real addresses)
  • Address correction (you'd need a second call or WhatsApp for that)
  • NDR management after dispatch

This is pre-dispatch only — filters fake orders before they ship.


Get Started

  1. Sign up at vyora.ai — free plan gives 50 credits to test
  2. Build your Hindi confirmation agent (takes 5 mins)
  3. Connect Shopify/WooCommerce via webhook
  4. Watch your RTO rate drop in week one

If you're losing more than ₹50,000/month to COD returns, this pays for itself on day one.


Questions on the webhook setup? Drop them below.

Tags: india ecommerce shopify node voiceai

Top comments (0)