

本文為英文版的機器翻譯版本，如內容有任何歧義或不一致之處，概以英文版為準。

# Connect Customer 規則無法執行時的錯誤通知
<a name="error-notifications-rule-fails-to-run"></a>

了解特定規則操作在生產環境中失敗的時間，以及導致失敗的原因非常重要。然後，您可以在未來主動緩解這些失敗。

若要取得無法執行之動作的即時洞見，您可以將 Connect Customer Rules 與 Amazon EventBridge 事件整合。例如，當「建立任務」動作因為 **每個執行個體的最大並行使用中任務** 數量達到服務配額而無法執行時，讓您收到通知。發生這種情況時，Connect Customer 會使用 Amazon EventBridge 事件傳送錯誤通知。

[盡可能](https://docs.aws.amazon.com/eventbridge/latest/userguide/eb-service-event.html)發出事件。

## 訂閱 EventBridge 通知
<a name="rule-error-notifications-subscribe"></a>

若要訂閱這些通知，請建立符合下列項目的自訂 EventBridge 規則：
+ 「來源」=「aws.connect」
+ 「詳細資料類型」=「Contact Lens 規則動作執行失敗」

您還可以新增至模式，以便在特定事件代碼發生時通知。如需詳細資訊，請參閱《Amazon EventBridge 使用者指南》**中的[事件模式](https://docs.aws.amazon.com/eventbridge/latest/userguide/filtering-examples-structure.html)。

通知的格式如下範例：

```
{
  "version": "0",
  "id": "8d122163-6c07-f8cb-06e7-373a1bcf8fc6",
  "source": "aws.connect",
  "detail-type": "Amazon Connect Rules Action Execution Failed",
  "account": "123456789012",
  "time": "2022-01-05T01:30:42Z",
  "region": "us-east-1",
  "resources": ["arn:aws:connect:us-east-1:123456789012:instance/cb54730f-5aac-4376-b2f4-7c822889931e"],
  "detail": {
    "ruleId": "7410c94b-21c2-4db0-a707-c6d751edbe8f",
    "actionType": "CREATE_TASK",
    "triggerEvent": "THIRD_PARTY",
    "instanceArn": "arn:aws:connect:us-east-1:123456789012:instance/cb54730f-5aac-4376-b2f4-7c822889931e",
    "reasonCode": "ResourceNotFoundException",
    "error": "ContactFlowId provided does not belong to connect instance",
    "additionalInfo": "{\n  \"message\": \"Not Found\",\n  \"code\": \"ResourceNotFoundException\",\n  \"statusCode\": 404,\n  \"time\": \"2022-01-03T20:23:07.073Z\",\n  \"requestId\": \"048e4403-71c1-47d6-96fc-825744f518e7\",\n  \"retryable\": false,\n  \"retryDelay\": 28.217537834500316\n}"
  }
}
```

## 支援的動作類型
<a name="supported-action-types-rules"></a>
+ `CREATE_TASK`
+ `GENERATE_EVENTBRIDGE_EVENT`
+ `SEND_NOTIFICATION`

如需 `ASSIGN_CONTACT_CATEGORY` 的資訊，請參閱「[錯誤通知：當 Contact Lens 無法分析聯絡 疑難排解](contact-lens-error-notifications.md)」。

## 支援的觸發事件
<a name="supported-trigger-events"></a>
+ `REAL_TIME_CALL`
+ `REAL_TIME_CHAT`
+ `POST_CALL`
+ `POST_CHAT`
+ `THIRD_PARTY`

## 動作失敗的原因代碼
<a name="reason-codes-failed-actions"></a>

當動作失敗時，錯誤通知服務會從支援的動作收集原因代碼。如需任務和 EventBridge 動作失敗之原因代碼的詳細資訊，請參閱下列主題：
+ 如需任務動作失敗的原因代碼，請參閱 *Connect Customer API 參考指南*中的 **StartTaskContact** API 主題中的[錯誤](https://docs.aws.amazon.com/connect/latest/APIReference/API_StartTaskContact.html#API_StartTaskContact_Errors)。
+ 如需 EventBridge 動作失敗的原因代碼，請參閱《Amazon EventBridge API 參考資料指南》**中 **PutEvents** API 主題中的[錯誤](https://docs.aws.amazon.com/eventbridge/latest/APIReference/API_PutEvents.html#API_PutEvents_Errors)。