Updates: Check the release notes for new features and product updates.

Revoke messages

Your agent can revoke messages that it has sent but that the RBM platform hasn't delivered to the user. If the RBM platform successfully revokes a message, the platform deletes the message from the user's message queue and doesn't deliver the message.

When the RBM platform receives a revocation request, the platform returns 200 OK. The 200 OK response doesn't confirm whether or not the RBM platform successfully revoked the message.

There is a small chance that your agent may initiate a revocation while the RBM platform is in the process of delivering the message. In these rare cases, your agent receives a DELIVERED event for the message shortly after initiating the revocation request.

It's best practice to revoke messages that aren't delivered after a reasonable period of time as part of a fallback messaging strategy. A reasonable period of time depends on your agent's use case and should be short enough that you can follow a message revocation with another messaging strategy, such as SMS, without blocking your end users.

Example

The following code sends a revocation request. For formatting and value information, see phones.agentMessages.delete.

cURL

curl -X DELETE "https://REGION-rcsbusinessmessaging.googleapis.com/v1/phones/PHONE_NUMBER/agentMessages/MESSAGE_ID" \
-H "Content-Type: application/json" \
-H "User-Agent: curl/rcs-business-messaging" \
-H "`oauth2l header --json PATH_TO_SERVICE_ACCOUNT_KEY rcsbusinessmessaging`"

Node.js

// Reference to RBM API helper
const rbmApiHelper = require('../libs/rbm_api_helper');

// Stop the message associated with messageId from being delivered
rbmApiHelper.revokeMessage('+12223334444', messageId, function(err, response) {
   console.log(response);
});
This code is an excerpt from an RBM sample agent.

Java

import com.google.rbm.samples.lib.RbmApiHelper;
…

try {
   // Create an instance of the RBM API helper
   RbmApiHelper rbmApiHelper = new RbmApiHelper();

   // Stop the message associated with messageId from being delivered
   rbmApiHelper.revokeMessage(messageId, "+12223334444");
} catch(Exception e) {
   e.printStackTrace();
}
This code is an excerpt from an RBM sample agent.

Python

# Reference to RBM Python client helper and messaging object structure
from rcs_business_messaging import rbm_service

# Stop the message associated with message_id from being delivered
rbm_service.revoke('+12223334444', message_id)
This code is an excerpt from an RBM sample agent.

C#

using RCSBusinessMessaging;
…

// Create an instance of the RBM API helper
RbmApiHelper rbmApiHelper = new RbmApiHelper(credentialsFileLocation,
                                                 projectId);

// Stop the message associated with messageId from being delivered
rbmApiHelper.RevokeMessage(messageId, "+12223334444");
This code is an excerpt from an RBM sample agent.