Cancel_sm with Ozeki NG SMS Gateway

This guide provides you detailed information on how to cancel an SMS text message after it has been sent to the SMS center (SMSC) but it has not been received by the recipient. This functionality can be achieved by cancel_sm service that is first available in 3.15.8 version of Ozeki NG SMS Gateway. Follow the guide below to adopt this service successfully.

If you send out an SMS message from your database with the help of Database user of Ozeki NG SMS Gateway you need to insert a record into the database. The database user checks the database and it sends out the SMS text message to the SMS center (SMSC). From the SMSC you will receive a report about the fact that the message arrives at the SMSC. This report contains the callback ID of the message. When the report is received the Database user updates the message status to Sent and insert the callback ID into Reference column of the database. This is the usual process of sending SMS from a database (Figure 1).

sending sms from a database with database user
Figure 1 - Sending SMS from a database with Database user

But if the user did not received the message after some time for any reason (for example the handset is off), then it is possible to cancel the message from the SMSC with the help of cancel_sm service. It can be the proper solution if the message has been expired after a definite time.

To cancel the message from the SMSC, insert a record into the database:

  • Message type: SMS:CANCEL
  • Recipient: the original recipient of the message
  • Message: the received callback ID

So if you insert the record above into the database, the Database user will poll out it and send a cancel indication to the SMSC and the SMSC will return a confirmation if the message has been canceled (Figure 2).

cancelling sms with cancel_sm
Figure 2 - Canceling SMS with cancel_sm

Configuration guide

First start Ozeki NG SMS Gateway and go to Database user configuration pane. In SQL Settings menu select SQL for sending tab. Click on Sent tab and type reference='$callbackid' after "status='sent'," (Figure 3).

type reference
Figure 3 - Type reference='$callbackid'

In our example I send out a test message to demonstrate the solution (Figure 4).

  • Recipient: +06205460691
  • Message: Hello World!
  • Status: send

send out a message
Figure 4 - Send out a message

On Figure 5 you can see that the message is accepted for delivery and the callback ID is also defined in this report.

callback id
Figure 5 - Callback ID

With SELECT * FROM ozekimessageout; statement you can query the messages from ozekimessageout table. After clicking on Execute you can see the message data that contain the callback ID among others (Figure 6).

query the ozekimessageout table
Figure 6 - Query ozekimessageout table

Now I insert a record to be sent out into the database where

  • Recipient: is the same as in the original message (+06205460691)
  • Message type: SMS:CANCEL
  • status: send (Figure 7).

insert a record to send out
Figure 7 - Insert a record to send out

In SMPP service provider the following PDUs will be seen: the first row is the cancel indication for canceling the message. The second row is the confirmation about the fact that the message has been canceled (Figure 8).

pdus for canceling
Figure 8 - PDUs for canceling

More information