ওয়েবহুক পরিচালনা করুন

RBM Management API-এর মাধ্যমে তৈরি করা সমস্ত এজেন্ট ডিফল্টরূপে বিজ্ঞপ্তির জন্য একটি একক ওয়েবহুক ব্যবহার করে। এই অংশীদার-স্তরের ওয়েবহুকটি বিজনেস কমিউনিকেশনস ডেভেলপার কনসোলে কনফিগার করা হয়েছে এবং এটি আপনার অংশীদার অ্যাকাউন্টের সমস্ত এজেন্টের জন্য প্রযোজ্য।

বিকল্পভাবে, আপনি এজেন্ট-স্তরের ওয়েবহুক কনফিগার করতে RBM ম্যানেজমেন্ট API ব্যবহার করতে পারেন। আপনি যদি স্বতন্ত্র আচরণ সহ একাধিক এজেন্ট পরিচালনা করেন তবে এটি একটি ভাল বিকল্প হতে পারে।

এই পৃষ্ঠার কোড স্নিপেটগুলি জাভা নমুনা এবং Node.js নমুনা থেকে নেওয়া হয়েছে।

একটি ওয়েবহুক ইন্টিগ্রেশন তৈরি করুন

একটি এজেন্ট ওয়েবহুক ইন্টিগ্রেশন যোগ করতে, প্রথমে আপনার ওয়েবহুকের URLটি সংজ্ঞায়িত করুন এবং একটি বৈধতা টোকেন সংজ্ঞায়িত করুন৷ তারপর বৈধকরণের ধাপগুলি অনুসরণ করতে ওয়েবহুক কনফিগার করুন। কনফিগার হয়ে গেলে, URL এবং টোকেন মান সহ createWebhookIntegration পদ্ধতিতে কল করুন। যদি সেই কলটি সফল হয়, আপনি ইনকামিং বার্তাগুলি যাচাই এবং পরিচালনার সাথে এগিয়ে যেতে পারেন৷

Node.js


const businessCommunicationsApiHelper =
  require('@google/rbm-businesscommunications');

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

businessCommunicationsApiHelper.initBusinessCommunucationsApi(privateKey);

const url = 'https://myrbmserviceendpoint.somewhere.com/callback';

const token = '123456';

businessCommunicationsApiHelper
  .createWebhookIntegration(agent.name, url, token)
  .then((response) => {
    console.log(JSON.stringify(response.data, null, 2));
  }).catch((err) => {
    console.log(err);
  }
);

এই কোডটি নতুন ওয়েবহুক অবজেক্ট প্রদান করে:

{
  "name": "brands/40bd963f-ff92-425c-b273-8f0892d2d017/agents/my_new_agent_hfaoplpu_agent/integrations/4efdb82f-fd6d-4ba4-8ea3-f2f4a60d1547",
  "status": "ENABLED",
  "agentWebhookIntegration": {
    "webhookUri": "https://myrbmserviceendpoint.somewhere.com/callback"
  }
}

একটি এজেন্ট এর ওয়েবহুক ইন্টিগ্রেশন দেখুন

আপনি একটি এজেন্টের অন্তর্গত সমস্ত ওয়েবহুক ইন্টিগ্রেশনের একটি তালিকা পুনরুদ্ধার করতে পারেন। অনুশীলনে, একটি RBM এজেন্টের শুধুমাত্র একটি একক ওয়েবহুক ইন্টিগ্রেশন থাকে।

Node.js


const businessCommunicationsApiHelper =
  require('@google/rbm-businesscommunications');

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

businessCommunicationsApiHelper.initBusinessCommunucationsApi(privateKey);

businessCommunicationsApiHelper
  .listAgentIntegrations(agent.name)
  .then((response) => {
    console.log(JSON.stringify(response.data, null, 2));
    datastore.saveJsonData('integrations', response.data);
  }).catch((err) => {
    console.log(err);
  });

এই কোডটি এজেন্টের ওয়েবহুক ইন্টিগ্রেশনের একটি তালিকা প্রদান করে:

{
  "integrations": [
    {
      "name": "brands/40bd963f-ff92-425c-b273-8f0892d2d017/agents/my_new_agent_hfaoplpu_agent/integrations/4efdb82f-fd6d-4ba4-8ea3-f2f4a60d1547",
      "status": "ENABLED",
      "agentWebhookIntegration": {
        "webhookUri": "https://myrbmserviceendpoint.somewhere.com/callback"
      }
    }
  ]
}

একটি ইন্টিগ্রেশন বিস্তারিত দেখুন

একটি ইন্টিগ্রেশনের রেফারেন্স দেওয়া হলে, এর বিবরণ পুনরুদ্ধার করা যেতে পারে।

Node.js


const businessCommunicationsApiHelper =
  require('@google/rbm-businesscommunications');

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

businessCommunicationsApiHelper.initBusinessCommunucationsApi(privateKey);

businessCommunicationsApiHelper
  .getAgentIntegration(integrations.integrations[0].name)
  .then((response) => {
    console.log(JSON.stringify(response.data, null, 2));
  }).catch((err) => {
    console.log(err);
  });

এই কোডটি ওয়েবহুক ইন্টিগ্রেশনের বিবরণ প্রদান করে:

{
  "name": "brands/40bd963f-ff92-425c-b273-8f0892d2d017/agents/my_new_agent_hfaoplpu_agent/integrations/4efdb82f-fd6d-4ba4-8ea3-f2f4a60d1547",
  "status": "ENABLED",
  "agentWebhookIntegration": {
    "webhookUri": "https://myrbmserviceendpoint.somewhere.com/callback"
  }
}

একটি ওয়েবহুক সরান

একটি ওয়েবহুক তার রেফারেন্স ব্যবহার করে একটি এজেন্ট থেকে সরানো যেতে পারে:

Node.js


const businessCommunicationsApiHelper =
  require('@google/rbm-businesscommunications');

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

businessCommunicationsApiHelper.initBusinessCommunucationsApi(privateKey);

businessCommunicationsApiHelper
  .deleteAgentIntegration(integrations.integrations[0].name)
  .then((response) => {
    console.log(JSON.stringify(response.data, null, 2));
  }).catch((err) => {
    console.log(err);
  });

একটি খালি বস্তু ফেরত দেওয়া হয়:

{}