# 服務紀錄

## 搜尋

```javascript
GET https://{API_DOMAIN}/api/v1/interact-collection
```

```javascript
curl -X GET
    -H "Content-Type: application/json"
    '{"handler_id": 3}'
    https://{API_HOST}/api/v1/interact-collection
```

### Form Data

下表為可使用的過濾條件

| PARAMETER                | REQUIRED | DEFAULT | TYPE     | DESCRIPTION    |
| ------------------------ | -------- | ------- | -------- | -------------- |
| **handler\_id**          | false    | NULL    | Number   | 負責專員的 ID       |
| **handler\_group\_id**   | false    | NULL    | Number   | 此服務紀錄負責專員的員工群組 |
| **contact\_id**          | false    | NULL    | Numbe    | 相關連的客戶 ID      |
| **created\_at\_\_start** | false    | NULL    | Datetime | 服務紀錄開始時間       |
| **created\_at\_\_end**   | false    | NULL    | Datetime | 服務紀錄結束時間       |
| **is\_acw\_completed**   | false    | NULL    | Boolean  | 是否為服務完成狀態      |

### Response

| PROPERTY | TYPE             | DESCRIPTION                                                       |
| -------- | ---------------- | ----------------------------------------------------------------- |
| **data** | Array of objects | [服務紀錄](/developer/api/response-object.md#interact-collection)陣列物件 |
| **meta** | Object           | 頁籤資料                                                              |

```javascript
{
    "data": [
        {
            "id": 491,
            "is_acw_completed": false,
            "first_enter_queue_at": "2021-04-14 13:36:35",
            "first_start_service_at": "2021-05-06 12:23:25",
            "acw_at": null,
            "last_finished_at": null,
            "handler_id": 1,
            "handler": {
                "id": 1,
                "name": "alice chang",
                "first_name": "alice",
                "last_name": "chang",
                "employee_no": "alice",
                "photo_url": null,
                "identity_no": null,
                "job_title_id": -1,
                "department_id": -1,
                "extension_id": 25,
                "extension": {
                    "id": 25,
                    "type": 3,
                    "extension": "8002",
                    "webrtc_password": "540939228002",
                    "description": null,
                    "media_cluster_id": null
                },
                "profile_id": 2195673,
                "group_id": 1,
                "group": {
                    "id": 1,
                    "name": "客服小組",
                    "description": null,
                    "supervisor_id": 4
                },
                "cti_agent_account": "ag8002",
                "cti_agent": {
                    "id": 6,
                    "account": "ag8002",
                    "group_id": null
                },
                "cti_agent_id": 6,
                "created_at": "2019-05-07 12:37:48",
                "updated_at": "2021-01-07 10:28:04"
            },
            "contact_id": null,
            "contact": null,
            "memo": null,
            "bound_type": 1,
            "logs": [
                {
                    "id": 522,
                    "enter_queue_at": "2021-04-14 13:36:35",
                    "service_start_at": "2021-05-06 12:23:25",
                    "service_end_at": null,
                    "service_time": null,
                    "status": 1,
                    "bound_type": 1,
                    "provider_type": "App\\LivechatContentProvider",
                    "provider": {
                        "id": 61,
                        "message": [
                            {
                                "id": 2675,
                                "type": "text",
                                "content": "哈囉",
                                "is_contact": true,
                                "is_system": false,
                                "is_csat": false,
                                "is_kb": false,
                                "kb_id": null,
                                "sender_id": 5,
                                "question": null,
                                "at": "2021-04-14 13:36:35"
                            }
                        ],
                        "media_contact_id": 109,
                        "media_contact": {
                            "id": 109,
                            "name": "b97beb2d-bc60-4a14-86b1-31de6bfe928e",
                            "gender": null,
                            "state": 1,
                            "uuid": "b97beb2d-bc60-4a14-86b1-31de6bfe928e",
                            "token": "5f7916af6cdfba5efdddba0b981a84c4",
                            "is_visible": true,
                            "channel": "livechat.624de7dfabffd4875c0150ee03b65138.b97beb2d-bc60-4a14-86b1-31de6bfe928e"
                        }
                    },
                    "interact_collection_id": 491,
                    "can_listen": true
                }
            ],
            "sponsor_id": null,
            "sponsor": null,
            "campaign_queue": null,
            "campaign_queue_id": null,
            "reasons": [],
            "reason_ids": [],
            "result_id": null,
            "result": {
                "id": null,
                "name": null,
                "is_active": true,
                "description": null,
                "category_id": null,
                "priority": null,
                "created_at": null,
                "updated_at": null
            },
            "media_cluster_id": null,
            "employee_schedule": null,
            "transfer_logs": [],
            "created_at": "2021-05-06 12:23:25"
        },
    ]
```

## 取得單一服務紀錄

```javascript
https://{API_DOMAIN}/api/v1/interact-collection/{interact-collection}
```

```javascript
curl -X GET
    -H "Content-Type: application/json"
    https://{API_HOST}/api/v1/interact-collection/245621
```

### URL Parameters

| PARAMETER | REQUIRED | DEFAULT | TYPE   | DESCRIPTION |
| --------- | -------- | ------- | ------ | ----------- |
| **ID**    | true     | NULL    | Number | 服務紀錄的 ID    |

### Response

| PROPERTY | TYPE   | DESCRIPTION                                                   |
| -------- | ------ | ------------------------------------------------------------- |
| **data** | Object | [服務紀錄](/developer/api/response-object.md#interact-collection) |

```javascript
{
    "id": 495,
    "is_acw_completed": false,
    "first_enter_queue_at": "2021-04-14 13:36:35",
    "first_start_service_at": "2021-04-15 12:23:25",
    "acw_at": null,
    "last_finished_at": null,
    "handler_id": 1,
    "handler": {
        "id": 1,
        "name": "alice chang",
        "first_name": "alice",
        "last_name": "chang",
        "employee_no": "alice",
        "photo_url": null,
        "identity_no": null,
        "job_title_id": -1,
        "department_id": -1,
        "extension_id": 25,
        "extension": {
            "id": 25,
            "type": 3,
            "extension": "8002",
            "webrtc_password": "540939228002",
            "description": null,
            "media_cluster_id": null
        },
        "profile_id": 2195673,
        "group_id": 1,
        "group": {
            "id": 1,
            "name": "客服小組",
            "description": null,
            "supervisor_id": 4
        },
        "cti_agent_account": "ag8002",
        "cti_agent": {
            "id": 6,
            "account": "ag8002",
            "group_id": null
        },
        "cti_agent_id": 6,
        "created_at": "2019-05-07 12:37:48",
        "updated_at": "2021-01-07 10:28:04"
    },
    "contact_id": null,
    "contact": null,
    "memo": null,
    "bound_type": 1,
    "logs": [
        {
            "id": 522,
            "enter_queue_at": "2021-04-14 13:36:35",
            "service_start_at": "2021-05-06 12:23:25",
            "service_end_at": null,
            "service_time": null,
            "status": 1,
            "bound_type": 1,
            "provider_type": "App\\LivechatContentProvider",
            "interact_collection_id": 491,
            "can_listen": true
        }
    ],
    "sponsor_id": null,
    "sponsor": null,
    "campaign_queue": null,
    "campaign_queue_id": null,
    "reasons": [],
    "reason_ids": [],
    "result_id": null,
    "result": {
        "id": null,
        "name": null,
        "is_active": true,
        "description": null,
        "category_id": null,
        "priority": null,
        "created_at": null,
        "updated_at": null
    },
    "media_cluster_id": null,
    "fb_accounts": [
            {
                "id": 2,
                "name": "110906707118012",
                "media_cluster_id": 4,
                "skills": [
                    {
                        "id": 2,
                        "name": "日文",
                        "description": null,
                        "creater_id": 1
                    },
                ],
                "skill_ids": [
                    2,
                ]
            }
        ],
    "line_account_ids": [],
    "line_accounts": [],
    "employee_schedule": null,
    "transfer_logs": [],
    "created_at": "2021-05-06 12:23:25"
},   
```

### 更新服務紀錄

{% hint style="success" %}
此 API 為 **3.06.10** 後版本開放。
{% endhint %}

請求方法: `PUT`\
端點: `/api/v1/interact-collection/{interact-collection}`\
說明: 更新指定服務紀錄的資料。

#### 限制說明

此 API **僅提供修改**，**不提供新增與刪除**。

另有重要限制：\
**僅當服務紀錄尚未完成時才允許修改。**\
若該筆服務紀錄已有 `acw_at` 值，代表該服務已完成，系統將不允許任何異動。現有服務紀錄文件中的回應欄位已可見 `acw_at`，且未完成案例為 `null`。

#### Curl 範例

```bash
curl -X PUT \
     -H "Content-Type: application/json" \
     -d '{
       "memo": "客戶表示已收到處理進度，待後續回覆",
       "cz_cols": [
         {
           "id": 4,
           "value": "123456"
         },
         {
           "id": 7,
           "value": "apple"
         },
         {
           "id": 18,
           "value": ["A", "B", "C"]
         }
       ]
     }' \
     https://{API_HOST}/api/v1/interact-collection/245621
```

#### URL 參數

| 參數名稱 | 必填 | 預設值  | 類型     | 說明         |
| ---- | -: | ---- | ------ | ---------- |
| `id` |  是 | NULL | Number | 服務紀錄的唯一識別碼 |

#### 表單資料

| 欄位名稱      | 必填 | 預設值  | 類型               | 說明            |
| --------- | -: | ---- | ---------------- | ------------- |
| `memo`    |  否 | NULL | String           | 備註文字，字數上限 600 |
| `cz_cols` |  否 | NULL | Array of objects | 自訂欄位資料陣列      |

**`cz_cols` 物件格式**

| 欄位名稱    | 必填 | 預設值  | 類型             | 說明                          |
| ------- | -: | ---- | -------------- | --------------------------- |
| `id`    |  是 | NULL | Number         | 自訂欄位 ID                     |
| `value` |  是 | NULL | String / Array | 自訂欄位值；實際型別依欄位設定而定，可為單一字串或陣列 |

#### `cz_cols` 範例

```json
[
  {
    "id": 4,
    "value": "123456"
  },
  {
    "id": 7,
    "value": "apple"
  },
  {
    "id": 18,
    "value": ["A", "B", "C"]
  }
]
```

#### 回應結構

| 欄位名稱   | 類型     | 說明           |
| ------ | ------ | ------------ |
| `data` | Object | 更新後的單筆服務紀錄資料 |

#### 回應範例

```json
{
  "data": {
    "id": 245621,
    "memo": "客戶表示已收到處理進度，待後續回覆",
    "acw_at": null,
    "cz_cols": [
      {
        "id": 4,
        "value": "123456"
      },
      {
        "id": 7,
        "value": "apple"
      },
      {
        "id": 18,
        "value": ["A", "B", "C"]
      }
    ],
    "updated_at": "2026-03-20 14:30:00"
  }
}
```

#### 失敗情境說明

**服務紀錄已完成，不允許修改**

當服務紀錄已有 `acw_at` 值時，代表該服務已完成，系統應拒絕更新請求。

```json
{
  "message": "This interact-collection has already been ACWed and cannot be edited."
}
```


---

# Agent Instructions: Querying This Documentation

If you need additional information that is not directly available in this page, you can query the documentation dynamically by asking a question.

Perform an HTTP GET request on the current page URL with the `ask` query parameter:

```
GET https://help.firstline.cc/developer/api/service-log.md?ask=<question>
```

The question should be specific, self-contained, and written in natural language.
The response will contain a direct answer to the question and relevant excerpts and sources from the documentation.

Use this mechanism when the answer is not explicitly present in the current page, you need clarification or additional context, or you want to retrieve related documentation sections.
