[null,null,["最后更新时间 (UTC):2024-10-14。"],[[["\u003cp\u003eA webhook defines how your agent responds to messages and events, and should be set at either the partner or agent level, depending on your needs.\u003c/p\u003e\n"],["\u003cp\u003ePartner-level webhooks apply to all agents under your account, whereas agent-level webhooks are specific to individual agents and take precedence.\u003c/p\u003e\n"],["\u003cp\u003eTo set a webhook, you provide an endpoint URL, obtain a clientToken for verification, and configure your webhook to handle verification requests from Google.\u003c/p\u003e\n"],["\u003cp\u003eThe verification process involves receiving a POST request with a clientToken and secret, validating the clientToken, and responding with a 200 OK and the secret value.\u003c/p\u003e\n"],["\u003cp\u003eYou can set up your webhook using either the Business Communications Developer Console or the API.\u003c/p\u003e\n"]]],[],null,["# Set your webhook\n\n| Choose whether to set your webhook with the Business Communications [Developer\n| Console](https://business-communications.cloud.google.com?utm_source=/business-communications/business-messages/guides/how-to/agents/set-webhook&utm_medium=devsite&utm_campaign=business-messages) or [API](/business-communications/business-messages/reference/business-communications/rest). \n| Developer Console API\n\nA webhook is a partner-created HTTPS callback that specifies how your agent\nshould respond to messages and events. Unless you're using a pre-built automated\nsolution like [Dialogflow](/business-communications/business-messages/guides/how-to/integrate/dialogflow#dialogflow_integration),\nyou need to set a custom webhook to define the behavior for your agent.\n\nPartner-level and agent-level webhooks\n--------------------------------------\n\nYou can set your webhook either at the partner level or at the agent level.\nPartner-level webhooks apply to every agent you maintain, while agent-level\nwebhooks each apply to one individual agent.\n\nIf you operate multiple agents with distinct behavior, you may wish to set a\ndifferent webhook for each agent using the agent-level setting. On the other\nhand, if your agents have similar behavior, or if you only have one agent, you\ncan use the partner-level webhook.\n\nIf you have both a partner-level webhook and an agent-level webhook configured,\nthe agent-level webhook takes precedence on its specific agent, while the\npartner-level webhook applies to agents that don't have an agent-level\nwebhook.\n\nSet your partner-level webhook\n------------------------------\n\nTo set your partner-level webhook, follow these steps:\n\n1. Open the [Business Communications Developer Console](https://business-communications.cloud.google.com?utm_source=/business-communications/business-messages/guides/how-to/agents/set-webhook&utm_medium=devsite&utm_campaign=business-messages) and sign in with your Business Messages Google account.\n2. Open the [Account settings](https://business-communications.cloud.google.com/console/partner/settings?utm_source=/business-communications/business-messages/guides/how-to/set-webhook&utm_medium=devsite&utm_campaign=business-messages).\n3. Make sure the correct partner account is selected.\n4. For **Business Messages webhook URL** , click **Configure**.\n5. For **Webhook endpoint URL**, enter your application's URL + \"/callback/\". For example, it might be something like \"https://PROJECT_ID.appspot.com/callback/\".\n6. Note your `clientToken` value. You need it to [verify that messages you receive are coming from Google](/business-communications/business-messages/guides/how-to/message/receive#verify).\n7. Configure your webhook to accept a POST request with the specified\n `clientToken` parameter and send a `200 OK` response with the plain text\n value of the secret parameter as the response body. For example, suppose your\n webhook receives a POST request with the following body content:\n\n {\n \"clientToken\":\"SJENCPGJESMGUFPY\",\n \"secret\":\"0123456789\"\n }\n\n In that case, your webhook should confirm the `clientToken` value and, if\n `clientToken` is correct, return a `200 OK` response with `0123456789` as the\n response body.\n8. In the console, click **Verify**. When Business Messages verifies your webhook,\n the dialog closes.\n\nSet an agent-level webhook\n--------------------------\n\nYou receive messages sent to your agent at your partner-level webhook. If you\nwant messages for a specific agent to arrive at a different webhook instead, you\ncan set an agent-level webhook.\n\n1. Open the [Business Communications Developer Console](https://business-communications.cloud.google.com?utm_source=/business-communications/business-messages/guides/how-to/agents/set-webhook&utm_medium=devsite&utm_campaign=business-messages) and sign in with your Business Messages Google account.\n2. Click your agent.\n3. Click **Integrations**.\n4. For **Webhook** , click **Configure**.\n5. For **Webhook endpoint URL**, enter your webhook's URL, beginning with \"https://\".\n6. Note your `clientToken` value. You need it to [verify that messages you\n receive are coming from Google](/business-communications/business-messages/guides/how-to/message/receive#verify).\n7. Configure your webhook to accept a POST request with the specified\n `clientToken` parameter and send a 200 OK response with the value of the\n secret parameter. For example, suppose your webhook receives a POST request\n with the following body content:\n\n {\n \"clientToken\":\"SJENCPGJESMGUFPY\",\n \"secret\":\"0123456789\"\n }\n\n In that case, your webhook should confirm the `clientToken` value and, if\n `clientToken` is correct, return a `200 OK` response with the secret URL\n parameter set to `0123456789`.\n8. In the console, click **Verify**. When Business Messages verifies your webhook,\n the dialog closes."]]