[null,null,["最后更新时间 (UTC):2025-01-16。"],[[["\u003cp\u003eWebhooks in the RBM platform are partner-specified URLs that receive messages and event notifications.\u003c/p\u003e\n"],["\u003cp\u003eBy default, all agents created through the RBM Management API utilize a single partner-level webhook, configurable in the Business Communications Developer Console.\u003c/p\u003e\n"],["\u003cp\u003eAgent-level webhooks can be configured via the RBM Management API, offering a good alternative for managing multiple agents with varied behavior.\u003c/p\u003e\n"],["\u003cp\u003eCreating a webhook integration involves defining the webhook URL and validation token, followed by calling the \u003ccode\u003ecreateWebhookIntegration\u003c/code\u003e method.\u003c/p\u003e\n"],["\u003cp\u003eThe RBM Management API also allows you to retrieve, view, and remove webhook integrations.\u003c/p\u003e\n"]]],[],null,["# Manage webhooks\n\n| **Webhook** A partner-specified URL where the RBM platform posts [messages](/business-communications/rcs-business-messaging/guides/build/messages/receive) and [events](/business-communications/rcs-business-messaging/guides/build/events).\n\nAll agents created through the RBM Management API use a single webhook for\nnotifications by default. This [partner-level webhook](/business-communications/rcs-business-messaging/guides/get-started/partner-account#configure_your_partner_webhook)\nis configured in the Business Communications Developer Console\nand it applies to all agents within your partner account.\n\nAlternatively, you can use the RBM Management API to configure\n[agent-level webhooks](/business-communications/rcs-business-messaging/guides/integrate/webhooks#configure_an_agent_webhook).\nThis may be a good option if you manage multiple agents with distinct behavior.\n\nCode snippets on this page are taken from the [Java samples](https://github.com/rcs-business-messaging/rbm-api-examples/tree/master/java/rbm-mgmt-api)\nand [Node.js samples](https://github.com/rcs-business-messaging/rbm-api-examples/tree/master/nodejs/rbm-mgmt-api).\n\nCreate a webhook integration\n----------------------------\n\nTo add an agent webhook integration, first define the URL for your webhook and\ndefine a validation token. Then configure the webhook to follow the\n[validation steps](/business-communications/rcs-business-messaging/guides/integrate/webhooks#configure_an_agent_webhook).\nOnce configured, call the `createWebhookIntegration` method with the URL and\ntoken values. If that call succeeds, you can proceed with\n[verifying and handling incoming messages](/business-communications/rcs-business-messaging/guides/integrate/webhooks#verify_incoming_messages).\n\nFor more details, see\n[`brands.agents.integrations`](/business-communications/rcs-business-messaging/reference/business-communications/rest/v1/brands.agents.integrations#resource:-integration)\nand [`brands.agents.integrations.create`](/business-communications/rcs-business-messaging/reference/business-communications/rest/v1/brands.agents.integrations/create). \n\n### Node.js\n\n```javascript\nconst businessCommunicationsApiHelper =\n require('@google/rbm-businesscommunications');\n\nconst privateKey =\n require('../../resources/businesscommunications-service-account-credentials.json');\n\nbusinessCommunicationsApiHelper.initBusinessCommunucationsApi(privateKey);\n\nconst url = 'https://myrbmserviceendpoint.somewhere.com/callback';\n\nconst token = '123456';\n\nbusinessCommunicationsApiHelper\n .createWebhookIntegration(agent.name, url, token)\n .then((response) =\u003e {\n console.log(JSON.stringify(response.data, null, 2));\n }).catch((err) =\u003e {\n console.log(err);\n }\n);\n```\n\nThis code returns the new webhook object: \n\n {\n \"name\": \"brands/40bd963f-ff92-425c-b273-8f0892d2d017/agents/my_new_agent_hfaoplpu_agent/integrations/4efdb82f-fd6d-4ba4-8ea3-f2f4a60d1547\",\n \"status\": \"ENABLED\",\n \"agentWebhookIntegration\": {\n \"webhookUri\": \"https://myrbmserviceendpoint.somewhere.com/callback\"\n }\n }\n\nLook up an agent's webhook integrations\n---------------------------------------\n\nYou can retrieve a list of all the webhook integrations belonging to an agent.\nIn practice, an RBM agent only ever has a single webhook integration. For more\ndetails, see [`brands.agents.integrations.list`](/business-communications/rcs-business-messaging/reference/business-communications/rest/v1/brands.agents.integrations/list). \n\n### Node.js\n\n```javascript\nconst businessCommunicationsApiHelper =\n require('@google/rbm-businesscommunications');\n\nconst privateKey =\n require('../../resources/businesscommunications-service-account-credentials.json');\n\nbusinessCommunicationsApiHelper.initBusinessCommunucationsApi(privateKey);\n\nbusinessCommunicationsApiHelper\n .listAgentIntegrations(agent.name)\n .then((response) =\u003e {\n console.log(JSON.stringify(response.data, null, 2));\n datastore.saveJsonData('integrations', response.data);\n }).catch((err) =\u003e {\n console.log(err);\n });\n```\n\nThis code returns a list of the agent's webhook integrations: \n\n {\n \"integrations\": [\n {\n \"name\": \"brands/40bd963f-ff92-425c-b273-8f0892d2d017/agents/my_new_agent_hfaoplpu_agent/integrations/4efdb82f-fd6d-4ba4-8ea3-f2f4a60d1547\",\n \"status\": \"ENABLED\",\n \"agentWebhookIntegration\": {\n \"webhookUri\": \"https://myrbmserviceendpoint.somewhere.com/callback\"\n }\n }\n ]\n }\n\nLook up details of an integration\n---------------------------------\n\nYou can retrieve integration details if you have the reference to an\nintegration. For more details, see [`brands.agents.integrations.get`](/business-communications/rcs-business-messaging/reference/business-communications/rest/v1/brands.agents.integrations/get). \n\n### Node.js\n\n```javascript\nconst businessCommunicationsApiHelper =\n require('@google/rbm-businesscommunications');\n\nconst privateKey =\n require('../../resources/businesscommunications-service-account-credentials.json');\n\nbusinessCommunicationsApiHelper.initBusinessCommunucationsApi(privateKey);\n\nbusinessCommunicationsApiHelper\n .getAgentIntegration(integrations.integrations[0].name)\n .then((response) =\u003e {\n console.log(JSON.stringify(response.data, null, 2));\n }).catch((err) =\u003e {\n console.log(err);\n });\n```\n\nThis code returns the webhook integration details: \n\n {\n \"name\": \"brands/40bd963f-ff92-425c-b273-8f0892d2d017/agents/my_new_agent_hfaoplpu_agent/integrations/4efdb82f-fd6d-4ba4-8ea3-f2f4a60d1547\",\n \"status\": \"ENABLED\",\n \"agentWebhookIntegration\": {\n \"webhookUri\": \"https://myrbmserviceendpoint.somewhere.com/callback\"\n }\n }\n\nRemove a webhook\n----------------\n\nYou can remove a webhook from an agent using its reference. For more\ndetails, see [`brands.agents.integrations.delete`](/business-communications/rcs-business-messaging/reference/business-communications/rest/v1/brands.agents.integrations/delete). \n\n### Node.js\n\n```javascript\nconst businessCommunicationsApiHelper =\n require('@google/rbm-businesscommunications');\n\nconst privateKey =\n require('../../resources/businesscommunications-service-account-credentials.json');\n\nbusinessCommunicationsApiHelper.initBusinessCommunucationsApi(privateKey);\n\nbusinessCommunicationsApiHelper\n .deleteAgentIntegration(integrations.integrations[0].name)\n .then((response) =\u003e {\n console.log(JSON.stringify(response.data, null, 2));\n }).catch((err) =\u003e {\n console.log(err);\n });\n```\n\nAn empty object is returned: \n\n {}"]]