ตัวแทนทั้งหมดเป็นของแบรนด์ (ธุรกิจ องค์กร หรือกลุ่ม) คุณต้องสร้างแบรนด์ที่เป็นเจ้าของก่อนจึงจะสร้างตัวแทนได้ แบรนด์มีไว้เพื่อการจัดระเบียบเท่านั้น เพื่อช่วยให้คุณจัดกลุ่มตัวแทนที่เกี่ยวข้องไว้ด้วยกัน
ข้อมูลโค้ดในหน้านี้นำมาจากตัวอย่าง Java และตัวอย่าง Node.js
สร้างตัวแทน
หากต้องการสร้างตัวแทน RBM คุณต้องกําหนดข้อมูลพื้นฐานของตัวแทน ดูรายละเอียดเพิ่มเติมได้ที่ brands.agents.create
Node.js
const businessCommunicationsApiHelper = require('@google/rbm-businesscommunications'); const privateKey = require('../../resources/businesscommunications-service-account-credentials.json'); businessCommunicationsApiHelper.initBusinessCommunucationsApi(privateKey); const newAgentDetails = { displayName: 'My new agent', name: brandId + '/agents/', 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' } ], // It's recommended to provide at least one contact method (phone or email) because // this is required for launch. For any phone, email, or website provided, a corresponding label // must also be included. 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: 'BASIC_MESSAGE' }, agentUseCase: 'TRANSACTIONAL', hostingRegion: 'EUROPE' } }; businessCommunicationsApiHelper.createAgent(brandId, newAgentDetails).then((response) => { }).catch((err) => { console.log(err); });
Java
Brand brand = api.getBrand(brandId); logger.info("Brand to operate on: " + brand); String displayName = flags.getOrDefault("agent_name", "Test RBM Agent: " + now.getSecond()); String suffix = flags.getOrDefault("agent_data_suffix", "API"); RcsBusinessMessagingAgent agentData = AgentFactory.createRbmAgent(suffix); Agent agent = api.createRbmAgent(brand, displayName, agentData); logger.info("RBM agent has been created: " + agent);
รหัสนี้จะแสดงข้อมูลตัวแทนใหม่และตัวระบุที่ไม่ซ้ำกันซึ่งกำหนดให้กับตัวแทน
{
name: 'brands/40bd963f-ff92-425c-b273-8f0892d2d017/agents/my_new_agent_dxuewtvy_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: [ [Object] ],
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: 'BASIC_MESSAGE' },
agentUseCase: 'MULTI_USE',
hostingRegion: 'EUROPE'
}
}
ค้นหาคำจำกัดความของตัวแทน
คุณสามารถเรียกข้อมูลตัวแทนได้โดยระบุตัวระบุที่ไม่ซ้ำกัน (name
) ดูรายละเอียดเพิ่มเติมได้ที่ brands.agents.list
Node.js
const businessCommunicationsApiHelper = require('@google/rbm-businesscommunications'); const privateKey = require('../../resources/businesscommunications-service-account-credentials.json'); businessCommunicationsApiHelper.initBusinessCommunucationsApi(privateKey); // Retrieve details of the first agent (if one has already been created) businessCommunicationsApiHelper.getAgent(agent.name).then((response) => { }).catch((err) => { console.log(err); });
Java
Agent agent = api.getAgent(flags.get("agent_id")); logger.info("Agent: " + agent);
รหัสนี้จะแสดงข้อมูลตัวแทน
{
name: 'brands/40bd963f-ff92-425c-b273-8f0892d2d017/agents/my_new_agent_dxuewtvy_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: [ [Object] ],
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: 'BASIC_MESSAGE' },
agentUseCase: 'MULTI_USE',
hostingRegion: 'EUROPE'
}
}
ส่งข้อมูลการยืนยัน
คุณต้องยืนยันแบรนด์เพื่อเปิดตัวตัวแทน คุณต้องส่งข้อมูลการยืนยันก่อนส่งคําขอเปิดใช้งาน โปรดทราบว่าคุณไม่จําเป็นต้องรอการอนุมัติการใช้แบรนด์ก่อนส่งคําขอเปิดตัว การอนุมัติการใช้แบรนด์เป็นส่วนหนึ่งของกระบวนการอนุมัติการเปิดตัว
ดูรายละเอียดเพิ่มเติมได้ที่ brands.agents.requestVerification
Node.js
const businessCommunicationsApiHelper = require('@google/rbm-businesscommunications'); const privateKey = require('../../resources/businesscommunications-service-account-credentials.json'); businessCommunicationsApiHelper.initBusinessCommunucationsApi(privateKey); let agentVerificationContact = { partnerName: 'Alice', partnerEmailAddress: 'alice@thepartner.com', brandContactName: 'Bob', brandContactEmailAddress: 'bob@thebrand.com', brandWebsiteUrl: 'https://thebrand.com/' }; businessCommunicationsApiHelper.verifyAgent(agent.name, agentVerificationContact).then((response) => { }).catch((err) => { console.log(err); });
Java
AgentVerificationContact contact = AgentFactory.createRbmAgentVerification(); AgentVerification verification = api.requestAgentVerification(agent.getName(), contact); logger.info("Verification requested: " + verification);
รหัสนี้จะแสดงข้อมูลการยืนยัน
{
"name": "brands/40bd963f-ff92-425c-b273-8f0892d2d017/agents/my_new_agent_ciymyd2b_agent",
"verificationState": "VERIFICATION_STATE_UNVERIFIED",
"agentVerificationContact": {
"partnerName": "Alice",
"partnerEmailAddress": "alice@thepartner.com",
"brandContactName": "Bob",
"brandContactEmailAddress": "bob@thebrand.com",
"brandWebsiteUrl": "https://thebrand.com/"
}
}
ค้นหาข้อมูลการยืนยันของตัวแทน
คุณดูสถานะการยืนยันแบรนด์ของตัวแทนได้ ดูรายละเอียดเพิ่มเติมได้ที่ 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(agent.name).then((response) => { }).catch((err) => { console.log(err); });
Java
AgentVerification verification = api.getAgentVerification(agent.getName()); logger.info("RBM agent verification: " + verification);
รหัสนี้จะแสดงสถานะการยืนยันและข้อมูลพาร์ทเนอร์
{
"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"
}
}
ส่งตัวแทนเพื่อเปิดใช้งาน
คุณส่งตัวแทนเพื่อเปิดตัวในผู้ให้บริการอย่างน้อย 1 รายได้ การเปิดตัวบางรายการได้รับการจัดการโดย Google ส่วนการเปิดตัวอื่นๆ ได้รับการจัดการโดยผู้ให้บริการโดยตรง การเปิดตัวที่จัดการโดยผู้ให้บริการเครือข่ายอาจมีข้อกำหนดเพิ่มเติม ดูข้อมูลเพิ่มเติมที่หัวข้อการเปิดตัวที่จัดการโดย Google เทียบกับการเปิดตัวที่จัดการโดยผู้ให้บริการเครือข่าย
คุณต้องส่งข้อมูลการยืนยันก่อนจึงจะเปิดใช้งานตัวแทนได้เป็นครั้งแรก ซึ่งจะช่วยให้ Google, ผู้ให้บริการ หรือทั้ง 2 ฝ่ายยืนยันกับผู้ติดต่อของแบรนด์ว่าคุณได้รับอนุญาตให้จัดการตัวแทนในนามของแบรนด์ โปรดดูรายละเอียดที่หัวข้อการยืนยันตัวตนของแบรนด์
เมื่อส่งข้อมูลการยืนยันและดำเนินการตามข้อกําหนดเบื้องต้นในการเปิดตัวเรียบร้อยแล้ว คุณจะส่งคําขอเปิดตัวได้
คุณส่งตัวแทนเพื่อเปิดตัวในผู้ให้บริการอย่างน้อย 1 รายได้ คุณต้องส่งแบบสอบถามการเปิดใช้งานที่กรอกข้อมูลครบถ้วนเป็นส่วนหนึ่งของคำขอเปิดใช้งาน ดูรายละเอียดเพิ่มเติมได้ที่ brands.agents.requestLaunch
Node.js
const businessCommunicationsApiHelper = require('@google/rbm-businesscommunications'); const privateKey = require('../../resources/businesscommunications-service-account-credentials.json'); businessCommunicationsApiHelper.initBusinessCommunucationsApi(privateKey); let agentLaunch = { questionnaire: { contacts: [ { name: 'James Bond', title: 'Mr 0 0 7', email: 'someone@somewhere.com' } ], optinDescription: 'Users accepted our terms of service online.', triggerDescription: 'We are reaching preregistered users', interactionsDescription: 'This agent does not do much.', optoutDescription: 'Reply stop and we stop.', agentAccessInstructions: 'This is a a simple agent that reaches registered users.', videoUris: [ 'https://www.google.com/a/video' ], screenshotUris: [ 'https://www.google.com/a/screenshot' ] }, launchDetails: {} }; businessCommunicationsApiHelper.launchAgent(agent.name, agentLaunch).then((response) => { }).catch((err) => { console.log(err); });
Java
Optional<Questionnaire> q = Optional.of(AgentFactory.createRbmQuestionnaire()); AgentLaunch launch = api.requestRbmAgentLaunch(agent.getName(), regionIds, q); logger.info("RBM agent updated launch: " + launch);
โค้ดนี้จะแสดงข้อมูลการเริ่มทํางานของตัวแทน
{
"name": "brands/40bd963f-ff92-425c-b273-8f0892d2d017/agents/my_new_agent_7jo0trhw_agent/launch",
"rcsBusinessMessaging": {
"questionnaire": {
"contacts": [
{
"name": "James Bond",
"title": "Mr O O 7",
"email": "someone@somewhere.com"
}
],
"optinDescription": "Users accepted our terms of service online.",
"triggerDescription": "We are reaching preregistered users",
"interactionsDescription": "This agent does not do much.",
"optoutDescription": "Reply stop and we stop.",
"agentAccessInstructions": "This is a a simple agent that reaches registered users.",
"videoUris": [
"https://www.google.com/a/video"
],
"screenshotUris": [
"https://www.google.com/a/screenshot"
]
},
"launchDetails": {
"/v1/regions/some-carrier": {
"launchState": "LAUNCH_STATE_PENDING",
"updateTime": "2023-02-24T15:02:13.903554Z"
}
},
"launchRegion": "NORTH_AMERICA"
}
}
โปรดทราบว่า launchRegion
เลิกใช้งานแล้วและมีกำหนดการจะนำออกในเร็วๆ นี้
ค้นหาสถานะการเปิดใช้งานของตัวแทน
คุณสามารถเรียกดูสถานะการเปิดตัวปัจจุบันของตัวแทนได้ ดูรายละเอียดเพิ่มเติมได้ที่ brands.agents.getLaunch
Node.js
const businessCommunicationsApiHelper = require('@google/rbm-businesscommunications'); const privateKey = require('../../resources/businesscommunications-service-account-credentials.json'); businessCommunicationsApiHelper.initBusinessCommunucationsApi(privateKey); businessCommunicationsApiHelper.getAgentLaunch(agent.name).then((response) => { }).catch((err) => { console.log(err); });
Java
AgentLaunch launch = api.getAgentLaunch(agent.getName()); logger.info("RBM agent launch: " + launch);
โค้ดนี้จะแสดงข้อมูลการเปิดตัวและสถานะการเปิดตัวสำหรับผู้ให้บริการเป้าหมายแต่ละราย
{
"name": "brands/40bd963f-ff92-425c-b273-8f0892d2d017/agents/my_new_agent_7jo0trhw_agent/launch",
"rcsBusinessMessaging": {
"questionnaire": {
"contacts": [
{
"name": "James Bond",
"title": "Mr O O 7",
"email": "someone@somewhere.com"
}
],
"optinDescription": "Users accepted our terms of service online.",
"triggerDescription": "We are reaching preregistered users",
"interactionsDescription": "This agent does not do much.",
"optoutDescription": "Reply stop and we stop.",
"agentAccessInstructions": "This is a a simple agent that reaches registered users.",
"videoUris": [
"https://www.google.com/a/video"
],
"screenshotUris": [
"https://www.google.com/a/screenshot"
]
},
"launchDetails": {
"/v1/regions/some-carrier": {
"launchState": "LAUNCH_STATE_PENDING",
"updateTime": "2023-02-24T15:02:13.903554Z"
}
},
"launchRegion": "NORTH_AMERICA"
}
}
โปรดทราบว่า launchRegion
เลิกใช้งานแล้วและกำหนดเวลาให้นำออกในเร็วๆ นี้
เพิ่มผู้ให้บริการรายอื่นในการเปิดตัวของตัวแทน
หลังจากเรียกข้อมูลการเปิดตัวปัจจุบันของตัวแทนโดยใช้brands.agents.getLaunch
การเรียก API แล้ว คุณสามารถเพิ่มผู้ให้บริการเป้าหมายเพิ่มเติมเพื่อขยายการเข้าถึงของตัวแทนได้ ดูรายละเอียดเพิ่มเติมได้ที่ brands.agents.updateLaunch
Node.js
const businessCommunicationsApiHelper = require('@google/rbm-businesscommunications'); const privateKey = require('../../resources/businesscommunications-service-account-credentials.json'); businessCommunicationsApiHelper.initBusinessCommunucationsApi(privateKey);'); // To launch an agent to further carriers, we need to first obtain the existing // launch information and extend it with the new carrier(s). businessCommunicationsApiHelper.getAgentLaunch(agent.name).then((response) => { let existingLaunch = response.data.rcsBusinessMessaging; // Now we add the new carrier to the existing launch existingLaunch.launchDetails[config.launchCarrier2] = null; // And we submit the launch again businessCommunicationsApiHelper.launchAgent(agent.name, existingLaunch).then((response) => { console.log('Launch details are:'); console.log(JSON.stringify(response.data, null, 2)); }).catch((err) => { console.log(err); }); }).catch((err) => { console.log(err); });
โค้ดนี้จะแสดงข้อมูลการเปิดตัวที่อัปเดต
{
"name": "brands/40bd963f-ff92-425c-b273-8f0892d2d017/agents/my_new_agent_7jo0trhw_agent/launch",
"rcsBusinessMessaging": {
"questionnaire": {
"contacts": [
{
"name": "James Bond",
"title": "Mr O O 7",
"email": "someone@somewhere.com"
}
],
"optinDescription": "Users accepted our terms of service online.",
"triggerDescription": "We are reaching preregistered users",
"interactionsDescription": "This agent does not do much.",
"optoutDescription": "Reply stop and we stop.",
"agentAccessInstructions": "This is a a simple agent that reaches registered users.",
"videoUris": [
"https://www.google.com/a/video"
],
"screenshotUris": [
"https://www.google.com/a/screenshot"
]
},
"launchDetails": {
"/v1/regions/some-carrier": {
"launchState": "LAUNCH_STATE_PENDING",
"updateTime": "2023-02-24T15:02:13.903554Z"
},
"/v1/regions/another-carrier": {
"launchState": "LAUNCH_STATE_PENDING",
"updateTime": "2023-02-24T15:04:50.456552Z"
}
},
"launchRegion": "NORTH_AMERICA"
}
}
แสดงรายการตัวแทนทั้งหมดที่สร้างสำหรับแบรนด์
นักพัฒนาแอปสามารถเรียกข้อมูลรายการตัวแทนทั้งหมดที่สร้างไว้สำหรับแบรนด์หนึ่งๆ ได้
ดูรายละเอียดเพิ่มเติมได้ที่ brands.agents.list
Node.js
const businessCommunicationsApiHelper = require('@google/rbm-businesscommunications'); const privateKey = require('../../resources/businesscommunications-service-account-credentials.json'); businessCommunicationsApiHelper.initBusinessCommunucationsApi(privateKey); businessCommunicationsApiHelper.listAgents(brand.name).then((response) => { console.log('Current agents are:'); console.log(response.data); datastore.saveJsonData('agents', response.data.agents); }).catch((err) => { console.log(err); });
Java
Brand brand = api.getBrand(brandId); logger.info("Brand: " + brand); ListAgentsResponse response = api.listAllAgents(brand); List<Agent> agents = response.getAgents().stream() .sorted(Comparator.comparing(Agent::getName)).collect(Collectors.toList()); logger.info(String.format("Found %d agents", response.getAgents().size())); for (Agent agent : agents) { logger.info(String.format("Agent [%s]: '%s'", agent.getName(), agent.getDisplayName())); }
รหัสนี้จะแสดงรายการตัวแทนทั้งหมดที่แบรนด์เป็นเจ้าของ
{
agents: [
{
name: 'brands/40bd963f-ff92-425c-b273-8f0892d2d017/agents/my_new_agent_4fpd1psz_agent',
displayName: 'My new agent',
rcsBusinessMessagingAgent: [Object]
},
{
name: 'brands/40bd963f-ff92-425c-b273-8f0892d2d017/agents/my_new_agent_ciymyd2b_agent',
displayName: 'My second agent',
rcsBusinessMessagingAgent: [Object]
},
{
name: 'brands/40bd963f-ff92-425c-b273-8f0892d2d017/agents/my_new_agent_helof85o_agent',
displayName: 'My third agent',
rcsBusinessMessagingAgent: [Object]
}
]
}
ลบตัวแทน
คุณจะลบตัวแทน RBM ไม่ได้อีกต่อไปเนื่องด้วยเหตุผลด้านความปลอดภัย โปรดติดต่อทีมสนับสนุนของ RBM เพื่อขอความช่วยเหลือ