2024 年 7 月 31 日をもって、Google ビジネス メッセージはご利用いただけなくなります。詳しくは
こちらをご覧ください。
Webhook を設定する
コレクションでコンテンツを整理
必要に応じて、コンテンツの保存と分類を行います。
<ph type="x-smartling-placeholder">
Webhook はパートナーが作成した HTTPS コールバックで、エージェントが
イベントに応答する必要があります。事前構築済みの自動化されたパイプラインを
Dialogflow などのソリューション
エージェントの動作を定義するには、カスタム Webhook を設定する必要があります。
パートナー レベルとエージェント レベルの Webhook
Webhook はパートナー レベルまたはエージェント レベルで設定できます。
パートナー レベルの Webhook は管理するすべてのエージェントに適用されるのに対し、エージェント レベルの Webhook は
Webhook はそれぞれ 1 つのエージェントに適用されます。
動作が異なる複数のエージェントを運用している場合は、
エージェントレベルの設定を使用して、エージェントごとに異なる Webhook を構成できます。反対側
エージェントの動作が似ている場合や
エージェントが 1 つしかない場合は
パートナーレベルの Webhook を使用できます。
パートナーレベルの Webhook とエージェント レベルの Webhook の両方が構成されている場合は、
エージェント レベルの Webhook はその特定のエージェントで優先され、
パートナー レベルの Webhook は、エージェント レベルの Webhook を持たないエージェントに適用されます。
できます。
パートナー レベルの Webhook を設定する
パートナー レベルの Webhook を設定する手順は次のとおりです。
- Business Communications Developer Console を開きます。
ビジネス メッセージの Google アカウントでログインします。
- [アカウント設定] を開きます。
- 正しいパートナー アカウントが選択されていることを確認します。
- [Business Messages webhook URL] で [Configure] をクリックします。
- [Webhook endpoint URL] に、アプリケーションの URL に「/callback/」を加えた名前を入力します。
たとえば、「https://PROJECT_ID.appspot.com/callback/」のようになります。
clientToken
の値をメモします。これは、受信したメールが Google から送信されたものであることを確認するために必要です。
指定した POST リクエストを受け入れるように Webhook を構成します。
clientToken
パラメータを使用して、書式なしテキストを含む 200 OK
レスポンスを送信します。
シークレット パラメータの値をレスポンス本文として指定します。たとえば、
Webhook が、以下の本文コンテンツを含む POST リクエストを受け取ります。
{
"clientToken":"SJENCPGJESMGUFPY",
"secret":"0123456789"
}
その場合、Webhook は clientToken
値を確認する必要があり、
clientToken
は正しいので、0123456789
が指定された 200 OK
レスポンスを返します。
レスポンスの本文です
コンソールで [確認] をクリックします。ビジネス メッセージが Webhook の確認を完了すると、
ダイアログが閉じます。
エージェント レベルの Webhook を設定する
パートナー レベルの Webhook でエージェントに送信されたメッセージを受信します。もし
特定のエージェントのメッセージを別の Webhook に届けたい場合は、
エージェントレベルの Webhook を設定できます
- Business Communications Developer Console を開きます。
ビジネス メッセージの Google アカウントでログインします。
- エージェントをクリックします。
- [Integrations] をクリックします。
- [Webhook] で [構成] をクリックします。
- [Webhook endpoint URL] に、Webhook の URL(
"https://"
clientToken
の値をメモします。これは、受信したメールが
Google から送信されたリクエストです。
指定した POST リクエストを受け入れるように Webhook を構成します。
clientToken
パラメータをリクエストし、200 OK レスポンスを送信します。
シークレット パラメータです。たとえば、Webhook が POST リクエストを受信するとします。
次の本文コンテンツを追加します。
{
"clientToken":"SJENCPGJESMGUFPY",
"secret":"0123456789"
}
その場合、Webhook は clientToken
値を確認する必要があり、
clientToken
は正しいです。シークレット URL を含む 200 OK
レスポンスを返します
パラメータを 0123456789
に設定します。
コンソールで [確認] をクリックします。ビジネス メッセージが Webhook の確認を完了すると、
ダイアログが閉じます。
特に記載のない限り、このページのコンテンツはクリエイティブ・コモンズの表示 4.0 ライセンスにより使用許諾されます。コードサンプルは Apache 2.0 ライセンスにより使用許諾されます。詳しくは、Google Developers サイトのポリシーをご覧ください。Java は Oracle および関連会社の登録商標です。
最終更新日 2024-10-14 UTC。
[null,null,["最終更新日 2024-10-14 UTC。"],[[["\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."]]