आरबीएम ऑपरेशंस एपीआई की मदद से एजेंट मैनेज करें

मोबाइल और इंटरनेट सेवा देने वाली कंपनियों के लिए, आरबीएम के मुख्य वर्कफ़्लो में नए एजेंट के बारे में जानकारी की समीक्षा करना और उन्हें मोबाइल और इंटरनेट सेवा देने वाली कंपनी के नेटवर्क पर लॉन्च करने की अनुमति देना या न देना और सदस्यों को मैसेज भेजना शामिल है.

इस पेज पर मौजूद कोड स्निपेट, हमारे JavaScript और Curl सैंपल से लिए गए हैं.

मोबाइल और इंटरनेट सेवा देने वाली कंपनी को सबमिट किए गए सभी एजेंट की सूची बनाएं

मोबाइल और इंटरनेट सेवा देने वाली कंपनी, उन सभी एजेंट की सूची हासिल कर सकती है जिन्हें डेवलपर ने मोबाइल और इंटरनेट सेवा देने वाली कंपनी के नेटवर्क पर लॉन्च करने के लिए सबमिट किया है.

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`"

इस ब्रैंड को - पर सेट किया गया है, क्योंकि सभी एजेंट की सूची लेते समय इसकी ज़रूरत नहीं होती.

यह कोड, मोबाइल और इंटरनेट सेवा देने वाली कंपनी के प्लैटफ़ॉर्म पर लॉन्च के लिए सबमिट किए गए सभी एजेंट की सूची दिखाता है:

{
  "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": "BASIC_MESSAGE"
        },
        "agentUseCase": "MULTI_USE",
        "hostingRegion": "NORTH_AMERICA"
      }
    },
    {
      "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_LEGACY"
        },
        "agentUseCase": "PROMOTIONAL",
        "hostingRegion": "NORTH_AMERICA"
      }
    }
  ]
}

नतीजों को एक बार में सिर्फ़ एक पेज पर लाया जा सकता है. ज़्यादा जानकारी के लिए, एपीआई का रेफ़रंस देखें.

एजेंट के लॉन्च की स्थिति और उसके सवालों की सूची की जानकारी पाएं

मोबाइल और इंटरनेट सेवा देने वाली कंपनी, किसी एजेंट के लॉन्च की मौजूदा स्थिति और डेवलपर लॉन्च से जुड़े सवालों की सूची की जानकारी हासिल कर सकती है.

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`"

यह ज़रूरी नहीं है कि कॉल करने वाले (कॉलर) को एजेंट का पूरा नाम बताएं. इसमें ब्रैंड का नाम भी शामिल होना चाहिए. सिर्फ़ एजेंट आईडी (@rbm.goog से पहले) की ज़रूरत है और ब्रैंड का नाम - पर सेट हो.

यह कोड लॉन्च की जानकारी देता है:

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

एजेंट की परिभाषा वापस पाएं

किसी एजेंट के यूनीक आइडेंटिफ़ायर (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`"

यह ज़रूरी नहीं है कि कॉलर को एजेंट का पूरा नाम और ब्रैंड का नाम बताना ज़रूरी है. सिर्फ़ एजेंट आईडी (@rbm.goog से पहले) की ज़रूरत है और ब्रैंड का नाम - पर सेट हो.

यह कोड, एजेंट की जानकारी दिखाता है:

{
  "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": "BASIC_MESSAGE"
    },
    "agentUseCase": "MULTI_USE",
    "hostingRegion": "NORTH_AMERICA"
  }
}

एजेंट के लॉन्च की स्थिति बदलें

मोबाइल और इंटरनेट सेवा देने वाली कंपनी, किसी एजेंट के लॉन्च की स्थिति को अपडेट कर सकती है और उसे ऐसा मैसेज जोड़ सकती है जिसे डेवलपर को ईमेल किया जाएगा.

स्टेटस को इस तरह बदला जाना चाहिए:

  • LAUNCH_STATE_PENDING से LAUNCH_STATE_LAUNCHED या LAUNCH_STATE_REJECTED
  • LAUNCH_STATE_LAUNCHED से LAUNCH_STATE_SUSPENDED तक
  • LAUNCH_STATE_SUSPENDED से LAUNCH_STATE_LAUNCHED या LAUNCH_STATE_REJECTED

यह ज़रूरी नहीं है कि कॉलर को एजेंट का पूरा नाम और ब्रैंड का नाम बताना ज़रूरी है. सिर्फ़ एजेंट आईडी (@rbm.goog से पहले) की ज़रूरत है और ब्रैंड का नाम - पर सेट हो.

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

यह कोड, लॉन्च के स्टेटस में बदलाव के साथ लॉन्च की अपडेट की गई जानकारी दिखाता है:

{
  "name": "brands/40bd963f-ff92-425c-b273-8f0892d2d017/agents/my_new_agent_4fpd1psz_agent/launch",
  "rcsBusinessMessaging": {
    "questionnaire": {
      "contacts": [
        {
          "name": "Ian",
          "title": "The Boss",
          "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/thecarrier": {
        "launchState": "LAUNCH_STATE_REJECTED",
        "comment": "We don't have a billing contract in place with you.",
        "updateTime": "2023-04-28T15:22:10.221191Z"
      }
    }
  }
}

किसी एजेंट को मिटाएं

सुरक्षा की वजहों से, अब आरबीएम एजेंट मिटाए नहीं जा सकते. मदद के लिए, RBM सहायता से संपर्क करें.