您可以使用 Google 商家檔案 (GBP) API 新增或更新特定地點的 WhatsApp 和簡訊網址屬性。
商家可透過實作這些屬性,讓客戶使用 WhatsApp 或簡訊與他們聯絡。這可讓商家與 GBP 上的使用者建立直接的溝通管道,以便提升客戶參與度和支援服務。
必要條件
繼續操作之前,請確認您已備妥以下項目:
- Google 商家檔案帳戶和地點
- 變更 Google 商家檔案地點所需的授權憑證
驗證成功狀況
如要新增、更新或刪除屬性,您必須提出 PATCH 要求。成功的 PATCH 要求會傳回 HTTP 200 OK
狀態碼。
要求新增或更新屬性
這個方法適用於 WhatsApp 和簡訊。
如要新增或更新單一屬性,請使用 HTTP PATCH 要求傳送至 location.updateattributes
的 Google 商家檔案 API 端點。
請使用網址中的 attributeMask
查詢參數,指定要鎖定的屬性。要求主體會包含更新的屬性資料。
適用於 WhatsApp
要求如下所示。
PATCH
https://mybusinessbusinessinformation.googleapis.com/v1/locations/{locationId}/attributes?attributeMask=attributes/url_whatsapp
在實作中,請將 {locationId
} 替換為 Google 商家檔案位置的實際 ID。
要求主體 (application/JSON) 會如下所示。
{
"name": "locations/17826990302864573181/attributes",
"attributes": [
{
"name":"attributes/url_whatsapp",
"values":[],
"uriValues": [
{
"uri": "https://wa.me/55555555"
}
]
}
]
}
請將範例中的 55555555
換成商家 WhatsApp 電話號碼 (使用國際格式)。
傳送簡訊
要求如下所示。
PATCH
https://mybusinessbusinessinformation.googleapis.com/v1/locations/{locationId}/attributes?attributeMask=attributes/url_text_messaging
在實作中,請將 {locationId
} 替換為 Google 商家檔案位置的實際 ID。
要求主體 (application/JSON) 會如下所示。
{
"name": "locations/17826990302864573181/attributes",
"attributes": [
{
"name":"attributes/url_text_messaging",
"values":[],
"uriValues": [
{
"uri": "sms:5555555555"
}
]
}
]
}
將範例中的 sms:5555555555
換成商家用於傳送簡訊的電話號碼。
刪除屬性
您可以在 attributeMask
查詢參數中加入 attributes/url_whatsapp
或 attributes/url_text_messaging
,藉此刪除 DELETE 要求中的兩個屬性。要求主體會包含屬性物件陣列,每個屬性物件對應一個要更新或刪除的屬性。
要求如下所示。
DELETE
https://mybusinessbusinessinformation.googleapis.com/v1/locations/{locationId}/attributes?attributeMask=attributes/url_whatsapp,attributes/url_text_messaging3
在實作中,請將 {locationId
} 替換為 Google 商家檔案位置的實際 ID。
要求主體 (application/JSON) 會如下所示。
{
"name": "locations/17826990302864573181/attributes",
"attributes": [
{
"name":"attributes/url_whatsapp",
"values":[],
"uriValues": []
}
]
}
將範例中的 uriValues
替換為空白的方括號。這會重設值,並從 GBP 中移除。