Delivery Receipts

You can verify that a message you sent using the Vonage SMS API reached your customer by requesting a delivery receipt from the carrier.

NOTE: Not all networks and countries support delivery receipts. You can check our knowledge base for some further information on what you might receive if your network does not support delivery receipts. For detailed information on delivery receipts see our documentation.

To access the delivery receipt, you need to:

NOTE: After you send a message there may be a delay before you receive the delivery receipt.

Prerequisites

npm install express body-parser

Write the code

Add the following to dlr-express.js:

const app = require('express')();
const bodyParser = require('body-parser');

app.use(bodyParser.json());
app.use(bodyParser.urlencoded({ extended: true }));

const handleDeliveryReceipt = (request, response) => {
  const params = Object.assign(request.query, request.body);
  console.log(params);
  response.status(204).send();
};

app
  .route('/webhooks/delivery-receipt')
  .get(handleDeliveryReceipt)
  .post(handleDeliveryReceipt);

app.listen(process.env.PORT || 3000);

View full source

Run your code

Save this file to your machine and run it:

node dlr-express.js

Configure the webhook endpoint in your Vonage Dashboard

So that Vonage knows how to access your webhook, you must configure it in your Vonage account.

In the code snippets, the webhook is located at /webhooks/delivery-receipt. If you are using Ngrok, the webhook you need to configure in your Vonage Dashboard API Settings page is of the form https://demo.ngrok.io/webhooks/delivery-receipt. Replace demo with the subdomain provided by Ngrok and enter your endpoint in the field labeled Webhook URL for Delivery Receipts:

Try it out

Send a message to a mobile number and, if the network supports it, you will receive a delivery receipt in the following format:

{
  "err-code": "0",
  "message-timestamp": "2020-10-25 12:10:29",
  "messageId": "0B00000127FDBC63",
  "msisdn": "447700900000",
  "network-code": "23410",
  "price": "0.03330000",
  "scts": "1810251310",
  "status": "delivered",
  "to": "Vonage"
}

NOTE: After you send a message there may be a delay before you receive the delivery receipt.

More information