RBM मैनेजमेंट एपीआई की मदद से बनाए गए सभी एजेंट, डिफ़ॉल्ट रूप से सूचनाओं के लिए एक ही वेबहुक का इस्तेमाल करते हैं. यह पार्टनर-लेवल वेबहुक, Business Communications डेवलपर कंसोल में कॉन्फ़िगर किया जाता है. यह आपके पार्टनर खाते के सभी एजेंट पर लागू होता है.
इसके अलावा, एजेंट-लेवल के वेबहुक कॉन्फ़िगर करने के लिए, RBM Management API का इस्तेमाल किया जा सकता है. अगर आपको अलग-अलग व्यवहार वाले कई एजेंट मैनेज करने हैं, तो यह एक अच्छा विकल्प हो सकता है.
इस पेज पर दिए गए कोड स्निपेट, Java सैंपल और Node.js सैंपल से लिए गए हैं.
वेबहुक इंटिग्रेशन बनाना
एजेंट वेबहुक इंटिग्रेशन जोड़ने के लिए, पहले अपने वेबहुक का यूआरएल तय करें और पुष्टि करने वाला टोकन तय करें. इसके बाद, पुष्टि करने के लिए, वेबहुक को कॉन्फ़िगर करें.
कॉन्फ़िगर करने के बाद, यूआरएल और टोकन वैल्यू के साथ createWebhookIntegration
तरीके को कॉल करें. अगर कॉल पूरा हो जाता है, तो इनकमिंग मैसेज की पुष्टि करने और उन्हें मैनेज करने की प्रोसेस शुरू की जा सकती है.
ज़्यादा जानकारी के लिए, brands.agents.integrations
और brands.agents.integrations.create
देखें.
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 एजेंट में सिर्फ़ एक वेबहुक इंटिग्रेशन होता है. ज़्यादा जानकारी के लिए, brands.agents.integrations.list
देखें.
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"
}
}
]
}
किसी इंटिग्रेशन की जानकारी देखना
अगर आपके पास किसी इंटिग्रेशन का रेफ़रंस है, तो इंटिग्रेशन की जानकारी वापस पाई जा सकती है. ज़्यादा जानकारी के लिए, brands.agents.integrations.get
देखें.
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"
}
}
वेबहुक हटाना
किसी एजेंट से वेबहुक को हटाने के लिए, उसके रेफ़रंस का इस्तेमाल करें. ज़्यादा जानकारी के लिए, brands.agents.integrations.delete
देखें.
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); });
कोई ऑब्जेक्ट नहीं दिखाया जाता:
{}