เหตุการณ์คือการแจ้งเตือนที่ตัวแทนสามารถรับและส่งได้ กิจกรรมมี 3 ประเภท
- เซิร์ฟเวอร์สร้าง: ส่งไปยังตัวแทนของคุณโดยแพลตฟอร์ม RBM
- ผู้ใช้สร้างขึ้น: อุปกรณ์ของผู้ใช้ส่งไปยัง Agent ของคุณ
- ตัวแทนสร้างขึ้น: ส่งโดยตัวแทนของคุณให้ผู้ใช้
เหตุการณ์ที่เซิร์ฟเวอร์สร้างขึ้น
แพลตฟอร์ม RBM จะส่งกิจกรรมเพื่อแจ้งให้ตัวแทนของคุณทราบเกี่ยวกับการอัปเดตระดับเซิร์ฟเวอร์ เช่น ข้อความหมดอายุ
ดูตัวเลือกการจัดรูปแบบและค่าได้ที่ ServerEvent
ข้อความหมดอายุแล้ว เพิกถอนสำเร็จ
ข้อความหมดอายุและถูกเพิกถอนเรียบร้อยแล้ว เหตุการณ์นี้จะเป็นจุดกระตุ้นที่ดี สำหรับกลยุทธ์การรับส่งข้อความสำรอง
{ "phoneNumber": [phone number of recipient that the original message was intended for] , "messageId": [RCS message ID of the message], "agentId": [bot ID], "eventType": "TTL_EXPIRATION_REVOKED", "eventId": [unique ID generated by the RBM platform], "sendTime": [time at which the server sent this event] }
ข้อความหมดอายุแล้ว เพิกถอนไม่สำเร็จ
ข้อความหมดอายุ แต่ไม่ได้ถูกเพิกถอน
{ "phoneNumber": [phone number of recipient that the original message was intended for] , "messageId": [RCS message ID of the message], "agentId": [bot ID], "eventType": "TTL_EXPIRATION_REVOKE_FAILED", "eventId": [unique ID generated by the RBM platform], "sendTime": [time at which the server sent this event] }
ไม่รับประกันการส่งข้อความ
- หากมีการส่งข้อความ คุณจะได้รับเหตุการณ์
DELIVERED
ที่เว็บฮุค - หากไม่ได้ส่งข้อความ ให้ใช้ API การเพิกถอนเพื่อส่งคำขอเพิกถอน
ถ้าข้อความมีกำหนดเวลา เช่น OTP หรือการแจ้งเตือนการประพฤติมิชอบ วิธีที่ดีที่สุดคือส่งข้อความผ่านช่องทางอื่น เช่น SMS แม้ว่าจะทำให้เกิดข้อความซ้ำถึงผู้ใช้ก็ตาม
กิจกรรมที่ผู้ใช้สร้างขึ้น
ตัวแทนจะได้รับเหตุการณ์ของผู้ใช้เป็น JSON เช่นเดียวกับข้อความของผู้ใช้และการตรวจสอบความสามารถ
ดูตัวเลือกการจัดรูปแบบและค่าได้ที่ UserEvent
ผู้ใช้ได้รับข้อความจาก Agent
เหตุการณ์นี้บ่งชี้ว่ามีการส่งข้อความแล้ว
{ "senderPhoneNumber": "PHONE_NUMBER", "eventType": "DELIVERED", "eventId": "EVENT_ID", "messageId": "MESSAGE_ID", "agentId": "AGENT_ID" }
ผู้ใช้อ่านข้อความของ Agent
เหตุการณ์นี้บ่งชี้ว่ามีการเปิดหรือรับทราบข้อความแล้ว
{ "senderPhoneNumber": "PHONE_NUMBER", "eventType": "READ", "eventId": "EVENT_ID", "messageId": "MESSAGE_ID", "agentId": "AGENT_ID" }
ผู้ใช้เริ่มพิมพ์
เหตุการณ์นี้แสดงว่าผู้ใช้กำลังพิมพ์อยู่
{ "senderPhoneNumber": "PHONE_NUMBER", "eventType": "IS_TYPING", "eventId": "EVENT_ID",, "agentId": "AGENT_ID" }
ผู้ใช้ส่ง SMS
{ "senderPhoneNumber": "PHONE_NUMBER", "text": "Hi", "eventId": "EVENT_ID", "agentId": "AGENT_ID" }
ผู้ใช้ส่งไฟล์
{ "senderPhoneNumber": "PHONE_NUMBER", "userFile": { "payload": { "mimeType": "image/gif", "fileSizeBytes": 127806, "fileUri": "https://storage.googleapis.com/copper_test/77ddb795-24ad-4607-96ae-b08b4d86406a/d2dcc67ab888d34ee272899c020b13402856f81597228322079eb007e8c9", "fileName": "4_animated.gif" } }, "eventId": "EVENT_ID",, "agentId": "AGENT_ID" }
ผู้ใช้แตะคำตอบที่แนะนำ
เมื่อผู้ใช้แตะการตอบกลับที่แนะนำ ตัวแทนของคุณจะได้รับกิจกรรมพร้อมข้อมูลระบบรายงานผล Conversion และข้อความของการตอบกลับ
{ "senderPhoneNumber": "PHONE_NUMBER", "eventId": "EVENT_ID", "agentId": "AGENT_ID", "suggestionResponse": { "postbackData": "postback_1234", "text": "Hello there!" } }
ผู้ใช้แตะการดำเนินการที่แนะนำ
เมื่อผู้ใช้แตะการดำเนินการที่แนะนำ ตัวแทนของคุณจะได้รับเหตุการณ์ที่มีข้อมูลระบบรายงานผล Conversion ของการดำเนินการ
{ "senderPhoneNumber": "PHONE_NUMBER", "eventId": "EVENT_ID", "agentId": "AGENT_ID", "suggestionResponse": { "postbackData": "postback_1234" } }
กิจกรรมที่ตัวแทนสร้างขึ้น
ตัวแทนจะส่งเหตุการณ์เพื่อจำลองการโต้ตอบของมนุษย์และให้ผู้ใช้มั่นใจว่าตัวแทนจะมีส่วนร่วมกับข้อความของตน สำหรับผู้ใช้ กิจกรรมจะแสดงเป็น การแจ้งเตือนภายในการสนทนา
ดูตัวเลือกการจัดรูปแบบและค่าได้ที่ phones.agentEvents
ตัวแทนส่งเหตุการณ์ READ
สำหรับผู้ใช้ กิจกรรมนี้จะปรากฏเป็นใบตอบรับการอ่านสําหรับข้อความที่ระบุ ซึ่งช่วยให้ผู้ใช้ทราบว่าแพลตฟอร์ม RBM ได้ส่งข้อความแล้ว และตัวแทนกำลังประมวลผลข้อความ
โค้ดต่อไปนี้จะส่งเหตุการณ์ READ
สําหรับข้อความที่มี messageId
ที่ตรงกัน
cURL
curl -X POST "https://REGION-rcsbusinessmessaging.googleapis.com/v1/phones/PHONE_NUMBER/agentEvents?eventId=EVENT_ID" \ -H "Content-Type: application/json" \ -H "User-Agent: curl/rcs-business-messaging" \ -H "`oauth2l header --json PATH_TO_SERVICE_ACCOUNT_KEY rcsbusinessmessaging`" \ -d "{ 'eventType': 'READ', 'messageId': 'MESSAGE_ID' }"
Node.js
// Reference to RBM API helper const rbmApiHelper = require('../libs/rbm_api_helper'); // Send the device an event to indicate that messageId has been read rbmApiHelper.sendReadMessage('+12223334444', messageId);โค้ดนี้ข้อความที่ตัดตอนมาจากตัวแทนตัวอย่าง RBM
Java
import com.google.rbm.samples.lib.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
ตัวแทนส่งเหตุการณ์ IS_TYPING
สำหรับผู้ใช้ เหตุการณ์นี้จะปรากฏเป็นสัญญาณบอกสถานะกำลังพิมพ์และแจ้งให้ผู้ใช้ทราบว่าตัวแทนของคุณกำลังเขียนข้อความ สัญญาณบอกสถานะกำลังพิมพ์จะหมดอายุหลังจากผ่านไปสักครู่ (ประมาณ 20 วินาที) หรือเมื่ออุปกรณ์ของผู้ใช้ได้รับข้อความใหม่จากตัวแทนของคุณ ตัวแทนสามารถส่งเหตุการณ์ IS_TYPING
หลายรายการเพื่อรีเซ็ตตัวจับเวลาการหมดอายุของสัญญาณบอกสถานะการพิมพ์
โค้ดต่อไปนี้จะส่งเหตุการณ์ IS_TYPING
cURL
curl -X POST "https://REGION-rcsbusinessmessaging.googleapis.com/v1/phones/PHONE_NUMBER/agentEvents?eventId=EVENT_ID" \ -H "Content-Type: application/json" \ -H "User-Agent: curl/rcs-business-messaging" \ -H "`oauth2l header --json PATH_TO_SERVICE_ACCOUNT_KEY rcsbusinessmessaging`" \ -d "{ 'eventType': 'IS_TYPING', }"
Node.js
// Reference to RBM API helper const rbmApiHelper = require('../libs/rbm_api_helper'); // 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.samples.lib.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