Chúng tôi sẽ ngừng cung cấp ứng dụng Google Business Messages từ ngày 31 tháng 7 năm 2024. Đọc thêm
tại đây.
Thiết lập webhook
Sử dụng bộ sưu tập để sắp xếp ngăn nắp các trang
Lưu và phân loại nội dung dựa trên lựa chọn ưu tiên của bạn.
Webhook là một lệnh gọi lại HTTPS do đối tác tạo để chỉ định cách nhân viên hỗ trợ của bạn
phải phản hồi các tin nhắn và sự kiện. Trừ phi bạn đang sử dụng
như Dialogflow,
bạn cần đặt một webhook tuỳ chỉnh để xác định hành vi cho nhân viên hỗ trợ của mình.
Webhook ở cấp đối tác và cấp nhân viên hỗ trợ
Bạn có thể thiết lập webhook ở cấp đối tác hoặc cấp nhân viên hỗ trợ.
Webhook ở cấp đối tác áp dụng cho mọi nhân viên hỗ trợ mà bạn duy trì, còn ở cấp nhân viên hỗ trợ
Mỗi webhook áp dụng cho một nhân viên hỗ trợ.
Nếu điều hành nhiều nhân viên hỗ trợ có hành vi riêng biệt, bạn có thể cần thiết lập một
webhook khác nhau cho từng nhân viên hỗ trợ bằng cách sử dụng chế độ cài đặt ở cấp nhân viên hỗ trợ. Mặt khác
nếu nhân viên hỗ trợ có hành vi tương tự, hoặc nếu bạn chỉ có một nhân viên hỗ trợ,
có thể sử dụng webhook ở cấp đối tác.
Nếu bạn đã thiết lập cả webhook ở cấp đối tác và webhook ở cấp nhân viên hỗ trợ,
webhook ở cấp nhân viên hỗ trợ sẽ được ưu tiên so với nhân viên hỗ trợ cụ thể, trong khi
Webhook ở cấp đối tác áp dụng cho những nhân viên hỗ trợ không có cấp nhân viên hỗ trợ
webhook.
Đặt webhook ở cấp đối tác
Để đặt webhook ở cấp đối tác, hãy làm theo các bước sau:
- Mở Business Communications Developer Console
rồi đăng nhập bằng Tài khoản Google của bạn trong Business Messages.
- Mở phần Cài đặt tài khoản.
- Nhớ chọn đúng tài khoản đối tác.
- Đối với URL webhook của Business Messages, hãy nhấp vào Định cấu hình.
- Đối với URL điểm cuối webhook, hãy nhập URL của ứng dụng + "/callback/".
Ví dụ: "https://PROJECT_ID.appspot.com/callback/".
- Ghi lại giá trị
clientToken
của bạn. Bạn cần mã xác minh này để xác minh rằng các tin nhắn bạn nhận được đến từ Google.
Định cấu hình webhook của bạn để chấp nhận yêu cầu POST bằng yêu cầu được chỉ định
Tham số clientToken
và gửi phản hồi 200 OK
có văn bản thuần tuý
giá trị của tham số bí mật làm nội dung phản hồi. Ví dụ: giả sử
webhook nhận được một yêu cầu POST với nội dung nội dung sau đây:
{
"clientToken":"SJENCPGJESMGUFPY",
"secret":"0123456789"
}
Trong trường hợp đó, webhook của bạn phải xác nhận giá trị clientToken
và nếu
clientToken
đã chính xác, hãy trả về phản hồi 200 OK
với 0123456789
là giá trị
nội dung phản hồi.
Trong bảng điều khiển, hãy nhấp vào Xác minh. Khi Business Messages xác minh webhook của bạn:
hộp thoại đóng lại.
Thiết lập webhook ở cấp nhân viên hỗ trợ
Bạn nhận tin nhắn gửi đến nhân viên hỗ trợ tại webhook ở cấp đối tác. Nếu bạn
muốn tin nhắn cho một đại lý cụ thể sẽ chuyển đến một webhook khác, bạn
có thể thiết lập webhook ở cấp độ nhân viên hỗ trợ.
- Mở Business Communications Developer Console
rồi đăng nhập bằng Tài khoản Google của bạn trong Business Messages.
- Nhấp vào nhân viên hỗ trợ.
- Nhấp vào Tích hợp.
- Đối với Webhook, hãy nhấp vào Định cấu hình.
- Đối với URL điểm cuối webhook, hãy nhập URL của webhook, bắt đầu bằng
"https://".
- Ghi lại giá trị
clientToken
của bạn. Bạn cần mã này để xác minh rằng tin nhắn bạn
nhận được đến từ Google.
Định cấu hình webhook của bạn để chấp nhận yêu cầu POST bằng yêu cầu được chỉ định
tham số clientToken
và gửi một phản hồi 200 OK bằng giá trị của
tham số bí mật. Ví dụ: giả sử webhook của bạn nhận được yêu cầu POST
có nội dung như sau:
{
"clientToken":"SJENCPGJESMGUFPY",
"secret":"0123456789"
}
Trong trường hợp đó, webhook của bạn phải xác nhận giá trị clientToken
và nếu
clientToken
đã chính xác, hãy trả về phản hồi 200 OK
có URL bí mật
tham số được đặt thành 0123456789
.
Trong bảng điều khiển, hãy nhấp vào Xác minh. Khi Business Messages xác minh webhook của bạn:
hộp thoại đóng lại.
Trừ phi có lưu ý khác, nội dung của trang này được cấp phép theo Giấy phép ghi nhận tác giả 4.0 của Creative Commons và các mẫu mã lập trình được cấp phép theo Giấy phép Apache 2.0. Để biết thông tin chi tiết, vui lòng tham khảo Chính sách trang web của Google Developers. Java là nhãn hiệu đã đăng ký của Oracle và/hoặc các đơn vị liên kết với Oracle.
Cập nhật lần gần đây nhất: 2024-10-14 UTC.
[null,null,["Cập nhật lần gần đây nhất: 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."]]