เราจะยุติการให้บริการ Google Business Messages ในวันที่ 31 กรกฎาคม 2024 อ่านเพิ่มเติม
ที่นี่
ตั้งค่าเว็บฮุค
จัดทุกอย่างให้เป็นระเบียบอยู่เสมอด้วยคอลเล็กชัน
บันทึกและจัดหมวดหมู่เนื้อหาตามค่ากำหนดของคุณ
เว็บฮุคคือการเรียกกลับ HTTPS ที่พาร์ทเนอร์สร้างขึ้นซึ่งระบุวิธีที่ Agent ของคุณ
ควรตอบกลับข้อความและกิจกรรม เว้นแต่คุณจะใช้ระบบอัตโนมัติที่สร้างไว้ล่วงหน้า
โซลูชันอย่าง Dialogflow
คุณต้องตั้งค่าเว็บฮุคที่กําหนดเองเพื่อกําหนดลักษณะการทํางานสําหรับตัวแทนของคุณ
เว็บฮุคระดับพาร์ทเนอร์และระดับตัวแทน
คุณตั้งค่าเว็บฮุคที่ระดับพาร์ทเนอร์หรือระดับตัวแทนได้
เว็บฮุคระดับพาร์ทเนอร์จะมีผลกับตัวแทนทุกรายที่คุณดูแลอยู่ แต่ระดับตัวแทน
เว็บฮุคแต่ละรายการจะมีผลกับ Agent 1 รายการ
หากคุณดำเนินธุรกิจตัวแทนหลายรายที่มีพฤติกรรมแตกต่างกัน คุณอาจต้องกำหนด
เว็บฮุคที่ต่างกันสำหรับตัวแทนแต่ละรายโดยใช้การตั้งค่าระดับตัวแทน ในอีกทาง
หากตัวแทนของคุณมีพฤติกรรมคล้ายกัน หรือหากคุณมีตัวแทนเพียงคนเดียว คุณจะ
ใช้เว็บฮุคระดับพาร์ทเนอร์ได้
หากคุณกำหนดค่าเว็บฮุคระดับพาร์ทเนอร์และเว็บฮุคระดับตัวแทนไว้
เว็บฮุคระดับตัวแทนจะมีความสำคัญเหนือกว่าตัวแทนเฉพาะ ขณะที่
เว็บฮุคระดับพาร์ทเนอร์มีผลกับตัวแทนที่ไม่มีระดับตัวแทน
เว็บฮุค
ตั้งค่าเว็บฮุคระดับพาร์ทเนอร์
หากต้องการตั้งค่าเว็บฮุคระดับพาร์ทเนอร์ ให้ทําตามขั้นตอนต่อไปนี้
- เปิดคอนโซลของนักพัฒนาซอฟต์แวร์ Business Communications
และลงชื่อเข้าใช้ด้วยบัญชี Google Business Messages
- เปิดการตั้งค่าบัญชี
- ตรวจสอบว่าได้เลือกบัญชีพาร์ทเนอร์ที่ถูกต้องแล้ว
- สำหรับ URL ของเว็บฮุคของ Business Messages ให้คลิกกำหนดค่า
- สำหรับ URL ปลายทางของเว็บฮุค ให้ป้อน URL ของแอปพลิเคชัน + "/callback/"
ตัวอย่างเช่น อาจเป็น "https://PROJECT_ID.appspot.com/callback/"
- จดค่า
clientToken
ไว้ คุณต้องใช้รหัสเพื่อยืนยันว่าข้อความที่ได้รับมาจาก Google
กำหนดค่าเว็บฮุคให้ยอมรับคำขอ POST ที่มี
พารามิเตอร์ clientToken
และส่งการตอบกลับ 200 OK
พร้อมข้อความธรรมดา
ของพารามิเตอร์ลับเป็นส่วนเนื้อหาการตอบกลับ ตัวอย่างเช่น สมมติว่า
เว็บฮุคจะได้รับคำขอ POST ที่มีเนื้อหาต่อไปนี้
{
"clientToken":"SJENCPGJESMGUFPY",
"secret":"0123456789"
}
ในกรณีดังกล่าว เว็บฮุคควรยืนยันค่า clientToken
และหาก
clientToken
ถูกต้อง แสดงการตอบกลับ 200 OK
ที่มี 0123456789
เป็น
เนื้อหาการตอบกลับ
คลิกยืนยันในคอนโซล เมื่อ Business Messages ยืนยันเว็บฮุค
กล่องโต้ตอบจะปิดลง
ตั้งค่าเว็บฮุคระดับตัวแทน
คุณจะได้รับข้อความที่ส่งถึงตัวแทนที่เว็บฮุคระดับพาร์ทเนอร์ หากคุณ
ข้อความสำหรับตัวแทนที่เจาะจง จะส่งไปยังเว็บฮุคอื่นแทน
ตั้งค่าเว็บฮุคระดับตัวแทนได้
- เปิดคอนโซลของนักพัฒนาซอฟต์แวร์ Business Communications
และลงชื่อเข้าใช้ด้วยบัญชี Google Business Messages
- คลิกตัวแทน
- คลิก Integrations
- สำหรับเว็บฮุค ให้คลิกกำหนดค่า
- สำหรับ URL ปลายทางของเว็บฮุค ให้ป้อน URL ของเว็บฮุคโดยขึ้นต้นด้วย
"https://"
- จดค่า
clientToken
ไว้ คุณต้องใช้รหัสเพื่อยืนยันว่า
ที่ได้รับมาจาก Google
กำหนดค่าเว็บฮุคให้ยอมรับคำขอ POST ที่มี
clientToken
และส่งการตอบกลับ 200 OK ที่มีค่า
พารามิเตอร์ลับ ตัวอย่างเช่น สมมติว่าเว็บฮุคได้รับคำขอ POST
ซึ่งมีเนื้อความดังต่อไปนี้
{
"clientToken":"SJENCPGJESMGUFPY",
"secret":"0123456789"
}
ในกรณีดังกล่าว เว็บฮุคควรยืนยันค่า clientToken
และหาก
clientToken
ถูกต้อง โปรดส่งการตอบกลับ 200 OK
ด้วย URL ลับ
ตั้งค่าพารามิเตอร์เป็น 0123456789
คลิกยืนยันในคอนโซล เมื่อ Business Messages ยืนยันเว็บฮุค
กล่องโต้ตอบจะปิดลง
เนื้อหาของหน้าเว็บนี้ได้รับอนุญาตภายใต้ใบอนุญาตที่ต้องระบุที่มาของครีเอทีฟคอมมอนส์ 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."]]