عوامل را با RBM Operations API مدیریت کنید

جریان کار اصلی RBM برای اپراتورها شامل بررسی اطلاعات مربوط به نمایندگان جدید و تأیید یا رد مجوز راه‌اندازی آنها در شبکه شرکت مخابراتی و ارسال پیام به مشترکانشان است.

قطعه کد در این صفحه از نمونه های جاوا اسکریپت و کرل ما گرفته شده است.

فهرست تمام نمایندگان ارسال شده به یک شرکت مخابراتی

شرکت مخابراتی می‌تواند فهرستی از تمام عواملی را که توسعه‌دهندگان برای راه‌اندازی در شبکه حامل ارسال کرده‌اند، دریافت کند.

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

نتایج را می توان یک صفحه در یک زمان بازیابی کرد. برای جزئیات به مرجع API مراجعه کنید.

وضعیت راه اندازی عامل و پرسشنامه را دریافت کنید

حامل می تواند وضعیت راه اندازی فعلی یک عامل و پرسشنامه راه اندازی توسعه دهنده را بدست آورد.

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 -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 -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 -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 دیگر قابل حذف نیستند. برای کمک با پشتیبانی RBM تماس بگیرید.