new_releases 更新:查看
版本说明,了解新功能和产品动态。
活动
使用集合让一切井井有条
根据您的偏好保存内容并对其进行分类。
在以下示例中,rbm_api_helper.js
(不适用于 Python)假定您正在处理的文件位于主应用文件夹下一个目录中。根据项目的配置,您可能需要调整位置。
读取事件
已读事件可让用户知道客服人员已收到消息,并让他们确信 RBM 平台已传送其消息。以下代码会向包含客户端库的设备发送读取事件。
Node.js
// Reference to RBM API helper
const rbmApiHelper = require('@google/rcsbusinessmessaging');
// Send the device an event to indicate that messageId has been read
rbmApiHelper.sendReadMessage('+12223334444', messageId);
此代码是 RBM 示例代理的摘录。
Java
import com.google.rbm.RbmApiHelper;
…
// Create an instance of the RBM API helper
RbmApiHelper rbmApiHelper = new RbmApiHelper();
// Send the device an event to indicate that messageId has been read
rbmApiHelper.sendReadMessage(messageId, "+12223334444");
此代码是 RBM 示例代理的摘录。
Python
# Reference to RBM Python client helper and messaging object structure
from rcs_business_messaging import rbm_service
# Send the device an event to indicate that message_id was read
rbm_service.send_read_event('+12223334444', message_id)
此代码是 RBM 示例代理的摘录。
C#
using RCSBusinessMessaging;
…
// Create an instance of the RBM API helper
RbmApiHelper rbmApiHelper = new RbmApiHelper(credentialsFileLocation,
projectId);
// Send the device an event to indicate that messageId has been read
rbmApiHelper.SendReadMessage(messageId, "+12223334444");
此代码是 RBM 示例代理的摘录。
打字事件
打字事件可让用户知道您的客服人员正在撰写消息。以下代码会向包含客户端库的设备发送打字事件。
Node.js
// Reference to RBM API helper
const rbmApiHelper = require('@google/rcsbusinessmessaging');
// Send the device an event to indicate that the agent is typing
rbmApiHelper.sendIsTypingMessage('+12223334444', function() {
console.log('Typing event sent!');
});
此代码是 RBM 示例代理的摘录。
Java
import com.google.rbm.RbmApiHelper;
…
// Create an instance of the RBM API helper
RbmApiHelper rbmApiHelper = new RbmApiHelper();
// Send the device an event to indicate that the agent is typing
rbmApiHelper.sendIsTypingMessage("+12223334444");
此代码是 RBM 示例代理的摘录。
Python
# Reference to RBM Python client helper and messaging object structure
from rcs_business_messaging import rbm_service
# Send the device an event to indicate that the agent is typing
rbm_service.send_is_typing_event('+12223334444')
此代码是 RBM 示例代理的摘录。
C#
using RCSBusinessMessaging;
…
// Create an instance of the RBM API helper
RbmApiHelper rbmApiHelper = new RbmApiHelper(credentialsFileLocation,
projectId);
// Send the device an event to indicate that the agent is typing
rbmApiHelper.SendIsTypingMessage(messageId, "+12223334444");
此代码是 RBM 示例代理的摘录。
如未另行说明,那么本页面中的内容已根据知识共享署名 4.0 许可获得了许可,并且代码示例已根据 Apache 2.0 许可获得了许可。有关详情,请参阅 Google 开发者网站政策。Java 是 Oracle 和/或其关联公司的注册商标。
最后更新时间 (UTC):2025-04-10。
[null,null,["最后更新时间 (UTC):2025-04-10。"],[[["\u003cp\u003eRead events inform the user that the agent has received their message, confirming delivery by the RBM platform, with code examples provided for Node.js, Java, Python, and C#.\u003c/p\u003e\n"],["\u003cp\u003eTyping events signal to the user that the agent is currently composing a message, and examples using Node.js, Java, Python, and C# are shown.\u003c/p\u003e\n"],["\u003cp\u003eThe examples demonstrate how to use the RBM API helper to send read and typing events, across multiple programming languages.\u003c/p\u003e\n"],["\u003cp\u003e\u003ccode\u003erbm_api_helper.js\u003c/code\u003e is designed for use in Node.js and assumes a specific directory structure, which might need adjustments based on your project's configuration.\u003c/p\u003e\n"]]],[],null,["# Events\n\nIn the following examples, `rbm_api_helper.js` (not used for Python) assumes the\nfile you are working in is one directory below the main app folder. You may need\nto adjust the location depending on your project's configuration.\n\nRead events\n-----------\n\n[Read events](/business-communications/rcs-business-messaging/guides/build/events#read) let the user know that the agent received the message and\nprovide confidence that the RBM platform delivered their message. The following\ncode sends a read event to a device with a client library. \n\n### Node.js\n\n```javascript\n// Reference to RBM API helper\nconst rbmApiHelper = require('@google/rcsbusinessmessaging');\n\n// Send the device an event to indicate that messageId has been read\nrbmApiHelper.sendReadMessage('\u003cvar fieldlabel=\"Phone number\" translate=\"no\"\u003e+12223334444\u003c/var\u003e', messageId);\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\n// Create an instance of the RBM API helper\nRbmApiHelper rbmApiHelper = new RbmApiHelper();\n\n// Send the device an event to indicate that messageId has been read\nrbmApiHelper.sendReadMessage(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).\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# Send the device an event to indicate that message_id was read\nrbm_service.send_read_event('\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// Send the device an event to indicate that messageId has been read\nrbmApiHelper.SendReadMessage(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).\n\nTyping events\n-------------\n\n[Typing events](/business-communications/rcs-business-messaging/guides/build/events#typing)\nlet the user know that your agent is composing a message. The following code\nsends a typing event to a device with a client library. \n\n### Node.js\n\n```javascript\n// Reference to RBM API helper\nconst rbmApiHelper = require('@google/rcsbusinessmessaging');\n\n// Send the device an event to indicate that the agent is typing\nrbmApiHelper.sendIsTypingMessage('\u003cvar fieldlabel=\"Phone number\" translate=\"no\"\u003e+12223334444\u003c/var\u003e', function() {\n console.log('Typing event sent!');\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\n// Create an instance of the RBM API helper\nRbmApiHelper rbmApiHelper = new RbmApiHelper();\n\n// Send the device an event to indicate that the agent is typing\nrbmApiHelper.sendIsTypingMessage(\"\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).\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# Send the device an event to indicate that the agent is typing\nrbm_service.send_is_typing_event('\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).\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// Send the device an event to indicate that the agent is typing\nrbmApiHelper.SendIsTypingMessage(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)."]]