Aracıları yönet

RCS for Business temsilcisi, markanızı temsil eden ve kullanıcılarla etkileşim kuran sohbet birimidir. RBM Management API'yi kullanarak temsilciler oluşturabilir, bunları doğrulama ve başlatma için gönderebilir ve genel yaşam döngülerini yönetebilirsiniz. Her temsilci bir sahip markaya ait olmalıdır. Bu nedenle, temsilci oluşturmadan önce marka oluşturmanız gerekir.

Bu sayfadaki kod snippet'leri Java örneklerinden ve Node.js örneklerinden alınmıştır.

Ajan oluşturma ve tanımlama

Temsilci oluşturun

RBM temsilcisi oluşturmak için temel bilgilerini tanımlamanız gerekir.

Daha fazla bilgi için brands.agents.create başlıklı makaleyi inceleyin.

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'
    }
  }"
Bu kod, RBM Management API örneğimizden alınmıştır.

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);

Bu kod, yeni aracı bilgilerini ve aracıya atanmış benzersiz tanımlayıcıyı döndürür:

{
  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'
  }
}

Ajan tanımını arama

Benzersiz tanımlayıcısını (name) belirterek bir aracıyı alabilirsiniz. Daha fazla bilgi için brands.agents.list başlıklı makaleyi inceleyin.

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);

Bu kod, aracı bilgilerini döndürür:

{
  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'
  }
}

Doğrulama ve başlatma

Doğrulama bilgilerini gönderme

Ajanın başlatılması için marka doğrulaması gereklidir. Başlatma isteğinde bulunmadan önce doğrulama bilgilerini göndermeniz gerekiyor. Lansman isteğinde bulunmadan önce marka onayını beklemeniz gerekmez. Marka onayı, lansman onayı sürecinin bir parçası olarak verilir. Belirli operatörler için doğrulama yetkilisi tarafından verilmiş geçerli bir doğrulama jetonu da sağlamanız gerekir.

Daha fazla bilgi için brands.agents.requestVerification başlıklı makaleyi inceleyin.

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);

Bu kod, doğrulama bilgilerini döndürür:

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

Bir temsilcinin doğrulama bilgilerini arama

Bir ajanın marka doğrulama durumunu alabilirsiniz. Daha fazla bilgi için brands.agents.getVerification başlıklı makaleyi inceleyin.

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);

Bu kod, doğrulama durumunu ve iş ortağı bilgilerini döndürür:

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

Doğrulama jetonlarını güncelleme ve silme

Halihazırda başlatılmış bir aracınız varsa doğrulama jetonuyla güncelleyebilirsiniz. Jeton eklemek veya güncellemek için updateVerification yöntemini (PATCH isteği kullanarak) çağırın ve agent_verification_tokens güncelleme maskesini belirtin.

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

Ajanınız birden fazla ülkede kullanıma sunuluyorsa bu bölgeler için onaylı doğrulama yetkilileri tarafından verilmiş birden fazla jeton (her ülke için bir tane) belirtmeniz gerekebilir. Ek bir jeton belirtmek için updateVerification yöntemini çağırın ve halihazırda ilişkili olanlar da dahil olmak üzere, aracıyla ilişkilendirmek istediğiniz tüm jetonları sağlayın.

Bir aracıyla ilişkili tüm jetonları silmek için PATCH isteğinizde boş bir liste gönderin:

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

Doğrulama jetonu hatalarını giderme

Doğrulama jetonlarını yönetirken ve lansman isteğinde bulunurken aşağıdaki hatalarla karşılaşabilirsiniz:

  • Lansman için jeton eksik: Jeton gerektiren bir operatörde lansman isteğinde bulunursanız ancak ajanda jeton yoksa 400 error (örneğin, "Verification token matching agent <...> and carrier country US is missing") alırsınız.
  • Eşleşmeyen aracı verileri: Aracı profilinizdeki aracı kimliği, aracı adı, logo ve banner, jetona yerleştirilmiş verilerle tam olarak eşleşmelidir. Eşleşmeyen bir jeton eklemeye çalışırsanız veya eşleşmeyen bir jetonla lansman isteğinde bulunursanız 400 error (örneğin, "Agent ID mismatch. Request agent ID: <...>, Token agent ID: <...>") alırsınız.

Lansman için bir ajan gönderme

Bir veya daha fazla operatörde kullanıma sunulmak üzere bir aracı gönderebilirsiniz. Bazı lansmanlar Google tarafından, bazıları ise doğrudan operatörler tarafından yönetilir. Operatör tarafından yönetilen lansmanlarda ek şartlar olabilir. Daha fazla bilgi için Google tarafından yönetilen lansmanlar ve operatör tarafından yönetilen lansmanlar başlıklı makaleyi inceleyin.

Bir temsilciyi ilk kez başlatmadan önce doğrulama bilgilerini göndermeniz gerekir. Bu sayede Google, operatörler veya her ikisi de marka temsilcinizle iletişime geçerek temsilciyi onlar adına yönetme yetkinizin olduğunu doğrulayabilir. Ayrıntılar için marka doğrulama başlıklı makaleyi inceleyin.

Doğrulama bilgilerini gönderip lansman ön koşullarını tamamladıktan sonra lansman isteği gönderebilirsiniz.

Bir veya daha fazla operatörde kullanıma sunulmak üzere bir aracı gönderebilirsiniz. Tamamlanmış başlatma anketi, başlatma isteğiyle birlikte gönderilmelidir. Daha fazla bilgi için brands.agents.requestLaunch başlıklı makaleyi inceleyin.

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': {}
        }
      }
    }
  }"
Bu kod, RBM Management API örneğimizden alınmıştır.

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);

Bu kod, aracı başlatma bilgilerini döndürür:

{
  "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'nın artık kullanılmadığını ve yakında kaldırılacağını hatırlatırız.

Bir veya daha fazla bölgede temsilci başlatma

Daha önce başlatılmamış bir temsilciyi bir veya daha fazla bölgede başlatmak için requestLaunch yöntemini çağırın. Bu yöntem, temsilcinin başlatılmasını istediğiniz tüm bölgeler için yalnızca anahtarların haritasını içeren bir nesneyle çağrılmalıdır. Boş bir harita kullanmak, API çağrıları arasında kullanılan nesnelerde dahili API tutarlılığını korumaya olanak tanır.

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': {}
    }
  }
}"

Bir temsilciyi bir veya daha fazla bölgede başlatmak için (temsilci daha önce başlatılmışsa) requestLaunch yöntemini çağırın. Bu yöntem, temsilcinin zaten başlatıldığı tüm bölgelerin ve temsilcinin başlatılmak istediği tüm bölgelerin yalnızca anahtarlarını içeren bir harita nesnesiyle çağrılmalıdır. Boş bir harita kullanmak, API çağrıları arasında kullanılan nesnelerde dahili API tutarlılığını korumaya olanak tanır.

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': {}
    }
  }
}"

Bir aracı, requestLaunch yöntemini çağırır ancak aracının zaten başlatıldığı tüm bölgeleri anahtar olarak içermezse 400 - Bad Request hatası verilir.

Bir temsilcinin lansman durumunu arama

Bir aracının mevcut lansman durumunu alabilirsiniz. Daha fazla bilgi için brands.agents.getLaunch başlıklı makaleyi inceleyin.

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);

Lansman operatör tarafından reddedilirse iş ortağı, operatörde tekrar lansman isteğinde bulunabilir (istek UNSPECIFIED durumundadır ve arka uç REJECTED durumundadır).

Bu kod, her hedef operatör için lansman bilgilerini ve lansman durumunu döndürür:

{
  "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'nın desteğinin sonlandırıldığını ve yakında kaldırılacağını hatırlatırız.

Bir ajanın lansmanına ek operatörler ekleme

brands.agents.getLaunch API çağrısını kullanarak temsilcinizin mevcut lansman bilgilerini aldıktan sonra, temsilcinizin erişim alanını genişletmek için daha fazla hedef operatör ekleyebilirsiniz. Daha fazla bilgi için brands.agents.updateLaunch başlıklı makaleyi inceleyin.

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);
});

Bu kod, güncellenen lansman bilgilerini döndürür:

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

Lansman sonrası ve bakım

Bir marka için oluşturulan tüm temsilcileri listeleme

Geliştirici, bir marka için oluşturduğu tüm temsilcilerin listesini alabilir. Daha fazla bilgi için brands.agents.list başlıklı makaleyi inceleyin.

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()));
}

Bu kod, markaya ait tüm temsilcilerin listesini döndürür:

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

Arşivlenmiş temsilcileri dahil et

Varsayılan olarak, tüm ajanların listesinde iş ortağı tarafından arşivlenen ajanlar yer almaz. Arşivlenmiş aracıları sonuçlara dahil etmek için includeArchived parametresini true olarak ayarlayın.

Node.js

`listAgents` yöntemi, arşivlenmiş aracıları dahil etmek için isteğe bağlı bir yapılandırma nesnesi kabul eder.
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` yöntemi, görünürlük kontrolü için bir boole parametresi içerir.
// 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()));
}

Ajanın kullanıma sunulmasını geri alma

Bir aracıyı belirli bir bölgede devre dışı bırakmak için updateLaunch yöntemini çağırın, çağrının haritasında hedef bölgeyi belirtin ve launchState değerini LAUNCH_STATE_UNLAUNCHED olarak ayarlayın.

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'
      }
    }
  }
}"

Temsilci silme

Güvenlik nedeniyle RBM temsilcileri artık silinemez. Yardım için RCS for Business Destek Ekibi ile iletişime geçin.

Aracıları arşivleme veya arşivden çıkarma

Çalışma alanınızın temiz ve düzenli kalması için artık kullanılmayan aracıları arşivleyebilirsiniz. Arşivlenen temsilciler, varsayılan API bulma sonuçlarında gizlenir.

Arşivleme, yalnızca görünürlükle ilgili bir değişikliktir. Bu işlem, temsilciyi silmez veya temel başlatma durumunu etkilemez. Görünürlüğünü geri yüklemek ve yönetime devam etmek için istediğiniz zaman bir ajanın arşivini kaldırabilirsiniz.

Etkin aracıların yanlışlıkla gizlenmemesi için aşağıdaki kurallar geçerlidir:

  • Uygunluk: Yalnızca etkin olmayan durumdaki aracıları arşivleyebilirsiniz: UNLAUNCHED, SUSPENDED veya REJECTED.
  • Kısıtlamalar: Herhangi bir operatörde LAUNCHED veya PENDING olan bir ajanı arşivleyemezsiniz. Böyle bir temsilciyi arşivlemeye çalışırsanız istek hata vererek reddedilir.

Arşiv durumunu güncelleme

Bir aracı arşivlemek veya arşivden çıkarmak için patch yöntemini kullanın. Güncellenen alanı belirtmek için URL'ye updateMask=is_archived parametresini eklemeniz gerekir. Arşivlemek için isArchived boole değerini true, arşivden çıkarmak için ise false olarak ayarlayın.

Yöntem: PATCH /v1/brands/{brandId}/agents/{agentId} Güncelleme maskesine is_archived ekleyin.

{
  "isArchived": true
}

Ajanları filtrelerle listeleme

Varsayılan olarak, list yöntemi arşivlenmiş temsilcileri gizler. Bu öğeleri sonuçlarınıza dahil etmek için include_archived parametresini kullanın.

Yöntem: GET /v1/brands/{brandId}/agents?include_archived=true