new_releases Actualizaciones: Consulte las
notas de la versión para conocer las funciones nuevas y las actualizaciones de productos.
Revocar mensajes
Organiza tus páginas con colecciones
Guarda y categoriza el contenido según tus preferencias.
Tu agente puede revocar un mensaje que se envió, pero que aún no se entregó. Es mejor revocar los mensajes no entregados antes de que se vuelvan obsoletos. El momento depende del caso de uso de tu agente. Por ejemplo, puedes revocar un mensaje de OTP después de diez minutos, pero revocar un mensaje promocional en una fecha de vencimiento específica. Para garantizar la entrega oportuna de los mensajes, asegúrate de revocarlos a tiempo para enviarlos por una ruta alternativa, como SMS.
Existen dos formas de revocar un mensaje:
Envía una solicitud de revocación para activar la revocación. La respuesta 200 OK confirma que se revocó el mensaje y se borró de la cola del usuario. Una respuesta 404 Not Found significa que el intento de revocación falló porque se entregó el mensaje.
Establece un vencimiento del mensaje para revocarlo automáticamente en el momento adecuado. La plataforma de RBM notifica a tu agente cuando vence el mensaje y confirma si se revocó correctamente. Consulta Eventos generados por el servidor para obtener más información.
En raras ocasiones, la revocación podría fallar. Por ejemplo, tu agente puede intentar revocar un mensaje mientras la plataforma de RBM está en proceso de entregarlo. Si falla la revocación, busca un evento DELIVERED
en tu webhook. Si el mensaje no se entregó, puedes enviar una nueva solicitud de revocación y, luego, enrutar el mensaje a un canal alternativo, como SMS, para que se entregue a tiempo.
Ejemplo
El siguiente código envía una solicitud de revocación. Para obtener información sobre el formato y los valores, consulta phones.agentMessages.delete
.
cURL
curl -X DELETE "https://REGION-rcsbusinessmessaging.googleapis.com/v1/phones/PHONE_NUMBER/agentMessages/MESSAGE_ID?agentId=AGENT_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('@google/rcsbusinessmessaging');
// Stop the message associated with messageId from being delivered
rbmApiHelper.revokeMessage('+12223334444', messageId, function(err, response) {
console.log(response);
});
Este código es un fragmento de un agente de muestra de RBM.
Java
import com.google.rbm.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();
}
Este código es un fragmento de un agente de muestra de RBM.
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)
Este código es un fragmento de un agente de muestra de RBM.
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");
Este código es un fragmento de un agente de muestra de RBM.
Salvo que se indique lo contrario, el contenido de esta página está sujeto a la licencia Atribución 4.0 de Creative Commons, y los ejemplos de código están sujetos a la licencia Apache 2.0. Para obtener más información, consulta las políticas del sitio de Google Developers. Java es una marca registrada de Oracle o sus afiliados.
Última actualización: 2025-08-01 (UTC)
[null,null,["Última actualización: 2025-08-01 (UTC)"],[[["\u003cp\u003eAgents can revoke undelivered messages, with the optimal timing for revocation depending on the message's context, such as revoking an OTP after ten minutes versus a promotional message on a specific date.\u003c/p\u003e\n"],["\u003cp\u003eMessage revocation can be initiated through a revocation request, which triggers a 200 OK response from the RBM platform without guaranteeing successful revocation; success results in the message being deleted from the user's queue.\u003c/p\u003e\n"],["\u003cp\u003eSetting a message expiration time enables automatic revocation, with the RBM platform confirming whether the message was successfully revoked upon expiration.\u003c/p\u003e\n"],["\u003cp\u003eIn the rare event that revocation fails, an agent can check for a \u003ccode\u003eDELIVERED\u003c/code\u003e event and resend a revocation request before routing the message via an alternative channel, like SMS, to ensure delivery.\u003c/p\u003e\n"],["\u003cp\u003eThe code examples show how to revoke a message through a revocation request in cURL, Node.js, Java, Python, and C#, demonstrating the practical application of message revocation.\u003c/p\u003e\n"]]],[],null,["# Revoke messages\n\nYour agent can revoke a message that has been sent but not yet delivered. It's\nbest to revoke undelivered messages before they go stale. The timing depends on\nyour agent's use case. For example, you might revoke an OTP message after ten\nminutes but revoke a promotional message on a specific expiration date. For\ntimely message delivery, be sure to revoke messages in time for you to send them\nby an alternate route like SMS.\n\nThere are two ways to revoke a message:\n\n- [Send a revocation request](/business-communications/rcs-business-messaging/guides/build/messages/revoke#example)\n to trigger the revocation. The 200 OK response confirms that the message was\n revoked and deleted from the user's queue. A 404 Not Found response means\n the revocation attempt has failed because the message was delivered.\n\n- [Set a message expiration](/business-communications/rcs-business-messaging/guides/build/messages/send#expire)\n to automatically revoke the message at the appropriate time. The RBM\n platform notifies your agent when the message has expired and confirms\n whether or not it was successfully revoked. See [Server-generated events](/business-communications/rcs-business-messaging/guides/build/events#server-generated_events)\n for more information.\n\nRevocation could fail on rare occasions. For example, your agent may attempt to\nrevoke a message while the RBM platform is in the process of delivering it. If\nrevocation fails, check for a [`DELIVERED` event](/business-communications/rcs-business-messaging/guides/build/events#delivered)\nat your webhook. If the message hasn't been delivered, you can send a new\n[revocation request](/business-communications/rcs-business-messaging/guides/build/messages/revoke#example)\nand then route the message to an alternate channel like SMS for timely delivery.\n\nExample\n-------\n\nThe following code sends a revocation request. For formatting and value\ninformation, see\n[`phones.agentMessages.delete`](/business-communications/rcs-business-messaging/reference/rest/v1/phones.agentMessages/delete). \n\n### cURL\n\n```console\ncurl -X DELETE \"https://\u003cvar fieldvalues=\"asia,europe,us\" translate=\"no\"\u003eREGION\u003c/var\u003e-rcsbusinessmessaging.googleapis.com/v1/phones/\u003cvar translate=\"no\"\u003ePHONE_NUMBER\u003c/var\u003e/agentMessages/\u003cvar fieldlabel=\"Message ID\" translate=\"no\"\u003eMESSAGE_ID\u003c/var\u003e?agentId=\u003cvar translate=\"no\"\u003eAGENT_ID\u003c/var\u003e\" \\\n-H \"Content-Type: application/json\" \\\n-H \"User-Agent: curl/rcs-business-messaging\" \\\n-H \"`oauth2l header --json \u003cvar translate=\"no\"\u003ePATH_TO_SERVICE_ACCOUNT_KEY\u003c/var\u003e rcsbusinessmessaging`\"\n```\n\n### Node.js\n\n```javascript\n// Reference to RBM API helper\nconst rbmApiHelper = require('@google/rcsbusinessmessaging');\n\n// Stop the message associated with messageId from being delivered\nrbmApiHelper.revokeMessage('\u003cvar fieldlabel=\"Phone number\" translate=\"no\"\u003e+12223334444\u003c/var\u003e', messageId, function(err, response) {\n console.log(response);\n});\n```\nThis code is an excerpt from an [RBM sample agent](/business-communications/rcs-business-messaging/samples).\n\n### Java\n\n```java\nimport com.google.rbm.RbmApiHelper;\n...\n\ntry {\n // Create an instance of the RBM API helper\n RbmApiHelper rbmApiHelper = new RbmApiHelper();\n\n // Stop the message associated with messageId from being delivered\n rbmApiHelper.revokeMessage(messageId, \"\u003cvar fieldlabel=\"Phone number\" translate=\"no\"\u003e+12223334444\u003c/var\u003e\");\n} catch(Exception e) {\n e.printStackTrace();\n}\n```\nThis code is an excerpt from an [RBM sample agent](/business-communications/rcs-business-messaging/samples).\n\n### Python\n\n```python\n# Reference to RBM Python client helper and messaging object structure\nfrom rcs_business_messaging import rbm_service\n\n# Stop the message associated with message_id from being delivered\nrbm_service.revoke('\u003cvar fieldlabel=\"Phone number\" translate=\"no\"\u003e+12223334444\u003c/var\u003e', message_id)\n```\nThis code is an excerpt from an [RBM sample agent](/business-communications/rcs-business-messaging/samples).\n\n### C#\n\n```c#\nusing RCSBusinessMessaging;\n...\n\n// Create an instance of the RBM API helper\nRbmApiHelper rbmApiHelper = new RbmApiHelper(credentialsFileLocation,\n projectId);\n\n// Stop the message associated with messageId from being delivered\nrbmApiHelper.RevokeMessage(messageId, \"\u003cvar fieldlabel=\"Phone number\" translate=\"no\"\u003e+12223334444\u003c/var\u003e\");\n```\nThis code is an excerpt from an [RBM sample agent](/business-communications/rcs-business-messaging/samples)."]]