回覆評論,然後編輯或封存回覆

找出可接受商家回覆的評論、發布回覆、確認回覆已送達發布平台,然後修改措辭或封存回覆。

商家回覆會代表您發布至發布平台。API 會立即接受回覆,並以非同步方式傳送,流程如下:選擇可回覆的評論、發布回覆,然後重新讀取以確認結果。

1. 選擇可回覆的評論

列出該地點的評論,並保留 canRespond 為 true 且 responded 為 false 的評論。responseStatus=["PENDING"] 篩選條件會在伺服器端執行第二項檢查;JSON 值必須經過 URL 編碼,這會由 --data-urlencode 處理。

Answerable reviews
curl -G "https://listingsapi.com/api/v4/locations/TG9jYXRpb246MTgwMDI4OQ==/reviews" \-H "Authorization: API $LISTINGSAPI_KEY" \--data-urlencode 'responseStatus=["PENDING"]' \--data-urlencode 'first=25'
JSON
{  "node": {    "id": "9e26d2a8-a6ed-42ea-8454-47d1c92ea841",    "source": "maps.google.com",    "rating": 5,    "content": "nice place for family together",    "responded": false,    "responseCount": 0,    "canRespond": true  }}

對於不接受透過 API 發布商家回覆的來源,canRespond 會是 false。請略過這些評論;嘗試回覆也無法將回覆送達發布平台。撰寫草稿時,列出評論詞句可讓您了解顧客最常提及的內容,以便在回覆中加以回應。

2. 發布回覆

POST /locations/reviews/respond 直接接受主體中的欄位,不需包在 input 中。interactionId 是評論的 id。respondedWith 為選填欄位,若您使用了回覆範本,可在此指定範本名稱。

Respond
curl -X POST https://listingsapi.com/api/v4/locations/reviews/respond \-H "Authorization: API $LISTINGSAPI_KEY" \-H "Content-Type: application/json" \-d '{  "interactionId": "9e26d2a8-a6ed-42ea-8454-47d1c92ea841",  "responseContent": "Thank you for visiting Jenny Home: we are glad you enjoyed your experience!"}'
JSON
{  "data": {    "respondToInteraction": {      "interaction": {        "id": "2090753a-ece6-4837-8336-8494ad308523",        "interactionId": "9e26d2a8-a6ed-42ea-8454-47d1c92ea841",        "content": "Thank you for visiting Jenny Home: we are glad you enjoyed your experience!",        "interactionStatus": "CREATED",        "editedResponse": false      },      "errors": null    }  }}

請保留 interaction.id:這是您日後編輯或封存回覆時所需的 responseId。遭拒的回覆會以 200 傳回,且 data.respondToInteraction 內的 errors 會有值,因此請讀取主體。SDK 在這種情況下會拋出 ValidationError。

3. 確認回覆已送達發布平台

interactionStatus 最初為 CREATED,之後會自行往下更新,無須再呼叫 API。稍候片刻後,依 id 重新讀取評論,並檢查 responded、responseCount 以及 responses[] 內的回覆狀態。

狀態意義
CREATED已接受並排入佇列,等待傳送至發布平台。
COMPLETED已發布至發布平台。部分平台會停留在此狀態。
CONFIRMED已發布並經發布平台確認。
FAILED發布平台已拒絕此回覆。回應中的 remarks 會說明原因。
Re-read
curl -G "https://listingsapi.com/api/v4/reviewDetails" \-H "Authorization: API $LISTINGSAPI_KEY" \--data-urlencode 'interactionIds=["9e26d2a8-a6ed-42ea-8454-47d1c92ea841"]'
JSON
{  "id": "9e26d2a8-a6ed-42ea-8454-47d1c92ea841",  "responded": true,  "responseCount": 1,  "responses": [    {      "id": "2090753a-ece6-4837-8336-8494ad308523",      "content": "Thank you for visiting Jenny Home: we are glad you enjoyed your experience!",      "interactionStatus": "CONFIRMED",      "editedResponse": false    }  ]}

responded: true 搭配狀態為 CONFIRMED 或 COMPLETED 的回覆,表示顧客可以看見該回覆。如果您看到 FAILED,請先讀取回應中的 remarks,了解發布平台提供的原因,再重試。

4. 編輯回覆

POST /locations/reviews/respond/edit 需要兩個 id:reviewId 是評論的 id,responseId 是步驟 2 中回覆的 id。編輯後的內容會重新提交,因此回覆的 interactionStatus 會回到 CREATED,而 editedResponse 會在內容送達後變成 true。

Edit reply
curl -X POST https://listingsapi.com/api/v4/locations/reviews/respond/edit \-H "Authorization: API $LISTINGSAPI_KEY" \-H "Content-Type: application/json" \-d '{  "reviewId": "9e26d2a8-a6ed-42ea-8454-47d1c92ea841",  "responseId": "2090753a-ece6-4837-8336-8494ad308523",  "responseContent": "Thank you again: we have updated our reply to include our new store hours."}'
JSON
{  "data": {    "editResponse": {      "status": "true",      "reviewId": "9e26d2a8-a6ed-42ea-8454-47d1c92ea841",      "responseId": "2090753a-ece6-4837-8336-8494ad308523"    }  }}

編輯內容獲接受時,status 會是字串 "true"。請使用與步驟 3 相同的方式確認新措辭。

5. 封存回覆

POST /locations/reviews/respond/archive 只接受 responseId。封存會從 Listings API 中該互動的 responses 移除回覆。這不會撤回已在 Google 或 Facebook 上公開的回覆,因此請用封存功能清除發布失敗或已被取代的草稿,並使用編輯功能處理已發布的內容。

Archive reply
curl -X POST https://listingsapi.com/api/v4/locations/reviews/respond/archive \-H "Authorization: API $LISTINGSAPI_KEY" \-H "Content-Type: application/json" \-d '{ "responseId": "2090753a-ece6-4837-8336-8494ad308523" }'
JSON
{  "data": {    "archiveResponse": {      "status": "true"    }  }}

封存後,評論的 responseCount 會減少,而 responded 會反映剩餘的回覆。

6. 透過 webhook 接收回覆事件

發布、編輯或封存回覆時,會觸發 interaction.response 事件。承載資料位於 data.interaction 下,其中包含 type: "Response",parent_id 則設為評論的 id,因此您無須再次呼叫,即可將事件與自己的記錄配對。如同 interaction.review,其 location_id 未經正規化,可能為 null。設定方式請參閱使用 webhook 回應事件。

後續步驟