new_releases Update: Periksa
catatan rilis untuk mengetahui fitur baru dan update produk.
Mencabut pesan
Tetap teratur dengan koleksi
Simpan dan kategorikan konten berdasarkan preferensi Anda.
Agen Anda dapat membatalkan pesan yang telah dikirim tetapi belum terkirim. Sebaiknya batalkan pesan yang belum terkirim sebelum pesan tersebut menjadi tidak valid. Waktunya bergantung pada
kasus penggunaan agen Anda. Misalnya, Anda dapat mencabut pesan OTP setelah sepuluh menit, tetapi mencabut pesan promosi pada tanggal habis masa berlaku tertentu. Untuk
pengiriman pesan tepat waktu, pastikan untuk mencabut pesan tepat waktu agar Anda dapat mengirimkannya
melalui rute alternatif seperti SMS.
Ada dua cara untuk mencabut pesan:
Kirim permintaan pencabutan
untuk memicu pencabutan. Respons 200 OK mengonfirmasi bahwa pesan telah dibatalkan dan dihapus dari antrean pengguna. Respons 404 Not Found berarti upaya pencabutan telah gagal karena pesan telah dikirim.
Menyetel masa berlaku pesan
untuk mencabut pesan secara otomatis pada waktu yang tepat. Platform RBM memberi tahu agen Anda saat pesan telah berakhir dan mengonfirmasi apakah pesan berhasil dicabut atau tidak. Lihat Peristiwa yang dibuat server
untuk mengetahui informasi selengkapnya.
Pencabutan akses dapat gagal dalam kasus yang jarang terjadi. Misalnya, agen Anda dapat mencoba mencabut pesan saat platform RBM sedang dalam proses mengirimkannya. Jika
pencabutan gagal, periksa peristiwa DELIVERED
di webhook Anda. Jika pesan belum terkirim, Anda dapat mengirim
permintaan pencabutan
baru, lalu mengarahkan pesan ke saluran alternatif seperti SMS agar terkirim tepat waktu.
Contoh
Kode berikut mengirim permintaan pencabutan. Untuk mengetahui informasi pemformatan dan nilai, lihat 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);
});
Kode ini adalah kutipan dari agen contoh 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();
}
Kode ini adalah kutipan dari agen contoh 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)
Kode ini adalah kutipan dari agen contoh 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");
Kode ini adalah kutipan dari agen contoh RBM.
Kecuali dinyatakan lain, konten di halaman ini dilisensikan berdasarkan Lisensi Creative Commons Attribution 4.0, sedangkan contoh kode dilisensikan berdasarkan Lisensi Apache 2.0. Untuk mengetahui informasi selengkapnya, lihat Kebijakan Situs Google Developers. Java adalah merek dagang terdaftar dari Oracle dan/atau afiliasinya.
Terakhir diperbarui pada 2025-08-01 UTC.
[null,null,["Terakhir diperbarui pada 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)."]]