จัดการ Agent

ตัวแทนทั้งหมดเป็นของแบรนด์ (ธุรกิจ องค์กร หรือกลุ่ม) คุณต้องสร้างแบรนด์ที่เป็นเจ้าของก่อนจึงจะสร้างตัวแทนได้ แบรนด์เป็นเพียงองค์กรที่ช่วยให้คุณจัดกลุ่มตัวแทนที่เกี่ยวข้องเข้าด้วยกัน

ข้อมูลโค้ดในหน้านี้มาจากตัวอย่าง Java และตัวอย่าง Node.js

การสร้างและกำหนดตัวแทน

สร้างตัวแทน

หากต้องการสร้างตัวแทน RBM คุณต้องกำหนด ข้อมูลพื้นฐานของตัวแทน

ดูรายละเอียดเพิ่มเติมได้ที่ brands.agents.create

การผสานรวม API ได้ที่ คำถามที่พบบ่อยเกี่ยวกับการเรียกเก็บเงิน

cURL

curl -v -X POST "https://businesscommunications.googleapis.com/v1/$BRAND_ID/agents" \
  -H "Content-Type: application/json" \
  -H "User-Agent: curl/business-messaging" \
  -H "`oauth2l header --json rbm-developer-service-account-credentials.json businesscommunications`" \
  -d "{
    'displayName': 'My test agent',
    'rcsBusinessMessagingAgent': {
      'description': 'My agent description',
      'logoUri': 'https://agent-logos.storage.googleapis.com/_/kt90w53vzw2QSxK6PG1uCeJf',
      'heroUri': 'https://agent-logos.storage.googleapis.com/_/kt90vzob74GQcfeHoEQbVRTP',
      'phoneNumbers': [
        {
            'phoneNumber': {
                'number': '+44800088088'
            },
            'label': 'My number'
        }
      ],
      'emails': [
        {
            'address': 'support@demo.test',
            'label': 'My email'
        }
      ],
      'websites': [
        {
            'uri': 'https://a.demo.test/',
            'label': 'My site'
        }
      ],
      'privacy': {
        'uri': 'https://a.demo.test/privacy',
        'label': 'My privacy policy'
      },
      'termsConditions': {
        'uri': 'https://a.demo.test/terms',
        'label': 'My terms'
      },
      'color': '#FFFFFF',
      'billingConfig': {
        'billingCategory': 'CONVERSATIONAL'
      },
      'agentUseCase': 'TRANSACTIONAL',
      'hostingRegion': 'EUROPE'
    }
  }"
โค้ดนี้เป็นข้อมูลบางส่วนจากตัวอย่าง RBM Management API

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: 'NON_CONVERSATIONAL' },
    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: 'NON_CONVERSATIONAL' },
    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: 'NON_CONVERSATIONAL' },
    agentUseCase: 'MULTI_USE',
    hostingRegion: 'EUROPE'
  }
}

การยืนยันและการเปิดใช้งาน

ส่งข้อมูลการยืนยัน

คุณต้องยืนยันแบรนด์ ก่อนจึงจะเปิดใช้งานตัวแทนได้ คุณต้องส่งข้อมูลการยืนยันก่อนส่งคำขอเปิดใช้งาน โปรดทราบว่าคุณไม่จำเป็นต้องรอการอนุมัติแบรนด์ก่อนส่งคำขอเปิดใช้งาน โดยการอนุมัติแบรนด์จะเป็นส่วนหนึ่งของกระบวนการอนุมัติการเปิดใช้งาน สำหรับผู้ให้บริการบางราย คุณต้องระบุโทเค็นการยืนยันที่ถูกต้องซึ่งออกโดยหน่วยงานออกใบรับรองด้วย

ดูรายละเอียดเพิ่มเติมได้ที่ brands.agents.requestVerification

cURL

curl -v "https://businesscommunications.googleapis.com/v1/brands/$BRAND_ID/agents/$AGENT_ID:requestVerification" \
-H "Content-Type: application/json" \
-H "x-http-method-override: POST" \
-H "User-Agent: curl/business-messaging" \
-H "$(oauth2l header --json PATH_TO_SERVICE_ACCOUNT_KEY businesscommunications)" \
-d "{
  'agentVerificationContact': {
     ...
   },
   'agentVerificationToken':
     {'tokenBase64Encoded': '$TOKEN'}
}"

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/"
  },
  "agentVerificationTokens": [
    {
      "verificationAuthorityDisplayName": "Example Verification Authority",
      "expirationTime": "2027-06-16T13:45:14Z",
      "status": "ACTIVE",
      "countryCode": "US",
      "tokenBase64Encoded": "...",
      "certificateChainUri": "https://rbm.goog/certificates?v=5&kid=6CAE185529AABAC216565E99A8DE22504B086209"
    }
  ]
}

ค้นหาข้อมูลการยืนยันของตัวแทน

คุณสามารถดึงข้อมูลสถานะการยืนยันแบรนด์ของตัวแทนได้ ดูรายละเอียดเพิ่มเติมได้ที่ ดู 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"
  },
  "agentVerificationTokens": [
    {
      "verificationAuthorityDisplayName": "Example Verification Authority",
      "expirationTime": "2027-06-16T13:45:14Z",
      "status": "ACTIVE",
      "countryCode": "US",
      "tokenBase64Encoded": "...",
      "certificateChainUri": "https://rbm.goog/certificates?v=5&kid=6CAE185529AABAC216565E99A8DE22504B086209"
    }
  ]
}

อัปเดตและลบโทเค็นการยืนยัน

หากมีตัวแทนที่เปิดใช้งานอยู่แล้ว คุณสามารถอัปเดตตัวแทนด้วยโทเค็นการยืนยันได้ หากต้องการเพิ่มหรืออัปเดตโทเค็น ให้เรียกใช้เมธอด updateVerification (โดยใช้คำขอ PATCH) และระบุมาสก์การอัปเดต agent_verification_tokens

cURL

curl -v -X PATCH "https://businesscommunications.googleapis.com/v1/brands/$BRAND_ID/agents/$AGENT_ID/verification?updateMask=agent_verification_tokens" \
-H "Content-Type: application/json" \
-H "x-http-method-override: PATCH" \
-H "User-Agent: curl/business-messaging" \
-H "$(oauth2l header --json PATH_TO_SERVICE_ACCOUNT_KEY businesscommunications)" \
-d "{
   'agentVerificationTokens': [
     {'tokenBase64Encoded': '$TOKEN'}
   ]
}"

หากตัวแทนของคุณเปิดใช้งานในหลายประเทศ คุณอาจต้องระบุโทเค็นหลายรายการ (1 รายการต่อ 1 ประเทศ) ที่ออกโดยหน่วยงานออกใบรับรองที่ได้รับอนุมัติสำหรับภูมิภาคเหล่านั้น หากต้องการระบุโทเค็นเพิ่มเติม ให้เรียกใช้เมธอด updateVerification และระบุโทเค็นทั้งหมดที่คุณต้องการเชื่อมโยงกับตัวแทน รวมถึงโทเค็นที่เชื่อมโยงกับตัวแทนอยู่แล้ว

หากต้องการลบโทเค็นทั้งหมดที่เชื่อมโยงกับตัวแทน ให้ส่งรายการที่ว่างเปล่าในคำขอ PATCH

cURL

curl -v -X PATCH "https://businesscommunications.googleapis.com/v1/brands/$BRAND_ID/agents/$AGENT_ID/verification?updateMask=agent_verification_tokens" \
-H "Content-Type: application/json" \
-H "x-http-method-override: PATCH" \
-H "User-Agent: curl/business-messaging" \
-H "$(oauth2l header --json PATH_TO_SERVICE_ACCOUNT_KEY businesscommunications)" \
-d "{}"

การแก้ปัญหาข้อผิดพลาดของโทเค็นการยืนยัน

เมื่อจัดการโทเค็นการยืนยันและขอเปิดใช้งาน คุณอาจพบข้อผิดพลาดต่อไปนี้

  • ไม่มีโทเค็นสำหรับการเปิดใช้งาน: หากคุณขอเปิดใช้งานกับผู้ให้บริการที่ ต้องใช้โทเค็น แต่ตัวแทนไม่มีโทเค็น คุณจะได้รับ 400 error (เช่น "Verification token matching agent <...> and carrier country US is missing")
  • ข้อมูลตัวแทนไม่ตรงกัน: รหัสตัวแทน ชื่อตัวแทน โลโก้ และแบนเนอร์ใน โปรไฟล์ของตัวแทนต้องตรงกับข้อมูลที่ฝังอยู่ในโทเค็นทุกประการ หากคุณ พยายามแนบโทเค็นที่ไม่ตรงกัน หรือขอเปิดใช้งานด้วยโทเค็นที่ไม่ตรงกัน คุณจะได้รับ 400 error (เช่น "Agent ID mismatch. Request agent ID: <...>, Token agent ID: <...>")

ส่งตัวแทนเพื่อขอเปิดใช้งาน

คุณสามารถส่งตัวแทนเพื่อขอเปิดใช้งานกับผู้ให้บริการอย่างน้อย 1 ราย Google จะจัดการการเปิดใช้งานบางรายการ และผู้ให้บริการจะจัดการการเปิดใช้งานอื่นๆ โดยตรง การเปิดใช้งานที่ผู้ให้บริการจัดการอาจมีข้อกำหนดเพิ่มเติม ดูข้อมูลเพิ่มเติมได้ที่ การเปิดใช้งานที่ Google จัดการเทียบกับการเปิดใช้งานที่ผู้ให้บริการจัดการ

คุณต้อง ส่งข้อมูลการยืนยันก่อนจึงจะเปิดใช้งานตัวแทนเป็นครั้งแรกได้ ซึ่งจะช่วยให้ Google ผู้ให้บริการ หรือทั้ง 2 ฝ่ายยืนยันกับผู้ติดต่อของแบรนด์ได้ว่าคุณได้รับอนุญาตให้จัดการตัวแทนในนามของแบรนด์ ดูรายละเอียดได้ที่ การยืนยันแบรนด์

เมื่อส่งข้อมูลการยืนยันและทำตาม ข้อกำหนดเบื้องต้นในการเปิดใช้งาน, เสร็จแล้ว คุณจะส่งคำขอเปิดใช้งานได้

คุณสามารถส่งตัวแทนเพื่อขอเปิดใช้งานกับผู้ให้บริการอย่างน้อย 1 ราย คุณต้องส่งแบบสอบถามการเปิดใช้งานที่กรอกข้อมูลครบถ้วนแล้วเป็นส่วนหนึ่งของคำขอเปิดใช้งาน ดูรายละเอียดเพิ่มเติมได้ที่ brands.agents.requestLaunch

cURL

curl -v -X POST "https://businesscommunications.googleapis.com/v1/$AGENT_ID:requestLaunch" \
  -H "Content-Type: application/json" \
  -H "User-Agent: curl/business-messaging" \
  -H "`oauth2l header --json rbm-developer-service-account-credentials.json businesscommunications`" \
  -d "{
    'agentLaunch': {
      'rcsBusinessMessaging': {
        'questionnaire': {
          'contacts': [
            {
              'name': 'John Doe',
              'title': 'Product Owner',
              'email': 'support@demo.test'
            }
          ],
          'optinDescription': 'Thanks for your request.',
          'triggerDescription': 'Promotional messages will be triggered in a timely manner.',
          'interactionsDescription': 'Promotional messages are one way.',
          'optoutDescription': 'Sorry to see you go.',
          'agentAccessInstructions': 'Thanks for your request.',
          'videoUris': [
            'https://d2q4iodazzzt8b.cloudfront.net/MicrosoftTeamsvideo2_1758533835.mp4'
          ],
          'screenshotUris': [
            'https://rm.virbm.com/Il9ChvVEhS1na5mr/ee9bc94b468a40688fb7fc71cb1c069c.png'
          ]
        },
        'launchDetails': {
          '/v1/regions/$CARRIER_ID': {}
        }
      }
    }
  }"
โค้ดนี้เป็นข้อมูลบางส่วนจากตัวอย่าง RBM Management API

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 แล้วและมีกำหนดจะนำออกในเร็วๆ นี้

เปิดใช้งานตัวแทนในภูมิภาคอย่างน้อย 1 ภูมิภาค

หากต้องการเปิดใช้งานตัวแทนในภูมิภาคอย่างน้อย 1 ภูมิภาคเมื่อตัวแทนยังไม่ เคยเปิดใช้งาน มาก่อน ให้เรียกใช้เมธอด requestLaunch ด้วยออบเจ็กต์ที่มีแผนที่ของ คีย์เท่านั้น สำหรับภูมิภาคทั้งหมดที่คุณต้องการให้ตัวแทนเปิดใช้งาน การใช้แผนที่ที่ว่างเปล่าจะช่วยรักษาความสอดคล้องของ API ภายในในออบเจ็กต์ที่ใช้ระหว่างการเรียกใช้ API

curl -X POST \
"https://businesscommunications.googleapis.com/v1/brands/BRAND_ID/agents/AGENT_ID:requestLaunch" \
-H "Content-Type: application/json" \
-H "$(oauth2l header --json PATH_TO_SERVICE_ACCOUNT_KEY businesscommunications)" \
-d "{
  'name': 'brands/BRAND_ID/agents/AGENT_ID/launch',
  'rcsBusinessMessaging': {
    'questionnaire': {
      'contacts': [
        {
          'name': 'Contact person 000',
          'title': 'Contact manager 000',
          'email': 'user@domain.com000'
        }
      ],
      'optinDescription': 'Opt-in description 0',
      'triggerDescription': 'Trigger description 0',
      'optoutDescription': 'Opt-out description 0',
      'agentAccessInstructions': 'Agent instructions 0',
      'videoUris': [
        'https://www.youtube.com/watch?v=NN75im_us4k'
      ],
      'screenshotUris': [
        'https://www.youtube.com/watch?v=NN75im_us4k'
      ]
    },
    'launchDetails': {
      '/v1/regions/fi-rcs': {}
    }
  }
}"

หากต้องการเปิดใช้งานตัวแทนในภูมิภาคอย่างน้อย 1 ภูมิภาค (เมื่อตัวแทน เคย เปิดใช้งาน มาก่อน) ให้เรียกใช้เมธอด requestLaunch ด้วยออบเจ็กต์ที่มีแผนที่ของ คีย์เท่านั้น ของ ทุก ภูมิภาคที่ ตัวแทนเปิดใช้งานอยู่แล้ว และ ทุก ภูมิภาคที่ตัวแทนต้องการเปิดใช้งาน การใช้แผนที่ที่ว่างเปล่าจะช่วยรักษาความสอดคล้องของ API ภายในในออบเจ็กต์ที่ใช้ระหว่างการเรียกใช้ API

curl -X POST \
"https://businesscommunications.googleapis.com/v1/brands/BRAND_ID/agents/AGENT_ID:requestLaunch" \
-H "Content-Type: application/json" \
-H "$(oauth2l header --json PATH_TO_SERVICE_ACCOUNT_KEY businesscommunications)" \
-d "{
  'name': 'brands/BRAND_ID/agents/AGENT_ID/launch',
  'rcsBusinessMessaging': {
    'launchDetails': {
      '/v1/regions/fi-rcs': {},
      '/v1/regions/vodafone-idea-india': {}
    }
  }
}"

หากตัวแทนเรียกใช้เมธอด requestLaunch แต่ไม่ได้ระบุภูมิภาคทั้งหมด ที่ตัวแทนเปิดใช้งานอยู่แล้วเป็นคีย์ ระบบจะแสดงข้อผิดพลาด 400 - Bad Request

ค้นหาสถานะการเปิดใช้งานของตัวแทน

คุณสามารถดึงข้อมูลสถานะการเปิดใช้งานปัจจุบันของตัวแทนได้ ดูรายละเอียดเพิ่มเติมได้ที่ ดู 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);

หากผู้ให้บริการปฏิเสธการเปิดใช้งาน พาร์ทเนอร์จะขอเปิดใช้งานกับผู้ให้บริการอีกครั้งได้ (คำขอมีสถานะ UNSPECIFIED และแบ็กเอนด์มีสถานะ REJECTED)

โค้ดนี้จะแสดงข้อมูลการเปิดใช้งานและสถานะการเปิดใช้งานสำหรับผู้ให้บริการเป้าหมายแต่ละราย

{
  "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]
    }
  ]
}

รวมตัวแทนที่เก็บถาวร

โดยค่าเริ่มต้น รายการตัวแทนทั้งหมดจะไม่รวมตัวแทนที่พาร์ทเนอร์เก็บถาวรไว้ หากต้องการรวมตัวแทนที่เก็บถาวรไว้ในผลลัพธ์ ให้ตั้งค่าพารามิเตอร์ includeArchived เป็น true

Node.js

เมธอด `listAgents` ยอมรับออบเจ็กต์การกำหนดค่าที่ไม่บังคับเพื่อรวม ตัวแทนที่เก็บถาวรไว้
const businessCommunicationsApiHelper =
 require('@google/rbm-businesscommunications');

const privateKey =
 require('../../resources/businesscommunications-service-account-credentials.json');

businessCommunicationsApiHelper.initBusinessCommunicationsApi(privateKey);

// To list all agents including archived ones, set includeArchived to true
const listOptions = {
  includeArchived: true
};

businessCommunicationsApiHelper.listAgents(brand.name, listOptions).then((response) => {
 console.log('Current agents (including archived) are:');
 console.log(response.data);
 datastore.saveJsonData('agents', response.data.agents);
}).catch((err) => {
 console.log(err);
});

Java

เมธอด `listAllAgents` มีพารามิเตอร์บูลีนสำหรับการควบคุมระดับการเปิดเผย
// To list all agents including archived ones, pass 'true' for the includeArchived parameter
boolean includeArchived = true;
Brand brand = api.getBrand(brandId);
logger.info("Brand: " + brand);

// Call listAllAgents with the brand and the includeArchived flag
ListAgentsResponse response = api.listAllAgents(brand, includeArchived);

List agents = response.getAgents().stream()
 .sorted(Comparator.comparing(Agent::getName)).collect(Collectors.toList());

logger.info(String.format("Found %d agents (including archived)", response.getAgents().size()));
for (Agent agent : agents) {
 logger.info(String.format("Agent [%s]: '%s' (Archived: %s)",
    agent.getName(), agent.getDisplayName(), agent.getIsArchived()));
}

ยกเลิกการเปิดใช้งานตัวแทน

หากต้องการยกเลิกการเปิดใช้งานตัวแทนจากภูมิภาคที่เฉพาะเจาะจง ให้เรียกใช้เมธอด updateLaunch ระบุภูมิภาคเป้าหมายในแผนที่ของการเรียกใช้ และตั้งค่า launchState เป็น LAUNCH_STATE_UNLAUNCHED

curl -X PATCH \
"https://businesscommunications.googleapis.com/v1/brands/BRAND_ID/agents/AGENT_ID/launch" \
-H "Content-Type: application/json" \
-H "$(oauth2l header --json PATH_TO_SERVICE_ACCOUNT_KEY businesscommunications)" \
-d "{
  'rcsBusinessMessaging': {
    'launchDetails': {
      '/v1/regions/fi-rcs': {
        'launchState': 'LAUNCH_STATE_UNLAUNCHED'
      },
      '/v1/regions/vodafone-idea-india': {
        'launchState': 'LAUNCH_STATE_UNLAUNCHED'
      }
    }
  }
}"

ลบตัวแทน

ระบบไม่สามารถลบตัวแทน RBM ได้อีกต่อไปเนื่องด้วยเหตุผลด้านความปลอดภัย หากต้องการความช่วยเหลือ โปรดติดต่อทีมสนับสนุน RCS for Business

เก็บหรือยกเลิกการเก็บตัวแทน

คุณสามารถเก็บตัวแทนที่ไม่ได้ใช้งานแล้วเพื่อรักษาพื้นที่ทำงานให้เป็นระเบียบ การเก็บตัวแทนจะซ่อนตัวแทนนั้นจากผลการค้นหา API เริ่มต้น

การเก็บเป็นการเปลี่ยนแปลงระดับการเปิดเผยเท่านั้น โดยจะไม่ลบตัวแทนหรือส่งผลต่อสถานะการเปิดใช้งานที่สำคัญ คุณสามารถยกเลิกการเก็บตัวแทนได้ทุกเมื่อเพื่อกู้คืนระดับการเปิดเผยและจัดการตัวแทนต่อไป

ระบบจะบังคับใช้กฎต่อไปนี้เพื่อให้แน่ใจว่าจะไม่มีการซ่อนตัวแทนที่ใช้งานอยู่โดยไม่ได้ตั้งใจ

  • การมีสิทธิ์: คุณจะเก็บได้เฉพาะตัวแทนที่อยู่ในสถานะไม่ใช้งาน ได้แก่ UNLAUNCHED, SUSPENDED, หรือ REJECTED
  • ข้อจำกัด: คุณจะเก็บตัวแทนที่อยู่ในสถานะ LAUNCHED หรือ PENDING กับผู้ให้บริการรายใดรายหนึ่งไม่ได้ หากพยายามเก็บตัวแทนดังกล่าว ระบบจะปฏิเสธคำขอพร้อมข้อผิดพลาด

อัปเดตสถานะการเก็บ

หากต้องการเก็บหรือยกเลิกการเก็บตัวแทน ให้ใช้เมธอดแพตช์ คุณต้องใส่พารามิเตอร์ updateMask=is_archived ใน URL เพื่อระบุช่องที่จะอัปเดต หากต้องการเก็บ ให้ตั้งค่าบูลีน isArchived เป็น true และหากต้องการยกเลิกการเก็บ ให้ตั้งค่าเป็น false

เมธอด: PATCH /v1/brands/{brandId}/agents/{agentId} เพิ่ม is_archived ลงในมาสก์การอัปเดต

{
  "isArchived": true
}

แสดงรายการตัวแทนพร้อมตัวกรอง

โดยค่าเริ่มต้น เมธอด list จะซ่อนตัวแทนที่เก็บถาวรไว้ หากต้องการรวมตัวแทนดังกล่าวไว้ในผลลัพธ์ ให้ใช้พารามิเตอร์ include_archived

เมธอด: GET /v1/brands/{brandId}/agents?include_archived=true