註冊成為 Business Messages 合作夥伴後,就能啟用 藉由建立虛擬服務專員的對話,與使用者和品牌之間的對話 代表企業功能的實體,例如網站支援和品牌 或位置。
當使用者在 Google 搜尋或 Google 地圖中發現你管理的品牌時, 搜尋結果會顯示「即時通訊」選項。使用者按一下「Chat」後, 即可傳送訊息給品牌的服務專員客服專員可讓你接收及回覆 調整在使用者的郵件中
註冊成為合作夥伴
註冊成為 Business Messages 的合作夥伴,為品牌打造服務專員 並運用代理程式的 API,您就能啟用訊息傳遞功能 為客戶提供服務、銷售和其他商業應用程式的經驗。
- 開啟 Business Communications 開發人員控制台。
- 在「Business Messages」下方,按一下「建立合作夥伴帳戶」。
輸入合作夥伴資訊的值:
欄位 值 您的姓名 您的全名 合作夥伴名稱 貴機構的名稱 合作夥伴網站 貴機構的網站 區域 要託管 Business Messages 服務的區域
詳閱並接受 Business Messages 服務條款。
按一下「建立」。
您現在已註冊為 Business Messages 合作夥伴,因此可以存取 Business Messages 和 Business Communications API。Business Messages API 會傳送訊息給使用者,Business Communications API 則會管理服務專員。
建立服務帳戶
如要安全地驗證對 Business Messages 和 Business Communications API 的 API 呼叫,您必須具備服務帳戶金鑰和 oauth2l 指令列工具。
- 在 Business Communications 開發人員控制台首頁,按一下「合作夥伴帳戶設定」。
- 在左側導覽面板中按一下 服務帳戶。
按一下「建立金鑰」,然後點選「建立」。
瀏覽器會下載服務帳戶金鑰。將服務帳戶金鑰存放在安全的私人位置。錯誤做法 公開分享你的金鑰。稍後將需要使用這組金鑰,才能存取 Business Message and Business Communication API。
設定你的手冊
現在已啟用 Business Messages 和 Business Communications API 請先指定 Webhook 網址 接收訊息。
- 在 Business Communications 開發人員控制台中開啟帳戶設定。
- 確認已選取正確的合作夥伴帳戶。
- 在「Business Messages Webhook 網址」部分,按一下「設定」。
- 在「Webhook 端點網址」部分中,輸入 Webhook 的網址 (開頭為 「https://」。
- 記下
clientToken
值。你必須開啟這項功能,才能驗證訊息 收到的流量來自 Google。 將 Webhook 設定為接受指定項目的
POST
要求clientToken
參數,並傳送含有純文字的200 OK
回應 做為回應主體的secret
參數值。舉例來說,如果您的 Webhook 收到含有以下內容的
POST
要求, 身體內容{ "clientToken":"SJENCPGJESMGUFPY", "secret":"0123456789" }
Webhook 應確認
clientToken
值,如果clientToken
為 正確,請傳回200 OK
回應,並將0123456789
做為回應主體。在控制台中按一下「驗證」。
Business Messages 驗證 Webhook 後,對話方塊就會關閉。
詳情請見 範例:更新 Webhook 網址 ,瞭解如何使用 Business Communication API 設定 Webhook。
取得合作夥伴資訊
如要取得目前的合作夥伴資訊,可以查詢商家 含有您合作夥伴 ID 的 Communications API。
執行下列指令。然後將 PARTNER_ID 替換成您的合作夥伴 ID。
# This code gets the partner. # Read more: https://developers.google.com/business-communications/business-messages/reference/business-communications/rest/v1/partners/get # Replace the __PARTNER_ID__ # Make sure a service account key file exists at ./service_account_key.json curl -X GET \ "https://businesscommunications.googleapis.com/v1/partners/__PARTNER_ID__" \ -H "Content-Type: application/json" \ -H "User-Agent: curl/business-communications" \ -H "$(oauth2l header --json ./service_account_key.json businesscommunications)"
更新合作夥伴資訊
如要更新合作夥伴資訊,您可以前往 Business Communications 開發人員控制台的「帳戶設定」頁面,或是執行下列指令。
將 PARTNER_ID 替換為您的合作夥伴 ID(可在 Business Communications 開發人員控制台找到合作夥伴 ID),並將該 ID 替換為 將 UPDATED_FIELDS 改成您要更新的欄位名稱。
# This code updates the partner entity. # Read more: https://developers.google.com/business-communications/business-messages/reference/business-communications/rest/v1/partners/patch # Replace the __PARTNER_ID__, __UPDATED_FIELDS__, __FIELD_NAME__, __FIELD_VALUE__ # Make sure a service account key file exists at ./service_account_key.json curl -X PATCH \ "https://businesscommunications.googleapis.com/v1/partners/__PARTNER_ID__?updateMask=__UPDATED_FIELDS__" \ -H "Content-Type: application/json" \ -H "User-Agent: curl/business-communications" \ -H "$(oauth2l header --json ./service_account_key.json businesscommunications)" \ -d '{ "__FIELD_NAME__": "__FIELD_VALUE__" }'
如需格式設定和值選項,請參閱:
partners.patch
。
範例:更新顯示名稱
curl -X PATCH \ "https://businesscommunications.googleapis.com/v1/brands/12345/partners/67890?updateMask=displayName" \ -H "Content-Type: application/json" \ -H "User-Agent: curl/business-communications" \ -H "$(oauth2l header --json /path/to/service/account/key businesscommunications)" \ -d "{ 'displayName': 'XYZ Messaging', }"
範例:更新 Webhook 網址
curl -X PATCH \ "https://businesscommunications.googleapis.com/v1/partners/12345?updateMask=productCapabilities" \ -H "Content-Type: application/json" \ -H "User-Agent: curl/business-communications" \ -H "$(oauth2l header --json /path/to/service/account/key businesscommunications)" \ -d "{ 'productCapabilities': [ { 'product': 'BUSINESS_MESSAGES', 'businessMessagesCapability': { 'webhookUrl': 'https://xyz.messaging.com/webhook', }, }, ], }"
後續步驟
您已成為註冊合作夥伴並啟用 API,接下來可以 以及運用 Business Messages 開發的應用程式若要快速開始使用,請參閱 建立您的第一個虛擬服務專員。