# 同事尚有電郵空位，可以再接即時對話嗎？

同一組同事的電郵與即時對話空位分開核，不把一種餘額借給另一種。

## 先選聯絡類別，再計空位

本例只有 email、message 兩種渠道。空位按所選渠道的上限減已用位計，同事另須有 exports 技能及 active 狀態。已用位超過上限屬無效資料，不會當作負空位。位數不是工時，也不預測客戶會等多久。

已填渠道空位表

| 同事 | 電郵已用／上限 | 對話已用／上限 | 新即時對話 |
| --- | --- | --- | --- |
| A | 2 / 5 | 2 / 2 | 已滿 |
| B | 5 / 5 | 0 / 2 | 可接：2 位 |

## 只按所選渠道核合資格

新即時對話只有 B 符合本例條件；改成新電郵便只有 A 符合。兩者都不把所有渠道空位加起來判斷，畫面逐位列技能、狀態及該渠道空位。

1. 選電郵或即時對話
2. 上限減該類已用位
3. 再核技能與可接狀態
4. 列可接及待核同事

該渠道容量未明便待核，不用另一渠道頂替。

今次聯絡改為 email，哪位符合？

A：5 減 2 有 3 個電郵空位。B 是 5 減 5，即沒有電郵空位。

## 改已用位，技能不會跟着改

可轉渠道或改 A 的對話已用位。A 改成 1 位時，A、B 都可接新對話。「還原例子」會回到 message 及 A 已用 2 位。

對話上限 2 卻填已用 3，便以 CAPACITY_INPUT 拒絕。null 容量屬未知。上限及已用位須是 0 至 1,000 整數，本模型不管手動自接工單，也不量度整體人手工作量。

已有合資格同事，工單卻去錯小組時，可再查隊列規則先後。

## 完整本地記錄與逐項結果

```json
{
  "issuer": "Astera Technology",
  "resource": "ops-route-channel-capacity",
  "locale": "zh-HK",
  "contract": "本例只有 email、message 兩種渠道。空位按所選渠道的上限減已用位計，同事另須有 exports 技能及 active 狀態。已用位超過上限屬無效資料，不會當作負空位。位數不是工時，也不預測客戶會等多久。",
  "input": {
    "channel": "message",
    "required": [
      "exports"
    ],
    "agents": [
      {
        "id": "A",
        "skills": [
          "exports"
        ],
        "status": "active",
        "capacity": {
          "email": {
            "used": 2,
            "limit": 5
          },
          "message": {
            "used": 2,
            "limit": 2
          }
        }
      },
      {
        "id": "B",
        "skills": [
          "exports"
        ],
        "status": "active",
        "capacity": {
          "email": {
            "used": 5,
            "limit": 5
          },
          "message": {
            "used": 0,
            "limit": 2
          }
        }
      }
    ]
  },
  "output": {
    "ok": true,
    "state": "complete",
    "result": {
      "eligible": [
        "B"
      ],
      "unknown": []
    },
    "trace": [
      {
        "id": "A",
        "skills": true,
        "available": true,
        "spare": false,
        "remaining": 0,
        "decision": "ineligible"
      },
      {
        "id": "B",
        "skills": true,
        "available": true,
        "spare": true,
        "remaining": 2,
        "decision": "eligible"
      }
    ]
  },
  "verificationCases": [
    {
      "name": "baseline",
      "input": {
        "channel": "message",
        "required": [
          "exports"
        ],
        "agents": [
          {
            "id": "A",
            "skills": [
              "exports"
            ],
            "status": "active",
            "capacity": {
              "email": {
                "used": 2,
                "limit": 5
              },
              "message": {
                "used": 2,
                "limit": 2
              }
            }
          },
          {
            "id": "B",
            "skills": [
              "exports"
            ],
            "status": "active",
            "capacity": {
              "email": {
                "used": 5,
                "limit": 5
              },
              "message": {
                "used": 0,
                "limit": 2
              }
            }
          }
        ]
      },
      "expected": {
        "ok": true,
        "state": "complete",
        "result": {
          "eligible": [
            "B"
          ],
          "unknown": []
        }
      }
    },
    {
      "name": "material-edit",
      "input": {
        "channel": "email",
        "required": [
          "exports"
        ],
        "agents": [
          {
            "id": "A",
            "skills": [
              "exports"
            ],
            "status": "active",
            "capacity": {
              "email": {
                "used": 2,
                "limit": 5
              },
              "message": {
                "used": 2,
                "limit": 2
              }
            }
          },
          {
            "id": "B",
            "skills": [
              "exports"
            ],
            "status": "active",
            "capacity": {
              "email": {
                "used": 5,
                "limit": 5
              },
              "message": {
                "used": 0,
                "limit": 2
              }
            }
          }
        ]
      },
      "expected": {
        "ok": true,
        "state": "complete",
        "result": {
          "eligible": [
            "A"
          ],
          "unknown": []
        }
      }
    },
    {
      "name": "fresh-boundary",
      "input": {
        "channel": "message",
        "required": [
          "exports"
        ],
        "agents": [
          {
            "id": "A",
            "skills": [
              "exports"
            ],
            "status": "active",
            "capacity": {
              "email": {
                "used": 2,
                "limit": 5
              },
              "message": {
                "used": 3,
                "limit": 2
              }
            }
          },
          {
            "id": "B",
            "skills": [
              "exports"
            ],
            "status": "active",
            "capacity": {
              "email": {
                "used": 5,
                "limit": 5
              },
              "message": {
                "used": 0,
                "limit": 2
              }
            }
          }
        ]
      },
      "expected": {
        "ok": false,
        "error": "CAPACITY_INPUT"
      }
    }
  ],
  "meaningOfNull": "該欄位未知或沒有已建立的值；請按逐項結果判斷。",
  "businessSideEffects": false
}
```
