Quy trình làm việc RBM cốt lõi dành cho nhà mạng bao gồm việc xem xét thông tin về các tác nhân mới và phê duyệt hoặc từ chối cấp cho họ quyền ra mắt trên mạng của nhà mạng và nhắn tin cho người đăng ký.
Đoạn mã trên trang này được lấy từ các mẫu Javascript và Curl của chúng tôi.
Liệt kê tất cả các đại lý đã gửi cho một hãng vận chuyển
Nhà mạng có thể lấy danh sách tất cả các tác nhân mà nhà phát triển đã gửi để ra mắt trên mạng của nhà mạng.
Node.js
const businessCommunicationsApiHelper = require('@google/rbm-businesscommunications'); const privateKey = require('../../resources/businesscommunications-service-account-credentials.json'); businessCommunicationsApiHelper.initBusinessCommunucationsApi(privateKey); // Retrieve all agents targeting the carrier businessCommunicationsApiHelper.listAgents('brands/-').then((response) => { console.log('Current agents are:'); console.log(JSON.stringify(response.data, null, 2)); }).catch((err) => { console.log(err); });
cURL
curl -v "https://businesscommunications.googleapis.com/v1/brands/-/agents" \ -H "Content-Type: application/json" \ -H "User-Agent: curl/business-messaging" \ -H "`oauth2l header --json serviceAccount.json businesscommunications`"
Thương hiệu được đặt thành - vì không bắt buộc khi truy xuất danh sách tất cả các tác nhân.
Mã này trả về danh sách tất cả các nhân viên hỗ trợ đã được gửi để ra mắt tại hãng vận chuyển:
{
"agents": [
{
"name": "brands/40bd963f-ff92-425c-b273-8f0892d2d017/agents/my_new_agent_4fpd1psz_agent",
"displayName": "My new agent",
"rcsBusinessMessagingAgent": {
"description": "This is the agent description that will be displayed in the Agent info tab in Messages",
"logoUri": "https://agent-logos.storage.googleapis.com/_/kt90w53vzw2QSxK6PG1uCeJf",
"heroUri": "https://agent-logos.storage.googleapis.com/_/kt90vzob74GQcfeHoEQbVRTP",
"phoneNumbers": [
{
"phoneNumber": {
"number": "+12223334444"
},
"label": "Call support"
}
],
"privacy": {
"uri": "https://policies.google.com/privacy",
"label": "Our privacy policy"
},
"termsConditions": {
"uri": "https://policies.google.com/terms",
"label": "Our Terms and Conditions"
},
"color": "#0B78D0",
"billingConfig": {
"billingCategory": "NON_CONVERSATIONAL"
},
"agentUseCase": "MULTI_USE",
"hostingRegion": "NORTH_AMERICA",
"partner": {
"partnerId": "unique-identifier-for-my-partner",
"displayName": "My partner",
"company": "Public name of the company for my partner"
}
}
},
{
"name": "brands/40bd963f-ff92-425c-b273-8f0892d2d017/agents/my_new_agent_7jo0trhw_agent",
"displayName": "My second agent",
"rcsBusinessMessagingAgent": {
"description": "Another agent description",
"logoUri": "https://agent-logos.storage.googleapis.com/_/kt90w53vzw2QSxK6PG1uCeJf",
"heroUri": "https://agent-logos.storage.googleapis.com/_/kt90vzob74GQcfeHoEQbVRTP",
"phoneNumbers": [
{
"phoneNumber": {
"number": "+12228885768"
},
"label": "Call support"
}
],
"privacy": {
"uri": "https://policies.google.com/privacy",
"label": "Our privacy policy"
},
"termsConditions": {
"uri": "https://policies.google.com/terms",
"label": "Our Terms and Conditions"
},
"color": "#0B78D0",
"billingConfig": {
"billingCategory": "CONVERSATIONAL"
},
"agentUseCase": "PROMOTIONAL",
"hostingRegion": "NORTH_AMERICA",
"partner": {
"partnerId": "unique-identifier-for-my-partner",
"displayName": "My partner",
"company": "Public name of the company for my partner"
}
}
}
]
}
Bạn có thể truy xuất kết quả theo từng trang. Hãy xem Tài liệu tham khảo API để biết thông tin chi tiết.
Lấy thông tin xác minh của nhân viên hỗ trợ
Hãng vận chuyển có thể biết được trạng thái xác minh thương hiệu của đại lý. Để biết thêm thông tin chi tiết, hãy xem brands.agents.getVerification.
Node.js
const businessCommunicationsApiHelper = require('@google/rbm-businesscommunications'); const privateKey = require('../../resources/businesscommunications-service-account-credentials.json'); businessCommunicationsApiHelper.initBusinessCommunucationsApi(privateKey); businessCommunicationsApiHelper.getAgentVerification(agents[0].name).then((response) => { }).catch((err) => { console.log(err); });
cURL
curl -v "https://businesscommunications.googleapis.com/v1/brands/-/agents/AGENT ID/verification" \ -H "Content-Type: application/json" \ -H "User-Agent: curl/business-messaging" \ -H "`oauth2l header --json serviceAccount.json businesscommunications`"
Người gọi không nhất thiết phải biết tên đầy đủ của nhân viên hỗ trợ, bao gồm cả tên thương hiệu.
Bạn chỉ cần mã nhân viên hỗ trợ (trước @rbm.goog), với tên thương hiệu được đặt thành -.
Mã này trả về trạng thái xác minh và thông tin đối tác:
{
"name": "brands/40bd963f-ff92-425c-b273-8f0892d2d017/agents/my_new_agent_ciymyd2b_agent/verification",
"verificationState": "VERIFICATION_STATE_UNVERIFIED",
"agentVerificationContact": {
"partnerName": "John Doe",
"partnerEmailAddress": "john.doe@gmail.com",
"brandContactName": "Bob",
"brandContactEmailAddress": "bob@brand.com",
"brandWebsiteUrl": "https://www.brand.com"
}
}
Xem trạng thái ra mắt và bảng câu hỏi về nhân viên hỗ trợ
Nhà mạng có thể lấy trạng thái ra mắt hiện tại của một nhân viên hỗ trợ và bảng câu hỏi ra mắt của nhà phát triển.
Node.js
const businessCommunicationsApiHelper = require('@google/rbm-businesscommunications'); const privateKey = require('../../resources/businesscommunications-service-account-credentials.json'); businessCommunicationsApiHelper.initBusinessCommunucationsApi(privateKey); businessCommunicationsApiHelper.getAgentLaunch(agents[0].name).then((response) => { console.log('Launch details are:'); console.log(JSON.stringify(response.data, null, 2)); }).catch((err) => { console.log(err); });
cURL
curl -v "https://businesscommunications.googleapis.com/v1/brands/-/agents/AGENT ID/launch" \ -H "Content-Type: application/json" \ -H "User-Agent: curl/business-messaging" \ -H "`oauth2l header --json serviceAccount.json businesscommunications`"
Người gọi không nhất thiết phải biết tên đầy đủ của nhân viên hỗ trợ, bao gồm cả tên thương hiệu.
Bạn chỉ cần mã nhân viên hỗ trợ (trước @rbm.goog), với tên thương hiệu được đặt thành -.
Mã này trả về thông tin khởi chạy:
{
"name": "brands/8b5c7f80-b025-486b-bc8a-2d0797559711/agents/my-agent-demo/launch",
"rcsBusinessMessaging": {
"questionnaire": {
"contacts": [
{
"name": "John Doe",
"title": "Mr",
"email": "johndoe@developer.com"
}
],
"optinDescription": "Messages are sent to known MSISDNs",
"triggerDescription": "We respond to any interaction",
"interactionsDescription": "Simple conversations with a chatbot",
"optoutDescription": "User sends stop"
},
"launchDetails": {
"/v1/regions/thecarrier": {
"launchState": "LAUNCH_STATE_LAUNCHED",
"updateTime": "2023-02-20T15:10:36.528669Z"
}
}
}
}
Tra cứu định nghĩa về nhân viên hỗ trợ
Hãng vận chuyển có thể truy xuất thông tin của một hãng vận chuyển bằng mã nhận dạng duy nhất (name).
Node.js
const businessCommunicationsApiHelper = require('@google/rbm-businesscommunications'); const privateKey = require('../../resources/businesscommunications-service-account-credentials.json'); businessCommunicationsApiHelper.initBusinessCommunucationsApi(privateKey); businessCommunicationsApiHelper.getAgent(agent[0].name).then((response) => { console.log('Agent details are:'); console.log(JSON.stringify(response.data, null, 2)); }).catch((err) => { console.log(err); });
cURL
curl -v "https://businesscommunications.googleapis.com/v1/brands/-/agents/AGENT ID" \ -H "Content-Type: application/json" \ -H "User-Agent: curl/business-messaging" \ -H "`oauth2l header --json serviceAccount.json businesscommunications`"
Người gọi không nhất thiết phải biết tên đầy đủ của nhân viên hỗ trợ, bao gồm cả tên thương hiệu.
Bạn chỉ cần mã nhân viên hỗ trợ (trước @rbm.goog), với tên thương hiệu được đặt thành -.
Mã này trả về thông tin về tác nhân:
{
"name": "brands/40bd963f-ff92-425c-b273-8f0892d2d017/agents/my_new_agent_4fpd1psz_agent",
"displayName": "My new agent",
"rcsBusinessMessagingAgent": {
"description": "This is the agent description that will be displayed in the Agent info tab in Messages",
"logoUri": "https://agent-logos.storage.googleapis.com/_/kt90w53vzw2QSxK6PG1uCeJf",
"heroUri": "https://agent-logos.storage.googleapis.com/_/kt90vzob74GQcfeHoEQbVRTP",
"phoneNumbers": [
{
"phoneNumber": {
"number": "+12223334444"
},
"label": "Call support"
}
],
"privacy": {
"uri": "https://policies.google.com/privacy",
"label": "Our privacy policy"
},
"termsConditions": {
"uri": "https://policies.google.com/terms",
"label": "Our Terms and Conditions"
},
"color": "#0B78D0",
"billingConfig": {
"billingCategory": "NON_CONVERSATIONAL"
},
"agentUseCase": "MULTI_USE",
"hostingRegion": "NORTH_AMERICA",
"partner": {
"partnerId": "unique-identifier-for-my-partner",
"displayName": "My partner",
"company": "Public name of the company for my partner"
}
}
}
Thay đổi trạng thái ra mắt nhân viên hỗ trợ
Hãng vận chuyển có thể cập nhật trạng thái ra mắt của nhân viên hỗ trợ và thêm một bình luận giải thích lý do thay đổi trạng thái.
Bạn nên thay đổi trạng thái như sau:
LAUNCH_STATE_PENDINGđếnLAUNCH_STATE_LAUNCHEDhoặcLAUNCH_STATE_REJECTEDLAUNCH_STATE_LAUNCHEDđếnLAUNCH_STATE_SUSPENDEDLAUNCH_STATE_SUSPENDEDđếnLAUNCH_STATE_LAUNCHEDhoặcLAUNCH_STATE_UNLAUNCHED
Người gọi không nhất thiết phải biết tên đầy đủ của nhân viên hỗ trợ, bao gồm cả tên thương hiệu.
Bạn chỉ cần mã nhân viên hỗ trợ (trước @rbm.goog), với tên thương hiệu được đặt thành -.
Node.js
const businessCommunicationsApiHelper = require('@google/rbm-businesscommunications'); const privateKey = require('../../resources/businesscommunications-service-account-credentials.json'); businessCommunicationsApiHelper.initBusinessCommunucationsApi(privateKey); businessCommunicationsApiHelper .updateAgentLaunchState(agentId, 'LAUNCH_STATE_LAUNCHED').then((response) => { console.log('Updated launch details are:'); console.log(JSON.stringify(response.data, null, 2)); });
cURL
curl -v -X PATCH "https://businesscommunications.googleapis.com/v1/brands/-/agents/AGENT ID/launch" \ -H "Content-Type: application/json" \ -H "User-Agent: curl/business-messaging" \ -H "`oauth2l header --json serviceAccount.json businesscommunications`" \ -d "{ 'rcsBusinessMessaging': { 'launchDetails': { '': { 'launchState': 'LAUNCH_STATE_LAUNCHED', } } } }"
Mã này trả về thông tin khởi chạy đã cập nhật với trạng thái khởi chạy đã thay đổi:
{
"name": "brands/40bd963f-ff92-425c-b273-8f0892d2d017/agents/my_new_agent_4fpd1psz_agent/launch",
"rcsBusinessMessaging": {
"questionnaire": {
"contacts": [
{
"name": "John Doe",
"title": "Contact manager",
"email": "john.doe@gmail.com"
}
],
"optinDescription": "Users accepted our terms of service online.",
"triggerDescription": "We are reaching pre-registered users",
"interactionsDescription": "This agent sends notifications and processes suggested replies.",
"optoutDescription": "Reply stop and we stop.",
"agentAccessInstructions": "This is a simple agent that reaches registered users.",
"videoUris": [
"https://www.google.com/a/video"
],
"screenshotUris": [
"https://www.google.com/a/screenshot"
]
},
"launchDetails": {
"/v1/regions/thecarrier": {
"launchState": "LAUNCH_STATE_REJECTED",
"comment": "We don't have a billing contract in place with you.", // Note: The field is optional only for launch approval; otherwise, required.
"updateTime": "2023-04-28T15:22:10.221191Z"
}
}
}
}
Ẩn hoặc hiện nhân viên hỗ trợ
Để duy trì một không gian làm việc gọn gàng và ngăn nắp, bạn có thể ẩn những tác nhân không còn được sử dụng trên mạng của mình. Việc ẩn một tác nhân sẽ xoá tác nhân đó khỏi kết quả khám phá API mặc định.
Ẩn là một thay đổi chỉ về chế độ hiển thị. Chế độ này chỉ ảnh hưởng đến chế độ xem của hãng vận chuyển cụ thể và không ảnh hưởng đến trạng thái của nhân viên đối với đối tác hoặc các hãng vận chuyển khác. Bạn có thể hiện một tác nhân bất cứ lúc nào để khôi phục chế độ hiển thị và tiếp tục quản lý tác nhân đó.
Để đảm bảo rằng các tác nhân đang hoạt động không bị xoá khỏi chế độ xem một cách vô tình, các quy tắc sau sẽ được áp dụng:
- Điều kiện: Bạn chỉ có thể ẩn những nhân viên đang ở trạng thái không hoạt động trên mạng của mình: Bị tạm ngưng hoặc Bị từ chối.
- Hạn chế: Bạn không thể ẩn một tác nhân nếu trạng thái ra mắt của tác nhân đó trên mạng của bạn là Đã ra mắt hoặc Đang chờ ra mắt. Nếu bạn cố gắng ẩn một tác nhân như vậy, yêu cầu sẽ bị từ chối kèm theo lỗi
FAILED_PRECONDITION.
Cập nhật trạng thái ẩn
Để ẩn hoặc hiện một lần khởi chạy tác nhân cho hãng vận chuyển của bạn, hãy dùng phương thức setAgentLaunchVisibility trên tài nguyên khởi chạy. Để ẩn, hãy đặt giá trị boolean isHidden thành true và để hiện, hãy đặt giá trị này thành false.
Phương thức:
POST /v1/brands/{brandId}/agents/{agentId}/launch:setAgentLaunchVisibility
curl -v -X POST "https://businesscommunications.googleapis.com/v1/brands/$BRAND_ID/agents/$AGENT_ID/launch:setAgentLaunchVisibility" \
-H "Content-Type: application/json" \
-H "User-Agent: curl/business-messaging" \
-H "$(oauth2l header --json serviceAccount.json businesscommunications)" \
--data '{
"name": "brands/$BRAND_ID/agents/$AGENT_ID/launch",
"isHidden": true
}'
{
"name": "brands/8b5c7f80-b025-486b-bc8a-2d0797559711/agents/my-agent-demo/launch",
"rcsBusinessMessaging": {
"questionnaire": {
"contacts": [
{
"name": "John Doe",
"title": "Mr",
"email": "johndoe@developer.com"
}
],
"optinDescription": "Messages are sent to known MSISDNs",
"triggerDescription": "We respond to any interaction",
"interactionsDescription": "Simple conversations with a chatbot",
"optoutDescription": "User sends stop"
},
"launchDetails": {
"/v1/regions/thecarrier": {
"launchState": "LAUNCH_STATE_SUSPENDED",
"updateTime": "2026-02-20T15:10:36.528669Z",
"isHidden": true
}
}
}
}
Liệt kê các tác nhân bằng bộ lọc
Theo mặc định, phương thức list sẽ loại trừ những nhân viên hỗ trợ bị nhà mạng ẩn. Để đưa các kết quả này vào, hãy sử dụng tham số includeHidden.
Xoá một nhân viên hỗ trợ
Vì lý do bảo mật, bạn không thể xoá nhân viên hỗ trợ RBM nữa. Để được trợ giúp, hãy liên hệ với nhóm hỗ trợ RCS for Business.