

# Amazon Connect Cases
<a name="cases"></a>

**Tip**  
**New user?** Check out the [Amazon Connect Cases Workshop](https://catalog.workshops.aws/amazon-connect-cases/en-US/1-introduction). This online course guides you through setting up and using Amazon Connect Cases.

Amazon Connect Cases enables your customer service organization to track, collaborate, and resolve customer cases.

A *case* represents a customer's issue. It is created to record the customer's issue, the steps and interactions taken to resolve the customer's issue, and the outcome.

Without doing any integration work, you can enable Cases for your contact center. You can set up cases to be created when contacts come in, and collect information from the customer to display on the case. Alternatively, agents can manually create cases. When an agent accepts a contact, they have context about an issue and can immediately start solving it. You can create tasks to track and route follow up steps to resolve the case. 

The following image shows an example case as it appears in the agent application.

![\[The cases tab in the agent workspace.\]](http://docs.aws.amazon.com/connect/latest/adminguide/images/cases-agent-application-intro.png)


## Getting started with Cases
<a name="getting-started-cases"></a>

We recommend reviewing these topics to help you get started.

**Contact center manager or Admin actions on the Amazon Connect admin website**
+ [Enable Cases](enable-cases.md)
+ [Assign permissions](assign-security-profile-cases.md) 
+ [Create case fields](case-fields.md) and [case templates](case-templates.md) 
+ [Set up a case assignment in Amazon Connect Cases](case-assignment.md)
+ [Automatically monitor and update cases in Amazon Connect Cases](create-alerts-on-cases.md)
+ [Amazon Connect Cases metrics](case-management-metrics.md)
+  [Cases block](cases-block.md) 
+ [Case event streams](case-event-streams.md) 
+ [Cases quotas](amazon-connect-service-limits.md#cases-quotas)
+ [Tag-based access controls](cases-tag-based-access-control.md)

**Agent actions in the agent workspace**
+ [Search cases in Amazon Connect to view customer contact details](search-cases.md)
+ [Edit an existing case](cm-editcases.md) 
+ [Add comments to a case](cm-comments.md) 
+ [Associate a contact with a case](associatecontactandcase.md) 
+ [Create a task from a case](create-task-from-case.md) 

# Enable Cases using the Amazon Connect console
<a name="enable-cases"></a>

This topic explains how to enable Amazon Connect Cases using the Amazon Connect console. To use the API, see [Amazon Connect Cases API Reference](https://docs.aws.amazon.com/cases/latest/APIReference/Welcome.html).

**Tip**  
A case is always associated with a customer profile. You must have Customer Profiles enabled. Check your instance settings in the Amazon Connect console, and if a Customer Profiles domain does not yet exist, see [Enable Customer Profiles for your Amazon Connect instance](enable-customer-profiles.md).

## Requirements
<a name="cases-iam-requirements"></a>

If you're using custom IAM policies to manage access to the Amazon Connect Cases, your users need the following IAM permissions to onboard to Cases using the Amazon Connect console:
+ `connect:ListInstances`
+ `ds:DescribeDirectories`
+ `connect:ListIntegrationAssociations`
+ `cases:GetDomain`
+ `cases:CreateDomain`
+ `connect:CreateIntegrationAssociation`
+ `connect:DescribeInstance`
+ `iam:PutRolePolicy`

For more information, see [Required permissions for using custom IAM policies to manage Amazon Connect Cases](required-permissions-iam-cases.md).

## How to enable Amazon Connect Cases
<a name="how-to-enable-cases"></a>

1. Open the Amazon Connect console at [https://console.aws.amazon.com/connect/](https://console.aws.amazon.com/connect/).

1. On the instances page, choose the instance alias. The instance alias is also your **instance name**, which appears in your Amazon Connect URL. The following image shows the **Amazon Connect virtual contact center instances** page, with a box around the instance alias.  
![\[The Amazon Connect virtual contact center instances page, the instance alias.\]](http://docs.aws.amazon.com/connect/latest/adminguide/images/instance.png)

1. On the left navigation menu, choose **Cases** under the **Applications** section. If you don't see this option, it may not be available in your Region. For information about where Cases is available, see [Cases availability by Region](regions.md#cases_region). 

1. Choose **Enable cases** to get started.

1. On the **Cases** page, choose **Add domain**. 

1. On the **Add domain** page, enter a unique, friendly name that's meaningful to you, such as your organization name.

1. Choose **Add domain**. The domain is created.

   If the domain is not created, choose **Try again**. If that doesn't work, contact Support.

**Tip**  
To delete a Cases domain, use the [DeleteDomain](https://docs.aws.amazon.com/connect/latest/APIReference/API_connect-cases_DeleteDomain.html) API. 

## Next steps
<a name="enable-cases-next-steps"></a>

After your cases domain is created, do the following:

1. [Assign security profile permissions](assign-security-profile-cases.md) to agents and call center managers.

1. [Create case fields](case-fields.md). Fields are the building blocks of your case templates.

1. [Create case templates](case-templates.md). Case templates are forms that agents complete and reference in the agent application. Templates ensure the right information is collected and referenced for different types of customer issues.

1. Optionally, [enable attachments](enable-attachments.md) across your Amazon Connect instance. This step allows your agents to upload files to cases. For more information on the Files API, see the [StartAttachedFileUpload](https://docs.aws.amazon.com/connect/latest/APIReference/API_StartAttachedFileUpload.html) API documentation.
**Note**  
Ensure that you have the `cases:CreateRelatedItem ` permission for your IAM entity. For more information on Cases permissions, see [Actions, resources, and condition keys for Amazon Connect Cases](https://docs.aws.amazon.com/service-authorization/latest/reference/list_amazonconnectcases.html).

1. Optionally, add the [Cases](cases-block.md) block to your flows. This block enables you to get, update, or create cases automatically.

1. Optionally, set up [case event streams](case-event-streams.md) to get near real-time updates when cases are created or modified.

1. Optionally, set up a [Connect AI agents domain](ai-agent-initial-setup.md) and [Configure your flow](ai-agent-initial-setup.md#enable-ai-agents-step4) to generate AI-powered Case Summaries in the agent workspace

1. Optionally, [set up tag-based access controls for cases](cases-tag-based-access-control.md).

# Security profile permissions for Amazon Connect Cases
<a name="assign-security-profile-cases"></a>

This topic describes the security profiles permissions that are required to access and use Amazon Connect Cases. For a list of Cases permissions and their API name, see [List of security profile permissions in Amazon Connect](security-profile-list.md).

## Required Cases permissions
<a name="required-cases-permissions"></a>

The following image shows the security permissions used to manage access to [Amazon Connect Cases](cases.md) functionality:

![\[Cases security profile permissions.\]](http://docs.aws.amazon.com/connect/latest/adminguide/images/cases-security-profile-permissions.png)


## Required Customer Profiles permissions
<a name="required-cases-cp-permissions"></a>

To use Amazon Connect Cases, your users also need permissions to Customer Profiles permissions, as shown in the following image.

![\[Customer Profiles security profile permissions.\]](http://docs.aws.amazon.com/connect/latest/adminguide/images/cases-customer-profiles-permissions.png)


## Required queue, quick connect, and user view permissions
<a name="required-cases-queue-permissions"></a>

To be able to assign case ownership to users or queues, agents need permissions to view queues, quick connects, and users. To be able to view the author name on comments, agents need permission to view users. These permissions are shown in the following two images. 

![\[Queue and quick connect View permissions.\]](http://docs.aws.amazon.com/connect/latest/adminguide/images/cases-security-queue-permissions.png)


![\[User View permissions.\]](http://docs.aws.amazon.com/connect/latest/adminguide/images/cases-security-user-permissions.png)


## Description of Cases permissions
<a name="case-permissions-description"></a>
+ **Audit History**: Manage who can access the audit history of cases in the agent application.
  + **View Audit History**: Allows the user to view the audit history of cases in the agent application.
+ **Cases**: Manage who can access cases by using the agent application.
  + **View case**: Allows the user to view and search cases in the agent application. This includes viewing case data (for example, status, title, summary), contact history (for example, calls, chats, tasks with information such as start time, end time, duration, etc.), and comments.
  + **Edit case**: Allows the user to edit cases, which includes editing case data (for example, update case status), add comments, and associate contacts to cases.
  + **Create case**: Allows the user to create new cases, and associate contacts to cases.
+ **Case Fields**: Manage who can configure case fields by using the Amazon Connect admin website.
  + **View Case Fields**: Allows users to view the case fields page and all of the existing case fields (could be system or custom).
  + **Edit Case Fields**: Allows users to edit any of the case fields (for example, change title, description, single-select options).
  + **Create Case Fields**: Allows users to create new case fields.
+ **Case Templates**: Manage who can configure case templates by using the Amazon Connect admin website.
  + **View Case Fields**: Allows users to view the case fields page and all of the existing case fields (could be system or custom).
  + **Edit Case Fields**: Allows users to edit any of the case fields (for example, change title, description, single-select options).
  + **Create Case Fields**: Allows users to create new case fields.

When users have permissions to **View Case Fields** and **View Case Templates**, they will see the **Case fields** and **Case templates** options in their left navigation menu, as shown in the following image: 

![\[The navigation menu, the agent applications option.\]](http://docs.aws.amazon.com/connect/latest/adminguide/images/cases-agent-application-case-fields-menu.png)


## Required Agent Application permissions
<a name="required-agent-application-permissions"></a>

To be able to generate a summary for a case in the agent application, agents need permission to view AI agents in the agent application, as shown in the following image.

![\[Screenshot showing AI agent permissions in security profile.\]](http://docs.aws.amazon.com/connect/latest/adminguide/images/case-summary-ai-agent-permissions.png)


## Required Cases and Agent Applications permissions to generate AI-powered case summarization
<a name="required-cases-agent-app-ai-summary-permissions"></a>

To generate an AI-powered case summary, agents need View permissions on Cases and Audit History, and View permissions on Connect Assistant under Agent Applications.

**To save an AI-powered case summary, agents additionally need Edit permission on Cases.**

![\[Cases permissions.\]](http://docs.aws.amazon.com/connect/latest/adminguide/images/cases-permissions.png)


![\[Agent Applications permissions.\]](http://docs.aws.amazon.com/connect/latest/adminguide/images/agent-applications-permissions.png)


# Required permissions for using custom IAM policies to manage Amazon Connect Cases
<a name="required-permissions-iam-cases"></a>

If you're using custom IAM policies to manage access to the Amazon Connect Cases, your users need some or all of the permissions listed in this article, depending on the tasks they need to do.

## View Cases domain details
<a name="view-cases-domain-iam"></a>

There are two options for granting users IAM permissions to view Cases domain details on the Amazon Connect console.

### Option 1: Minimum required IAM permissions
<a name="option1-view-cases-domain-iam"></a>

To view Cases domain details in the Amazon Connect console, users must have the following IAM permissions:
+ `connect:ListInstances`
+ `ds:DescribeDirectories`
+ `connect:ListIntegrationAssociations`
+ `cases:GetDomain`

Following is a sample IAM policy with these permissions:

------
#### [ JSON ]

****  

```
{
    "Version":"2012-10-17",		 	 	 
    "Statement": [
        {
            "Sid": "AllowsViewingConnectConsole",
            "Effect": "Allow",
            "Action": [
                "connect:ListInstances",
                "ds:DescribeDirectories"
            ],
            "Resource": "*"
        },
        {
            "Sid": "ListIntegrationAssociations",
            "Effect": "Allow",
            "Action": [
                "connect:ListIntegrationAssociations"
            ],
            "Resource": "*"
        },
        {
            "Sid": "CasesGetDomain",
            "Effect": "Allow",
            "Action": [
                "cases:GetDomain"
            ],
            "Resource": "*"
        }
    ]
}
```

------

Note the following:
+ `cases:GetDomain` Action is required on Resource `*`
+ `connect:ListIntegrationAssociations` action supports the `instance` resource type. See the table in [Actions defined by Amazon Connect](https://docs.aws.amazon.com/service-authorization/latest/reference/list_amazonconnect.html#amazonconnect-actions-as-permissions).

### Option 2: Update the existing Amazon Connect policy with `cases:GetDomain` and `profile:SearchProfiles`
<a name="option2-view-cases-domain-iam"></a>

Include the [AmazonConnectReadOnlyAccess](security-iam-amazon-connect-permissions.md#amazonconnectreadonlyaccesspolicy) policy, and add `cases:GetDomain`, as shown in the following example. 

------
#### [ JSON ]

****  

```
{
    "Version":"2012-10-17",		 	 	 
    "Statement": [
        {
            "Sid": "CasesGetDomain",
            "Effect": "Allow",
            "Action": [
                "cases:GetDomain"
            ],
            "Resource": "*"
        }        
    ]
}
```

------

## Onboard to Cases
<a name="onboard-cases-iam"></a>

There are two options for granting users IAM permissions to onboard to Cases using the Amazon Connect console.

### Option 1: Minimum required permissions
<a name="option1-onboard-cases-iam"></a>

To onboard to Cases by using the Amazon Connect console, users must have the following IAM permissions:
+ `connect:ListInstances`
+ `ds:DescribeDirectories`
+ `connect:ListIntegrationAssociations`
+ `cases:GetDomain`
+ `cases:CreateDomain`
+ `connect:CreateIntegrationAssociation`
+ `connect:DescribeInstance`
+ `iam:PutRolePolicy`
+ `profile:SearchProfiles`

Following is a sample IAM policy with these permissions:

------
#### [ JSON ]

****  

```
{
    "Version":"2012-10-17",		 	 	 
    "Statement": [
        {
            "Sid": "AllowsViewingConnectConsole",
            "Effect": "Allow",
            "Action": [
                "connect:ListInstances",
                "ds:DescribeDirectories"
            ],
            "Resource": "*"
        },
        {
            "Sid": "ListIntegrationAssociations",
            "Effect": "Allow",
            "Action": [
                "connect:ListIntegrationAssociations"
            ],
            "Resource": "*"
        },
        {
            "Sid": "CasesGetDomain",
            "Effect": "Allow",
            "Action": [
                "cases:GetDomain"
            ],
            "Resource": "*"
        },
        {
            "Sid": "CasesCreateDomain",
            "Effect": "Allow",
            "Action": [
                "cases:CreateDomain"
            ],
            "Resource": "*"
        },
        {
            "Sid": "CreateIntegrationAssociationsAndDependencies",
            "Effect": "Allow",
            "Action": [
                "connect:CreateIntegrationAssociation",
                "connect:DescribeInstance"
            ],
            "Resource": "*"
        },
        {
            "Sid": "AttachAnyPolicyToAmazonConnectRole",
            "Effect": "Allow",
            "Action": "iam:PutRolePolicy",
            "Resource": "arn:aws:iam::*:role/aws-service-role/connect.amazonaws.com/AWSServiceRoleForAmazonConnect*"
        },
        {
            "Sid": "ProfileSearchProfiles",
            "Effect": "Allow",
            "Action": [
                "profile:SearchProfiles"
            ],
            "Resource": "*"
        }
    ]
}
```

------

Note the following:
+ `cases:GetDomain` Action is required on Resource `*`
+ You can scope the permissions to specific Amazon Connect tasks by using the information in [Actions, resources, and condition keys for Amazon Connect](https://docs.aws.amazon.com/service-authorization/latest/reference/list_amazonconnect.html).
+ `profile:SearchProfiles` Action is required because the `CreateCase` API calls the `SearchProfiles` API to search for customer profiles to validate against, and then associate the profile with the case.

### Option 2: Use a combination of existing policies
<a name="option2-onboard-cases-iam"></a>

The following combination of policies will also work:
+ **AmazonConnect\$1FullAccess** policy
+ `iam:PutRolePolicy` to modify the service-linked role. For an example, see [AWS managed policy: AmazonConnect\$1FullAccess policy](security-iam-amazon-connect-permissions.md#amazonconnectfullaccesspolicy). 
+ The following IAM policy:

------
#### [ JSON ]

****  

  ```
  {
      "Version":"2012-10-17",		 	 	 
      "Statement": [
          {
              "Sid": "CasesGetDomain",
              "Effect": "Allow",
              "Action": [
                  "cases:GetDomain",
                  "cases:CreateDomain"
              ],
              "Resource": "*"
          },
          {
              "Sid": "ProfileSearchProfiles",
              "Effect": "Allow",
              "Action": [
                  "profile:SearchProfiles"
              ],
              "Resource": "*"
          }
      ]
  }
  ```

------

# Create case fields in Amazon Connect Cases
<a name="case-fields"></a>

*Case fields* are the building blocks for *case templates*. You create all of the possible fields of information (for example, VIN number, policy number, make/model of car) that you want agents to collect for a given customer issue. 

 After you create case fields, you can create case templates.

There are two types of case fields:
+ [System case fields](#system-case-fields): Amazon Connect provides system fields. You cannot change the name or description.
+ [Custom case fields](#custom-case-fields): You can create custom case fields that are specific for your business. You must name the case field, and optionally provide a description. Note that the description appears only in the Amazon Connect admin website. It doesn't appear to agents.

## How to create case fields
<a name="how-to-create-case-fields"></a>

1. Log in to the Amazon Connect admin website with an **Admin** account, or an account assigned to a security profile that has permissions to create fields. For a list of required permissions, see [Security profile permissions for Amazon Connect Cases](assign-security-profile-cases.md).

1. Verify the quota for case fields and request an increase if needed. For more information, see [Amazon Connect Cases service quotas](amazon-connect-service-limits.md#cases-quotas).

1. On the left navigation menu, choose **Agent applications**, **Case fields**.

1. The first time you create new fields, you'll notice several [system fields](#system-case-fields) are already present. You cannot change the name of these fields, but in some cases you can edit them. 

   For example, **Case Id** is a system field. When a case is created, Amazon Connect adds a case ID automatically, and you cannot change it. **Case reason** is also a system field but you can edit it and enter reasons that are specific to your contact center.

1. Choose **\$1 New field**.

1. Select the type of field you want to create. For example, you might choose **Text** if you want agents to be able to enter free form notes.

1. Assign a name to the field. It will appear to agents in the agent application.

1. Optionally, provide a description. It appears only to admins on the Amazon Connect admin website. It does not appear to agents in the agent application.

1. Choose **Save**.

1. When you're done adding fields, you're ready to [create a template](case-templates.md).

## System case fields
<a name="system-case-fields"></a>

Amazon Connect provides system fields. You cannot change the name or description of a system field.

The following table lists the system case fields:


| Field name | Field ID (how you call the field in the API) | Field type | Description | Where the data comes from | 
| --- | --- | --- | --- | --- | 
|  Assigned queue  |  assigned\$1queue  | text | The Amazon Connect queue that is assigned to a case | Agent | 
|  Assigned user  |  assigned\$1user  | text | The Amazon Connect user who is assigned to a case | Agent | 
|  Case ID  |  case\$1id  | text | Unique Identifier of the case in UUID format (for example, 689b0bea-aa29-4340-896d-4ca3ce9b6226) | Amazon Connect | 
|  Case Reason  |  case\$1reason  | single-select | The reason for opening the case | Agent | 
|  Created By  |  created\$1by  | user | The identity of the user who created the case. | Amazon Connect | 
|  Customer  |  customer\$1id  | text | The full ARN of the customer profile identified for the case is required when using the API. On the Cases: Fields page, the customer's name is displayed. | Amazon Connect | 
|  Date/Time Closed  |  last\$1closed\$1datetime  | date-time | The date and time the case was last closed. It does not guarantee that a case is closed. If a case is reopened, this field contains the date/time stamp of the last time the status was changed to closed. | Amazon Connect | 
|  Date/Time Opened  |  created\$1datetime  | date-time | The date and time the case was opened. | Amazon Connect | 
|  Date/Time Updated  |  last\$1updated\$1datetime  | date-time | The date and time the case was last updated. | Amazon Connect | 
|  Last Updated User  |  last\$1updated\$1user  | user | The identity of the user who performed the last update on the case. | Amazon Connect | 
|  Reference number  |  reference\$1number  | text | A friendly number for the case in 8-digit numeric format. Reference numbers (unlike the Case ID) are not guaranteed to be unique. We recommend that you identify the customer and then collect the reference number to correctly find the right case.  | Amazon Connect | 
|  Status  |  status  | single-select | Current status of the case  | Agent | 
|  Summary  |  summary  | text | Summary of the case  | Agent | 
|  Title  |  title  | text | Title of the case  | Agent | 

## Custom case fields
<a name="custom-case-fields"></a>

You can create custom case fields that are specific for your business. You must name the case field, and optionally provide a description. Note that the description appears only in the Amazon Connect admin website. It doesn't appear to agents.

You can create fields that are type: number, text, single-select, true/false, datetime, and URL.

### Text fields
<a name="text-case-fields"></a>

Text fields allow agents to capture and store textual information related to customer cases. These fields are flexible and can accommodate various types of text-based data, from brief notes to detailed descriptions.

When creating a text field in the Amazon Connect admin website, you can select from two input display options under the **Input display** section to best suit your data collection needs:

**Single line text fields:** Single line text fields display text in a single horizontal line and have a character limit of 500 characters. They are ideal for capturing concise information such as customer reference numbers, product names, brief case summaries, and contact names.

**Multi-line text fields:** Multi-line text fields expand vertically to accommodate multiple lines of text and have a character limit of 4,100 characters. They are suitable for capturing detailed information such as case descriptions, customer feedback, resolution steps, and agent observations.

### Single-select fields
<a name="single-select-case-fields"></a>

For single-select case fields, whether system or custom, you can add value options that the field can take. For example, you can add options to the single-select system field Case reason such as **General inquiry**, **Billing issue**, or **Product defect**, that reflect the types of issues in your contact center. 

#### About the Status field
<a name="status-single-select-field"></a>

You can add options to the single-select **Status** field, such as **Investigating** or **Escalated to manager**. The field comes with two options, **Open** and **Closed**, which cannot be changed.

#### Active/inactive field options
<a name="active-inactive-single-select-field"></a>

Single-select case fields can be active or inactive.

![\[The Active and Inactive statuses.\]](http://docs.aws.amazon.com/connect/latest/adminguide/images/cases-single-select-active-inactive.png)

+ **Active**: If a field option is active, it means that the field can be given that option. For example, based on the following image, the Status field can be set to **Closed**, **Open**, or **Pending**, as these are the only active options.
+ **Inactive**: If you make the **Pending** option inactive, then the field can no longer be given that option. Any existing cases remain unchanged and can still have the status as **Pending**.

Single-select options have two parts:

1. Option name (shown to agents): The label that is displayed to agents in the agent application.

1. Option value (internal reference): The data that's collected. For example, for AWS Region, you may want to display **US West (Oregon)** but collect the data as **PDX**. 

   Field options appear to the agent in alphabetical order. 

![\[The Active and Inactive statuses.\]](http://docs.aws.amazon.com/connect/latest/adminguide/images/cases-single-select-names.png)


# Add case field conditions to a case template in Amazon Connect
<a name="case-field-conditions"></a>

Case field conditions in Amazon Connect make your case templates more dynamic and user-friendly. There are three types of case field conditions: Conditionally required, Hidden field conditions, and Dependent field options. Conditionally required fields allow you to enforce field completion based on specific criteria. Hidden field conditions let you show or hide fields based on other field values. Dependent field options create cascading dropdown menus where available choices depend on previous selections. These features help streamline agent workflows, reduce data entry errors, and ensure agents see only relevant information when managing cases. 

# Conditionally required
<a name="case-field-conditionally"></a>

You can streamline how agents populate case fields, and reduce data entry errors, by conditionally requiring specific fields.

To make a field conditionally required, you first set up a field condition. Then, on a case template, choose which field the case field condition should apply to. 

For example, you may want to enforce that **Agent Handle Reason** is required if a case is updated after it was created. To achieve this you would:

1. Create a case field condition based on whether the [Date/Time Opened](case-fields.md) field is not blank.

1. Apply the case field condition to the **Agent Handle Reason** field on the case template.

The following image shows an example **Edit case** page where this requirement is being enforced.

![\[The Edit case page on the agent workspace, the Agent Handle Reason field as required.\]](http://docs.aws.amazon.com/connect/latest/adminguide/images/cfc-agentworkspace.png)


This feature provides a lot of flexibility. Following are few other examples you can set up:
+ If Status = Closed, then the Close Reason field must be populated.
+ If Case Reason = Refund, then the Amount field is required.
+ If Country = USA, the State field is required.

You can apply case field conditions to multiple fields on a template.

**Topics**
+ [Step 1: Create case field conditions](#step1-create-case-field-condition)
+ [Step 2: Add the case field conditions to a template](#step2-add-casefieldcondition-template)
+ [Example field case conditions](#example-case-conditions)
+ [APIs to create field case conditions](#case-conditions-apis)

## Step 1: Create case field conditions
<a name="step1-create-case-field-condition"></a>

1. Log in to the Amazon Connect admin website with an **Admin** account, or an account assigned to a security profile that has the following permission in it's security profile: **Cases** - **Case Templates** - **Create**.

1. On the left navigation menu, choose **Agent applications**, **Case field conditions**.

1. Choose **New Field Condition**.

1. On the **Create new field condition** page, use the **Source field** dropdown list to choose the field you want to validate, as shown in the following image:   
![\[The Conditions section, the Source field dropdown list.\]](http://docs.aws.amazon.com/connect/latest/adminguide/images/cfc-choose-field-1.png)

1. Choose the operator and the value to check.

   For example, the following image shows when the **State** field equals **New York**, a case field will be required.   
![\[The Create new field condition page, example settings to make a field required.\]](http://docs.aws.amazon.com/connect/latest/adminguide/images/cfc-country-2.png)

   The condition is configured as follows:
   + **Source** = **State**
   + **Operator** = **equals**
   + **Value** = **New York**
   + **Required** is selected. A case field that you specify in [Step 2](#step2-add-casefieldcondition-template) will be required when this condition is met.

1. You can add up to 5 field conditions and choose whether they are fulfilled by AND or OR conditions, by clicking the Add Condition button.  
![\[A conditionally required field with 3 conditions configured.\]](http://docs.aws.amazon.com/connect/latest/adminguide/images/conditionally-required-with-3-conditions.png)

1. For **Fallback condition**, if the condition is not met, choose this field to set the default experience. 

   For example, if you leave **Fallback condition** unselected, when **Country** does not equal **USA**, then the field this condition is applied to won't be required. So, if you apply the condition to **State**, but the **Country = France**, the **State** field won't be required.

1. Choose **Save**, and then proceed to the next step to add the condition to your template.

## Step 2: Add case field conditions to a template
<a name="step2-add-casefieldcondition-template"></a>

In this step, you specify which case fields the condition will apply to.

1. Log in to the Amazon Connect admin website with an **Admin** account, or an account assigned to a security profile that has the following permission in it's security profile: **Cases** - **Case Templates** - **Create** or **Edit**. 

1. On the left navigation menu, choose **Agent applications**, **Case templates**.

1. Choose the case template you want to apply the condition to. 

   You may want the condition to apply to one template but not others. For example, you may want a **Close reason** condition to apply to escalations, but not to general inquires. 

1. In the **Fields** section, choose the settings icon next to the field you want to apply the condition to. The following image shows the settings icon for the **State** field.   
![\[The case templates page, the settings icon for a field.\]](http://docs.aws.amazon.com/connect/latest/adminguide/images/cfc-gear-icon-2.png)

1. In the **Modify field conditions for** [*field*] use the dropdown box to choose the condition you want to apply to the field. 

   In the following image, the **USA requirements** condition is going to be applied to the **State** field.  
![\[The Modify field conditions dialog box.\]](http://docs.aws.amazon.com/connect/latest/adminguide/images/cfc-choose-condition-2.png)

1. Choose **Apply**, and then choose **Save** to save the change to the template.

   The status page indicates which conditions have been applied to a field. The following image shows the **USA requirements** condition is applied to the **State** field.  
![\[The Fields on a template, the Required column.\]](http://docs.aws.amazon.com/connect/latest/adminguide/images/cfc-condition-applied-2.png)

## Example case field conditions
<a name="example-case-conditions"></a>

### Example 1: Require agents to enter a reason for closing a case
<a name="example1-case-conditions"></a>

1. Create the following condition:
   + If **Status** is **Closed**, then a case field will be required. If **Status** is not **Closed**, then a case field will be optional. 

   The following image shows how to set up this condition.   
![\[The Create new field condition page, example settings to make a field optional.\]](http://docs.aws.amazon.com/connect/latest/adminguide/images/cfc-example1-2.png)

1. Assign this condition to the **Closed Reason** field on the cases template. 

1. Result: When agents save a case and the **Closed Reason** field is blank, they will be prompted to enter a value.

### Example 2: Require agents to provide a reason every time they update a case
<a name="example2-case-conditions"></a>

1. Create the following condition:

   If the **Date/Time Created** field does not equal blank, then a case field will be required. If the **Date/Time Created** field is empty, then that case field is optional. The following image shows how to set up this condition.  
![\[The Create new field condition page, example settings to make a field optional.\]](http://docs.aws.amazon.com/connect/latest/adminguide/images/cfc-example2-2.png)

1. Assign this condition to the **Agent Handle Reason** field on the cases template.

1. Result: When agents save a case and the **Agent Handle Reason** is blank, they will be prompted to enter a value.

### Example 3: Require agents to provide a reason when they assign a case to the Escalation queue
<a name="example3-case-conditions"></a>

1. Create the following condition:

   If the **Assigned Queue** field equals the **Escalation queue** Amazon Resource Name (ARN), then a case field will be required. If the **Assigned Queue** field does not equal the **Escalation queue** ARN, then that case field is optional. 
**Tip**  
You can copy the ARN of a queue from the **Queues** page.

   The following image shows how to set up this condition.  
![\[The Create new field condition page, example settings to make a field optional.\]](http://docs.aws.amazon.com/connect/latest/adminguide/images/cfc-escalationqueue-2.png)

1. Assign this condition to the **Escalation reason** field on the cases template.

1. Result: When agents assign a case to the **Escalation queue**, and the **Escalation reason** field is blank, they will be prompted to enter a value.

## APIs to create case field conditions
<a name="case-conditions-apis"></a>

Use the following APIs to programmatically create case field conditions and associate them to a template:
+ [CreateCaseRule](https://docs.aws.amazon.com/connect/latest/APIReference/API_connect-cases_CreateCaseRule.html): Creates the case field condition.
+ [CreateTemplate](https://docs.aws.amazon.com/connect/latest/APIReference/API_connect-cases_CreateTemplate.html) or [UpdateTemplate](https://docs.aws.amazon.com/connect/latest/APIReference/API_connect-cases_UpdateTemplate.html): Associate the case field condition with the case template.

# Hidden field conditions
<a name="case-field-hidden"></a>

You can create dynamic case templates that show or hide fields based on other field values, improving the user experience and reducing complexity for agents.

To make a field conditionally hidden, you first set up a hidden field condition. Then, on a case template, choose which field the hidden field condition should apply to.

For example, you may want to hide the **Advanced Configuration** field unless the user selects **Advanced** as the **User Level**. To achieve this you would:

1. Create a hidden field condition based on whether the **User Level** field equals **Advanced**.

1. Apply the hidden field condition to the **Advanced Configuration** field on the case template.

This feature provides a lot of flexibility. Here are a few other examples you can set up:
+ If Case Type = Basic, hide the Priority field.
+ If Customer Type = Internal, hide the Billing Address fields.
+ If Status = Draft, hide the Approval fields.

You can apply hidden field conditions to multiple fields on a template.

## Step 1: Create hidden field conditions
<a name="step1-create-hidden-field-condition"></a>

1. Log in to the Amazon Connect admin website with an **Admin** account, or an account assigned to a security profile that has the following permission in it's security profile: **Cases** - **Case Templates** - **Create**.

1. On the left navigation menu, choose **Agent applications**, **Case field conditions**.

1. Choose **New Field Condition**.

1. On the **Create new field condition** page, select **Hidden** as the condition type.

1. Use the **Source field** dropdown list to choose the field you want to evaluate for the condition.

1. You can add up to 5 field conditions and choose whether they are fulfilled by AND or OR conditions, by clicking the Add Condition button.

1. Configure the visibility settings:
   + **Default visibility**: Choose whether the field is hidden or shown when no conditions match
   + **Show field when**: Define the conditions that will show the field

1. Choose the operator and the value to check.

1. You can add up to 5 field conditions and choose whether they are fulfilled by AND or OR conditions, by clicking the Add Condition button.  
![\[A hidden field condition with 3 conditions configured.\]](http://docs.aws.amazon.com/connect/latest/adminguide/images/conditionally-hidden-with-3-conditions.png)

1. Choose **Save**, and then proceed to the next step to add the condition to your template.

## Step 2: Add hidden field conditions to a template
<a name="step2-add-hidden-field-condition-template"></a>

In this step, you specify which case fields the hidden condition will apply to.

1. Log in to the Amazon Connect admin website with an **Admin** account, or an account assigned to a security profile that has the following permission in it's security profile: **Cases** - **Case Templates** - **Create** or **Edit**.

1. On the left navigation menu, choose **Agent applications**, **Case templates**.

1. Choose the case template you want to apply the condition to.

1. In the **Fields** section, choose the settings icon next to the field you want to apply the condition to.

1. In the **Modify field conditions for** [field] use the dropdown box to choose the hidden condition you want to apply to the field.

1. Choose **Apply**, and then choose **Save** to save the change to the template.

## Example hidden field conditions
<a name="example-hidden-field-conditions"></a>

### Example 1: Hide advanced options unless user selects advanced mode
<a name="example1-hidden-conditions"></a>

1. Create the following condition: If **User Level** equals **Advanced**, then show the field. Otherwise, hide the field by default.

1. Assign this condition to the **Advanced Configuration** field on the cases template.

1. Result: **Advanced Configuration** will only be visible when agents select **Advanced** in the **User Level**.

### Example 2: Hide billing fields for internal customers
<a name="example2-hidden-conditions"></a>

1. Create the following condition: If **Customer Type** does not equal **Internal**, then show the field. If **Customer Type** equals **Internal**, hide the field.

1. Assign this condition to the **Billing Address** field on the cases template.

1. Result: **Billing Address** will be hidden when the **Customer Type** is set to **Internal**.

### Example 3: Hide approval fields for draft cases
<a name="example3-hidden-conditions"></a>

1. Create the following condition: If **Status** does not equal **Draft**, then show the field. If **Status** equals **Draft**, hide the field.

1. Assign this condition to the **Approval** field on the cases template.

1. Result: **Approval** will be hidden until the case **Status** changes from **Draft**.

## APIs for hidden field conditions
<a name="hidden-field-conditions-apis"></a>

Use the following APIs to programmatically create hidden field conditions:
+ [CreateCaseRule](https://docs.aws.amazon.com/connect/latest/APIReference/API_connect-cases_CreateCaseRule.html): Creates the hidden field condition using the "hidden" rule type.
+ [CreateTemplate](https://docs.aws.amazon.com/connect/latest/APIReference/API_connect-cases_CreateTemplate.html) or [UpdateTemplate](https://docs.aws.amazon.com/connect/latest/APIReference/API_connect-cases_UpdateTemplate.html): Associate the hidden field condition with the case template.

# Dependent field options
<a name="case-field-dependent"></a>

You can create cascading dropdown fields where the options in a single-select field (target) depend on the selection made in another field (source), providing a more intuitive and organized experience for agents.

To set up dependent field relationships, you first create a field options condition that defines the relationship between a source field and a target field. Then, on a case template, apply this condition to control the available options.

For example, you may want the **State/Province** field options to change based on the selected **Country**. To achieve this you would:

1. Create a field options condition that maps country selections to their respective states/provinces.

1. Apply the field options condition to the **State/Province** field on the case template.

This feature provides a lot of flexibility. Here are a few other examples you can set up:
+ If Product Category = Electronics, show subcategories: Computers, Phones, Tablets, Accessories.
+ If Department = IT, show relevant issue types: Hardware, Software, Network, Security.
+ If Service Type = Premium, show premium-specific options in the Service Level field.

You can apply field options conditions to multiple dependent field pairs on a template.

## Step 1: Create field options conditions
<a name="step1-create-field-options-condition"></a>

1. Log in to the Amazon Connect admin website with an **Admin** account, or an account assigned to a security profile that has the following permission in it's security profile: **Cases** - **Case Templates** - **Create**.

1. On the left navigation menu, choose **Agent applications**, **Case field conditions**.

1. Choose **New Field Condition**.

1. On the **Create new field condition** page, select **Field Options** as the condition type.

1. Configure the relationship:
   + **Source field**: Choose the field that will control the options
   + **Target field**: Choose the field whose options will be controlled

1. Set up the option mappings by defining which source field values correspond to which target field options.

   For example, the following configuration shows when **Country** equals **United States**, the state field will show US states:
   + **Source field** = **Country**
   + **Target field** = **State/Province**
   + Mapping: "United States" → ["California", "New York", "Texas", "Florida"]

1. Add additional mappings for other source field values as needed.

1. Choose **Save**, and then proceed to the next step to add the condition to your template.

## Step 2: Add field options conditions to a template
<a name="step2-add-field-options-condition-template"></a>

In this step, you specify which target field the options condition will apply to.

1. Log in to the Amazon Connect admin website with an **Admin** account, or an account assigned to a security profile that has the following permission in it's security profile: **Cases** - **Case Templates** - **Create** or **Edit**.

1. On the left navigation menu, choose **Agent applications**, **Case templates**.

1. Choose the case template you want to apply the condition to.

1. In the **Fields** section, choose the settings icon next to the target field you want to apply the condition to.

1. In the **Modify field conditions for** [field] use the dropdown box to choose the field options condition you want to apply to the field.

1. Choose **Apply**, and then choose **Save** to save the change to the template.

## Example field options conditions
<a name="example-field-options-conditions"></a>

### Example 1: Show states/provinces based on country selection
<a name="example1-field-options-conditions"></a>

1. Create the following condition:
   + **Source field**: **Country**
   + **Target field**: **State/Province**
   + Mappings:
     + "United States" → ["California", "New York", "Texas", "Florida"]
     + "Canada" → ["Ontario", "Quebec", "British Columbia"]

1. Assign this condition to the **State/Province** field on the cases template.

1. Result: When agents select a **Country**, only the relevant states or provinces will be shown.

### Example 2: Show product subcategories based on main category
<a name="example2-field-options-conditions"></a>

1. Create the following condition:
   + **Source field**: **Product Category**
   + **Target field**: **Subcategory**
   + Mappings:
     + "Electronics" → ["Computers", "Phones", "Tablets", "Accessories"]
     + "Clothing" → ["Shirts", "Pants", "Shoes", "Accessories"]
     + "Books" → ["Fiction", "Non-Fiction", "Technical", "Children"]

1. Assign this condition to the **Subcategory** field on the cases template.

1. Result: When agents select a **Product Category**, only relevant subcategories will be shown.

### Example 3: Show department-specific issue types
<a name="example3-field-options-conditions"></a>

1. Create the following condition:
   + **Source field**: **Department**
   + **Target field**: **Issue Type**
   + Mappings:
     + "IT" → ["Hardware", "Software", "Network", "Security"]
     + "HR" → ["Benefits", "Payroll", "Policy", "Training"]
     + "Finance" → ["Invoicing", "Expenses", "Budget", "Reporting"]

1. Assign this condition to the **Issue Type** field on the cases template.

1. Result: When agents select a **Department**, only issue types relevant to that department will be available.

## APIs for field options conditions
<a name="field-options-conditions-apis"></a>

Use the following APIs to programmatically create field options conditions:
+ [CreateCaseRule](https://docs.aws.amazon.com/connect/latest/APIReference/API_connect-cases_CreateCaseRule.html): Creates the field options condition using the "fieldOptions" rule type.
+ [CreateTemplate](https://docs.aws.amazon.com/connect/latest/APIReference/API_connect-cases_UpdateTemplate.html) or [UpdateTemplate](https://docs.aws.amazon.com/connect/latest/APIReference/API_connect-cases_UpdateTemplate.html): Associate the field options condition with the case template.

# CSV upload for dependent field options
<a name="case-field-dependent-csv-upload"></a>

When you configure dependent field options for case templates, you can upload a CSV file. The file contains your field option mappings. This approach saves time compared to manually entering each relationship through the Amazon Connect admin website. This capability is useful when you have large datasets of hierarchical relationships. Examples include geographic hierarchies (Country → State → City) or product categorizations (Category → Subcategory).

## What is CSV upload for dependent field options?
<a name="case-field-dependent-csv-upload-definition"></a>

CSV upload is a bulk configuration method for dependent field options in Amazon Connect Cases. Dependent field options create cascading dropdown menus. The available choices in one field (the target field) depend on the value selected in another field (the source field).

You can prepare your mappings in a CSV file and upload it. This saves time compared to manually configuring each source-target value relationship through the Amazon Connect admin website. The system parses your CSV file and validates the field names and values against your case template. The system then pre-populates the rule creation form with your data. You create the rule using the standard workflow.

## How CSV upload works?
<a name="case-field-dependent-csv-upload-how-works"></a>

### CSV file structure
<a name="case-field-dependent-csv-file-structure"></a>

The CSV file uses a four-column format with the following headers:
+ **Parent Field Name** - The name of the source field that controls the relationship
+ **Child Field Name** - The name of the target field whose options depend on the source field
+ **Parent Value** - A specific value from the source field
+ **Child Value** - An option that appears in the target field when the parent value is selected

Each row in your CSV represents one source-target value relationship. You can include multiple field pairs in a single CSV file by using different parent-child field name combinations. For example, you can include both Country-State relationships and Product Category-Subcategory relationships in the same file. The number of entries you can save depends on your account's quota limits.

You can download a CSV template from the Amazon Connect admin website. The template provides the correct format with placeholder headers.

### Upload and validation process
<a name="case-field-dependent-csv-upload-validation-process"></a>

When you upload a CSV file, the system performs several validation checks:
+ **File format validation** - Verifies the CSV structure and required columns
+ **Field existence** - Confirms that the field names in your CSV match fields in your selected case template
+ **Field type validation** - Ensures both source and target fields are single-select type fields
+ **Value validation** - Checks that source field values exist in your template and identifies any child field values that don't exist

The system displays an error if source field values in your CSV do not exist in the template. If child field values do not exist, the system skips those values and shows an informational message.

After validation, the system groups your CSV rows by unique field pairs. The system displays each detected pair as a selectable option. If your CSV contains multiple field pairs, you select which pair to configure.

### Creating rules from CSV data
<a name="case-field-dependent-creating-rules-from-csv"></a>

After you select a field pair from your uploaded CSV, the rule creation form automatically populates with the field names and value mappings from your file.

You must explicitly create the rule after the form is populated. The upload process does not automatically create rules. If you upload a new CSV file before creating the rule, the new file's data overwrites the previously populated options.

Each CSV upload creates one rule at a time. If your CSV contains multiple field pairs, you create rules for each pair separately. Select different pairs and complete the rule creation workflow for each.

### Limits and requirements
<a name="case-field-dependent-limits-requirements"></a>

CSV upload has the following limits and requirements:
+ **Single-select fields only** - Both source and target fields must be single-select type fields
+ **Existing fields required** - All field names in your CSV must match fields that already exist

## Additional resources
<a name="case-field-dependent-csv-upload-apis"></a>

Use the following APIs to programmatically create field options conditions:
+ [CreateCaseRule](https://docs.aws.amazon.com/connect/latest/APIReference/API_connect-cases_CreateCaseRule.html): Creates the field options condition using the "fieldOptions" rule type.
+ [CreateTemplate](https://docs.aws.amazon.com/connect/latest/APIReference/API_connect-cases_UpdateTemplate.html) or [UpdateTemplate](https://docs.aws.amazon.com/connect/latest/APIReference/API_connect-cases_UpdateTemplate.html): Associate the field options condition with the case template.

# Create case templates to document customer issues in Amazon Connect Cases
<a name="case-templates"></a>

*Case templates* are forms that ensure agents collect and reference the right information for different types of customer issues. For example, you can create a case template for vehicle damage issues, and require agents complete certain fields when they talk to a customer filing an insurance claim. 

When you create a case template, you choose the name that appears to agents, the fields on the form, and the order of the fields.

**Important**  
Cases are always created based on a template.

## How case templates look in the agent application
<a name="agent-case-template"></a>

In the agent application, the agent sees the case fields in a Z-formation: case fields are displayed in two columns from left to right, top to bottom.

![\[A case in the agent workspace.\]](http://docs.aws.amazon.com/connect/latest/adminguide/images/cases-agent-side.png)


When you're building a case template, think of the information in the agent application as being is divided into two sections where case fields are displayed to the agent: 

![\[A cancellation request section in a case template.\]](http://docs.aws.amazon.com/connect/latest/adminguide/images/cases-templates-agent-application.png)

+ Top fields: This section is always visible on the case, even when agent is viewing sub-sections of the case (for example, **Activity Feed** or **Comments**).
+ More information: This is a tabbed subsection of the case. It is visible when agent is viewing another subsection, such as **Activity Feed** or **Comments**.

When you create and edit a template, you can do the following in each section:
+ Change the order of the fields.
+ Indicate if fields are required.

Some system fields, such as **Title** and **Status**, appear on all cases and are required. Other system fields, such as **Customer**, **Summary**, and **Reference number**, appear by default on the case details page. You can remove or rearrange these fields.

Each case that is created is connected to a customer profile from your Amazon Connect instance. On new case templates, the customer name appears by default on the case details page. You can remove or rearrange this field from your templates from the Amazon Connect admin website.

## How to create a template
<a name="how-to-create-template"></a>

1. Log in to the Amazon Connect admin website with an **Admin** account, or an account assigned to a security profile that has permissions to create templates. For a list of required permissions, see [Security profile permissions for Amazon Connect Cases](assign-security-profile-cases.md).

1. Verify the quota for case templates and request an increase if needed. For more information, see [Amazon Connect Cases service quotas](amazon-connect-service-limits.md#cases-quotas).

1. Verify the [case fields](case-fields.md) you want to add to your case template have already been created.

1. On the left navigation menu, choose **Agent applications**, **Case templates**.

1. Choose **\$1 New Template**.

1. Assign a name to the template. It will appear to agents in the agent application. The following image shows an example of how templates appear, by default in alphabetical order:  
![\[A case template showing how the template name appears to agents in the agent application.\]](http://docs.aws.amazon.com/connect/latest/adminguide/images/case-templates-in-agent-application.png)

1. In the **Top fields** section, you'll see some system fields already there. Choose **Add fields**, and use the dropdown to choose the field. Fields that are gray-out are already a part of the template. If you want agents to complete the field in order to save the form, choose **Required**.

1. In the **More information** section, choose the fields you want to appear.

1. Optionally, add **Case tags** to automatically propagate tags to cases created from this template. See [Tag-based access controls](cases-tag-based-access-control.md) for more information.

1. When you're done, choose **Save**. The template is immediately made available to agents in the agent application.

# Case layouts for developers using Amazon Connect Cases APIs
<a name="case-layouts"></a>

This topic is intended for developers who are using the Amazon Connect Cases APIs.

There is an underlying resource called a *case layout* that is linked to the case template. Technically, it is the case layout that holds the display elements for a case, such as: 
+ Which fields to display.
+ The section, either Top panel or More information.
+ The order within a section to display these fields

Whereas it's the case template that mandates a particular schema, such as required case fields. 

 The case layout is linked to a case template. 

**Note**  
You can create a case template and not link it to a case layout. Any case created with a case template that is not linked to a case layout will display system fields in a default order. 

# Set up a case assignment in Amazon Connect Cases
<a name="case-assignment"></a>

To help your organization clearly track ownership of cases and resolve them faster, you can ensure every case has an assigned owner who is responsible for case resolution. The owner can be a queue or an individual user.

**Note**  
Assigning a case owner does not route the case to the queue or the individual. 

The following image shows the **Case list** view in the agent workspace. You can filter by unassigned cases, for example, and assign ownership as needed. The default view is set to cases assigned to the agent who is viewing the list.

![\[The case list view in the agent workspace.\]](http://docs.aws.amazon.com/connect/latest/adminguide/images/cases-caselistview.png)


**Topics**
+ [Set up agents and flows](#setup-case-assignment)
+ [How agents assign case ownership](#agents-case-assignment)
+ [How to configure the Cases block to assign case ownership in a flow](#flows-case-assignment)

## Set up agents and flows case assignment
<a name="setup-case-assignment"></a>

To enable case assignment in your Amazon Connect instance, configure the following resources:

1. **Case template**. Add the following [system case fields](case-fields.md#system-case-fields) to a new or existing case template:
   + Assigned queue
   + Assigned user

1. To enable agents to assign case ownership in the agent workspace: 
   + **Security profile**. Grant agents permission to view the queues, users, and quick connects that are going to appear in the dropdown lists in the agent workspace. For more information, see [Required queue, quick connect, and user view permissions](assign-security-profile-cases.md#required-cases-queue-permissions).
   + **Quick connects**. Create user and queue quick connects for each user and queue that you want to appear in the dropdown lists. For instructions, see [Create quick connects in Amazon Connect](quick-connects.md).
   + **Queues**. Add the quick connects to the agent's queue. For instructions, see [Create a queue using the Amazon Connect admin website](create-queue.md).
   + **Routing profile**. Add the queue to the agent's routing profile. For instructions, see [Create a routing profile in Amazon Connect to link queues to agents](routing-profiles.md). 

     Agents see only those quick connects that are added to the queues assigned to their routing profile.

1. To configure the Cases block to assign case ownership automatically during a flow, set the **Request Fields** section to **Assigned Queue** or **Assigned User**. For an image and more instructions, see [How to configure the Cases block to assign case ownership in a flow](#flows-case-assignment). 

## How agents assign case ownership
<a name="agents-case-assignment"></a>

The following image shows the agent workspace. Agents choose the **Assign to** dropdown box to assign ownership of a case to themselves (the default option), a queue, or another user.

![\[The Assign to dropdown box in the agent workspace.\]](http://docs.aws.amazon.com/connect/latest/adminguide/images/case-assignment-example.png)


If agents assign ownership of a case to a queue or another user, they are presented with a prompt to choose from a filtered list of queues or users. The filtered list of available queues or users is based on the quick connects in the agent's routing profile.

### Assign to queue
<a name="queue-case"></a>

The following image shows an example dropdown list of queues in the agent workspace. For this list of queues to be displayed to an agent: create a quick connect for each queue, and then add the queue to the agent's routing profile.

![\[The Assign to queue box.\]](http://docs.aws.amazon.com/connect/latest/adminguide/images/cases-assignqueue-dropdown.png)


### Assign to user
<a name="queue-case"></a>

The following image shows an example dropdown list of users in the agent workspace. For this list of users to be displayed to an agent: create a quick connect for each user, assign the quick connects to the queue, add the queue to the agent's routing profile.

![\[The Assign to user box.\]](http://docs.aws.amazon.com/connect/latest/adminguide/images/case-assignment-userexample.png)


## How to configure the Cases block to assign case ownership in a flow
<a name="flows-case-assignment"></a>

You can configure the [Cases](cases-block.md) block to automatically populate the **Assigned queue** or **Assigned user** ownership fields. When agents view the case in the agent workspace, the case ownership is already set. Agents can override the assignment as needed, but are restricted to the queues and users that are available in their routing profile.

The following image shows an example of the Properties page for the **Cases** block. The **Request Fields** section is configured to **Set manually**, **Assigned queue**. You must enter the full ARN of the queue.

![\[The Cases block with request field set to Assigned queue.\]](http://docs.aws.amazon.com/connect/latest/adminguide/images/cases-block-assigned-queue.png)


There are situations where you may want to set the assigned queue or assigned user dynamically. For example, when the customer enters a DTMF number for a fraud issue, you can create cases where the Fraud department is automatically set as the case owner. 

# Access Amazon Connect Cases in the agent application
<a name="case-agent-experience"></a>

After you enable Amazon Connect Cases, you need to take steps to make the functionality available through the agent application. This topic explains your options.

**Tip**  
Make sure your agents have **Cases** permissions in their security profile so they can access Cases. For more information, see [Security profile permissions for Amazon Connect Cases](assign-security-profile-cases.md).

## Option 1: Use Cases with the CCP out-of-the-box
<a name="cases-access-out-of-the-box"></a>

Cases is already embedded alongside the Contact Control Panel (CCP). Your agents will access the CCP and Cases in the same browser window using a link that looks like this:
+ **https://*instance name*.my.connect.aws/agent-app-v2/** 

If you access your instance using the **awsapps.com** domain, use the following URL: 
+ **https://*instance name*.awsapps.com/connect/agent-app-v2/**

For help finding your instance name, see [Find your Amazon Connect instance name](find-instance-name.md).

## Option 2: Embed Cases into a custom agent application
<a name="cases-access-embed"></a>

When you embed your Contact Control Panel (CCP), you have the option of showing or hiding the pre-built CCP user interface. For example, you may want to develop a custom agent application that has a user interface you design, with customized buttons to accept and reject calls. Or, you may want to embed the pre-built CCP that's included with Amazon Connect into another custom app.

 You can display the pre-built CCP user interface, or hide it and build your own. In both scenarios, you can incorporate Cases into your agent application by using public APIs provided by Amazon Connect. These APIs are built to provide you the flexibility to create the functionality and user experience that you want. For more information, see the [Cases API documentation](https://docs.aws.amazon.com/cases/latest/APIReference/Welcome.html). 

**Tip**  
When you customize the agent's application, you determine what URL agents will use to access their agent application. This might be very different from the one provided by Amazon Connect. For example, your URL could be https://example-corp.com/agent-support-app. 

# How SLAs work in Amazon Connect Cases
<a name="cases-sla"></a>

 Service Level Agreements (SLAs) in Amazon Connect Cases are a type of related item that can be associated with a case. They allow you to track service goals for your contact center, specifying that particular types of cases should reach certain milestones within set timeframes. 

## Understanding SLAs in Cases
<a name="cases-sla-understand"></a>

 Case SLAs in Amazon Connect consist of the following components: 
+  **SLA name**: The identifier for the SLA in the UI and API responses. 
+  **Target date and time**: The deadline by which the case needs to progress to the target status. This can be configured up to 90 days. 
+  **Target value**: The field value that the case needs to be updated to for the SLA to be considered fulfilled. 
+  **SLA status**: The current fulfillment status of the SLA. Possible statuses include: 
  +  Active: SLA not yet fulfilled, but target time not reached 
  +  Met: SLA fulfilled before target time 
  +  Not met: SLA fulfilled after target time exceeded 
  +  Due soon: SLA not fulfilled, target time less than 24 hours away 
  +  Overdue: SLA not fulfilled, target time already exceeded 
+  **Time to breach**: For unfulfilled SLAs, the time remaining until the target date and time is exceeded. For overdue cases, this continues to run negative until the target value is achieved. 

## Adding SLAs to Cases
<a name="cases-sla-adding"></a>

 You can associate SLAs with cases in two ways: 
+  **Automatically**: Use Contact Lens Rules to add SLAs to cases that meet specified conditions (case template and field values) for Case Creation and Update rules. For more information, see [Automatically monitor and update cases in Amazon Connect Cases](create-alerts-on-cases.md).
+  **Manually**: Use the CreateRelatedItem API to add an SLA related item to a case. 

## Viewing SLAs on Cases
<a name="cases-sla-viewing"></a>

 Managers and agents can view case SLAs in the agent application to prioritize cases and identify those at risk of missing service goals. 

**Case summary page**

**To add SLA information to the case list view:**

1. Log in to the Amazon Connect admin website at https://*instance name*.my.connect.aws/.

1. Open the **Agent Workspace**.  
![\[Open the Agent Workspace.\]](http://docs.aws.amazon.com/connect/latest/adminguide/images/cases-sla-viewing-1.png)

1.  Choose the gear icon in the top right of the table.   
![\[Choose the gear icon in the top right of the table.\]](http://docs.aws.amazon.com/connect/latest/adminguide/images/cases-sla-viewing-2.png)

1.  Add the **Next SLA Breach** field to the active list.   
![\[Add the "Next SLA Breach" field to the active list.\]](http://docs.aws.amazon.com/connect/latest/adminguide/images/cases-sla-viewing-3.png)

1.  Toggle the field from inactive to active.   
![\[You then toggle this new field to make it appear in the SLA dashboard.\]](http://docs.aws.amazon.com/connect/latest/adminguide/images/cases-sla-viewing-4.png)

**Note**  
 These settings persist unless you clear your cookies. 

**Case detail page**

**For cases with active SLAs:**
+  A badge notification appears next to the case title, showing the time until the next active SLA will breach. 
+  An SLAs section below the case details lists all active and completed SLAs associated with the case, including: 
  +  SLA name 
  +  Status 
  +  Target date and time 
  +  Completion date and time (if applicable) 
  +  Time to breach (if applicable) 

## Automating Actions for Breached SLAs
<a name="cases-sla-automating-breached"></a>

 You can use Contact Lens Rules to trigger automated actions when SLAs reach their target completion time without being met: 

1.  In the Contact Lens Rules interface, add a new rule with the trigger based on **Case SLA Breach**. 

1.  Specify which SLA names the **Breach rule** should apply to. 

 For more information, see [Automatically monitor and update cases in Amazon Connect Cases](create-alerts-on-cases.md) in the Amazon Connect documentation. 

# Automatically monitor and update cases in Amazon Connect Cases
<a name="create-alerts-on-cases"></a>

You can easily set up case notifications and automation. You can create rules that automatically run whenever a case is created or updated. You can create rules that: 
+ Assign service level agreements to cases
+ Create tasks
+ End associated tasks
+ Update cases
+ Send email alerts to Amazon Connect users

For example, you can set up an alert that automatically sends an email to a manager when a high-priority case is created or updated.

**Tip**  
A developer needs to enable this feature. For instructions, see [Allow Amazon Connect Cases to send updates to Contact Lens rules](cases-rules-integration-onboarding.md). 

**Topics**
+ [Step 1: Define rule conditions](#conditions-alerts-on-cases)
+ [Step 2: Define rule actions](#rule-actions-alerts-on-cases)

## Step 1: Define rule conditions
<a name="conditions-alerts-on-cases"></a>

1. On the navigation menu, choose **Analytics and optimization**, **Rules**.

1. Select **Create a rule**, **Cases**.  
![\[The Create a rule dropdown menu on the Rules page, the Cases option.\]](http://docs.aws.amazon.com/connect/latest/adminguide/images/conditions-alerts-on-cases-1.png)

1. Under **When**, use the dropdown list to choose from two event sources: **A new case is created**, **A case is updated**, or **A case service level agreement is breached**. These options are shown in the following image.  
![\[The option When a case rule is available.\]](http://docs.aws.amazon.com/connect/latest/adminguide/images/conditions-alerts-on-cases-2.png)

1. Choose **Add condition**. You can define conditions based on the case template value, such as when the case template equals **Billing**, or based on case field values, such as when Priority equals **high**.  
![\[The condition for when a real-time metric is updated.\]](http://docs.aws.amazon.com/connect/latest/adminguide/images/conditions-alerts-on-cases-3.png)

   You can combine multiple conditions to build very specific rules.

   The following image shows a sample rule with multiple conditions:  
![\[The condition for when a real-time metric is updated.\]](http://docs.aws.amazon.com/connect/latest/adminguide/images/conditions-alerts-on-cases-4.png)

1. Choose **Next**.

## Step 2: Define rule actions
<a name="rule-actions-alerts-on-cases"></a>

1. Choose **Add action**. You can choose the following actions:
   + [Assign service level agreement to case](cases-sla.md#cases-sla-adding)
   + [Create task](contact-lens-rules-create-task.md)
   + [End tasks](contact-lens-rules-ends-tasks.md)
   + [Update case](contact-lens-rules-update-case.md)
   + [Send email notification](contact-lens-rules-email.md)  
![\[The add action dropdown menu, a list of actions.\]](http://docs.aws.amazon.com/connect/latest/adminguide/images/rule-actions-alerts-on-cases.png)

1. Choose **Next**.

1. Review and make any edits, then choose **Save**. 

# Amazon Connect Cases metrics
<a name="case-management-metrics"></a>

The following case driven metrics are available on the Historical metrics reports. To access these metrics on a report, Cases needs to be [enabled](enable-cases.md) for your instance, and at least one [case template](case-templates.md) is created.

## Average case resolution time
<a name="average-case-resolution-time-metric"></a>

This metric measures the average amount of time spent to resolve a case during the provided time interval. 

**Metric type**: String (*hh:mm:ss*)

**Metric category**: Case driven metric

**How to access using the Amazon Connect API**: 
+ [GetMetricDataV2](https://docs.aws.amazon.com/connect/latest/APIReference/API_GetMetricDataV2.html) API metric identifier: `AVG_CASE_RESOLUTION_TIME`

**How to access using the Amazon Connect admin website**: 
+ Historical metrics reports: Average Case Resolution Time

## Average contacts per case
<a name="average-contacts-case-metric"></a>

This metric measures the average number of contacts (calls, chat, tasks, and email) for cases created during the provided time interval.

**Metric type**: String

**Metric category**: Case driven metric

**How to access using the Amazon Connect API**: 
+ [GetMetricDataV2](https://docs.aws.amazon.com/connect/latest/APIReference/API_GetMetricDataV2.html) API metric identifier: `AVG_CASE_RELATED_CONTACTS`

**How to access using the Amazon Connect admin website**: 
+ Historical metrics reports: Average Case Related Contacts

## Cases created
<a name="cases-created-metric"></a>

This metric counts all the cases created.

**Metric type**: Integer

**Metric category**: Case driven metric

**How to access using the Amazon Connect API**: 
+ [GetMetricDataV2](https://docs.aws.amazon.com/connect/latest/APIReference/API_GetMetricDataV2.html) API metric identifier: `CASES_CREATED`

**How to access using the Amazon Connect admin website**: 
+ Historical metrics reports: Cases Created

**Calculation logic**:
+ Check case\$1create\$1time createdDataTime present?
+ Return count = 1 for each case, or null if not present.

**Notes**:
+ Uses SUM statistic for aggregation.
+ Counts each case creation event.
+ Returns null if creation timestamp is not present.
+ Can be filtered by case template and status.
+ Data for this metric is available starting from January 26, 2024 0:00:00 GMT.

## Cases reopened
<a name="cases-reopened-metric"></a>

This metric measures the number of times cases have been reopened.

**Metric type**: Integer

**Metric category**: Case driven metric

**How to access using the Amazon Connect API**: 
+ [GetMetricDataV2](https://docs.aws.amazon.com/connect/latest/APIReference/API_GetMetricDataV2.html) API metric identifier: `REOPENED_CASE_ACTIONS`

**How to access using the Amazon Connect admin website**: 
+ Historical metrics reports: Reopen Case Actions Performed

**Calculation logic**:
+ Check case\$1reopened\$1time lastReopenedDateTime present?
+ Return count = 1 for each reopened case.

**Notes**:
+ Uses SUM statistic for aggregation.
+ Counts each reopen action.
+ Returns null if reopen timestamp is not present.
+ Can be filtered by case template and status.
+ Data for this metric is available starting from January 26, 2024 0:00:00 GMT.

## Cases resolved
<a name="cases-resolved-metric"></a>

This metric measures the number of times cases have been resolved.

**Metric type**: Integer

**Metric category**: Case driven metric

**How to access using the Amazon Connect API**: 
+ [GetMetricDataV2](https://docs.aws.amazon.com/connect/latest/APIReference/API_GetMetricDataV2.html) API metric identifier: `RESOLVED_CASE_ACTIONS`

**How to access using the Amazon Connect admin website**: 
+ Historical metrics reports: Resolve Case Actions Performed

**Calculation logic**:
+ Check case\$1resolved\$1time lastCloseDateTime present?
+ Return count = 1 for each resolved case.

**Notes**:
+ Uses SUM statistic for aggregation.
+ Counts each resolution action.
+ Returns null if resolution timestamp is not present.
+ Can be filtered by case template and status.
+ Data for this metric is available starting from January 26, 2024 0:00:00 GMT.

## Cases resolved on first contact
<a name="cases-resolved-first-contact-metric"></a>

This metric measures the percent of cases that were resolved on the first contact (only including calls, chats, or email). Cases that have been reopened and subsequently closed in the specified interval will contribute to this metric. If cases are reopened but not closed in the specified interval it will not contribute to this metric.

**Metric type**: String
+ Min value: 0.00%
+ Max value: 100.00%

**Metric category**: Case driven metric

**How to access using the Amazon Connect API**: 
+ [GetMetricDataV2](https://docs.aws.amazon.com/connect/latest/APIReference/API_GetMetricDataV2.html) API metric identifier: `PERCENT_CASES_FIRST_CONTACT_RESOLVED`

**How to access using the Amazon Connect admin website**: 
+ Historical metrics reports: Case First Contact Resolution Rate

**Calculation logic**:
+ Check if Case Status is closed?
+ Count contacts (CHAT/VOICE/EMAIL) for the case.
+ Calculate first contact resolution: Return true (1.0) if exactly one contact. Else false (0.0).

**Notes**:
+ Uses AVG statistic for final percentage.
+ Only considers closed cases.
+ Counts only CHAT, VOICE, and EMAIL contacts.
+ Returns null if case is not closed or has no contacts.
+ True (1.0) if resolved in single contact.
+ Data for this metric is available starting from December 4, 2023 0:00:00 GMT.

## Current cases
<a name="current-cases-metric"></a>

This metric counts the total cases existing in a given domain for a specific point in time.

**Metric type**: Integer

**Metric category**: Case driven metric

**How to access using the Amazon Connect API**: 
+ [GetMetricDataV2](https://docs.aws.amazon.com/connect/latest/APIReference/API_GetMetricDataV2.html) API metric identifier: `CURRENT_CASES`

**How to access using the Amazon Connect admin website**: 
+ Historical metrics reports: Current cases

**Calculation logic**:
+ Get statusesNested.count for current time period.
+ Sum counts across all matching status records.

**Notes**:
+ We recommend limiting the queried time window to 5 minutes. Otherwise the returned data may be inaccurate.
+ Uses SUM statistic for aggregation.
+ Provides point-in-time case count.
+ Can be filtered by status and template.
+ Based on case snapshot timestamp.
+ Data for this metric is available starting from January 26, 2024 0:00:00 GMT.

# Set up tag-based access controls on cases
<a name="cases-tag-based-access-control"></a>

You can use resource tags and access control tags to apply granular access to cases in Amazon Connect Cases. For example, you can control who has access to view, create, or edit cases containing sensitive customer information based on department, case type, or security classification.

Tag-based access controls enable you to configure granular access to specific cases based on assigned resource tags. Cases inherit tags from their associated case templates, ensuring consistent access control without requiring agents to manually tag individual cases. You can configure tag-based access controls by using the API or the Amazon Connect admin website. For more information, see [Add tags to resources in Amazon Connect](tagging.md) and [Apply tag-based access control in Amazon Connect](tag-based-access-control.md).

## How tag propagation works for cases
<a name="cases-tag-propagation"></a>

When you create a case using a case template, the case automatically inherits the tags configured on that template. This ensures consistent access control and reduces the risk of human error in tagging individual cases. It is important to note that tags specified during case creation will override any conflicting tags from the template.

For example, if you tag a "Fraud Investigation" template with `Department:Fraud`, all cases created using that template will automatically receive the `Department:Fraud` tag, restricting access to users with appropriate permissions. However, if a CreateCase public API request is made with the same "Fraud Investigation" template with `Department:Finance` in the request, the case will instead have the `Department:Finance` tag.

## How to enable tag-based access control for cases
<a name="cases-enable-tag-based-access-control"></a>

To apply tags to control access to cases:
+ **Tag your case templates**: Apply tags to case templates that will be inherited by all cases created from those templates. You can add tags when creating or editing templates in the Amazon Connect admin website or by using the Amazon Connect Cases CreateTemplate or UpdateTemplates APIs.
+ **Configure security profiles**: Assign users to security profiles that grant access to specific case tags. On the Security profiles page, choose **Show advanced options** to configure tag-based permissions for the Cases resource. For more information about configuring access control tags, see [Apply tag-based access control in Amazon Connect](tag-based-access-control.md).
+ **Set appropriate permissions**: Users need one of the following permissions to work with cases:
  + **Cases - Create**: Allows creating new cases (requires permission for tags that will be applied)
  + **Cases - View**: Allows viewing existing cases with matching tags
  + **Cases - Edit**: Allows modifying existing cases with matching tags

# Amazon Connect Cases event streams
<a name="case-event-streams"></a>

Amazon Connect Cases event streams provide you with near real-time updates when cases are created or modified within your Amazon Connect Cases domain. The events published to the stream include these resource events:
+ Case created
+ Cases modified
+ Related items (Comments, Calls, Chats, Tasks) are added to a case

You can use the case event streams to integrate streams into your data lake solutions, create dashboards that display case performance metrics, implement business rules or automated actions based on case events, and configure alerting tools to trigger custom notifications of specific case activity.

**Topics**
+ [Set up case event streams](case-event-streams-enable.md)
+ [Allow Cases to send updates to Contact Lens rules](cases-rules-integration-onboarding.md)
+ [Case event payload and schema](case-event-streams-sample.md)

# Set up Amazon Connect Cases event streams
<a name="case-event-streams-enable"></a>

This topic explains how to set up and use case event streams. Some of the onboarding steps require you to call [Amazon Connect Cases APIs](https://docs.aws.amazon.com/cases/latest/APIReference/Welcome.html).

## Step 1: Create an Amazon Connect instance and enable Customer Profiles
<a name="step1-case-event-streams-enable"></a>

1. Ensure you have an working Amazon Connect instance in one of the AWS Regions where Cases is available. See [Cases availability by Region](regions.md#cases_region).

1. Enable Amazon Connect Customer Profiles. For instructions, see [Enable Customer Profiles for your Amazon Connect instance](enable-customer-profiles.md).

   Amazon Connect Cases requires Customer Profiles because each case must be associated with a customer profile from the Customer Profiles service.

## Step 2: Add a Cases domain to your Amazon Connect instance
<a name="step2-case-event-streams-enable"></a>

For instructions, see [Enable Cases using the Amazon Connect console](enable-cases.md).

If you want to add a case domain using the API, see the [CreateDomain](https://docs.aws.amazon.com/cases/latest/APIReference/API_CreateDomain.html) API in the *Amazon Connect Cases API Reference*. 

## Step 3: Create a case template
<a name="step3-case-event-streams-enable"></a>

[Create a case template](case-templates.md). In *Step 6: Test case event streams*, you'll use the template. 

If you want to create a case template using the API, see the [CreateTemplate](https://docs.aws.amazon.com/cases/latest/APIReference/API_CreateTemplate.html) API in the *Amazon Connect Cases API Reference*. 

## Step 4: Enable case event streams and setup to receive events into an SQS queue
<a name="step4-case-event-streams-enable"></a>

Run the following command to enable case event streams for your Cases domain. After this command runs, when cases are created or updated, an event is published to the default-bus of the EventBridge service in your account (it must be in the same AWS Region as your Cases domain).

```
aws connectcases put-case-event-configuration --domain-id dad5efb6-8485-4a55-8241-98a88EXAMPLE --event-bridge enabled=true
```

By default, the events published by Amazon Connect Cases only contain metadata about the case, such as `templateId`, `caseId`, `caseArn`, `approximateChangeTime`, and more. You can run the following command to get more information about the case (at the time the event was generated) to be included in the event.

**Note**  
If you want to include a custom field in the event, use the custom field ID. For instructions about how to locate the custom field ID, see [Find the custom field ID](cases-block.md#get-case-properties-find-uuid). 

```
# You can include any other field defined in your cases domain in the fields section.
# To list the fields that are defined in your cases domain, call the Cases ListFields API.
# To include case fields that you create (custom fields) in the event, enter the custom field ID.
aws connectcases put-case-event-configuration --domain-id YOUR_CASES_DOMAIN_ID --event-bridge "{
    \"enabled\": true, 
    \"includedData\": {
       \"caseData\": {
          \"fields\": [
          {
          \"id\": \"status\"
          },
          {
          \"id\": \"title\"
          },
          {
          \"id\": \"customer_id\"
          },
         {
          \"id\": \"your custom field ID\"
          }
        ]
      },
      \"relatedItemData\": {
      \"includeContent\": true
      }
    }
  }"
```

Next, create an Amazon SQS queue and set that as a target for the Amazon Connect Cases events on your EventBridge bus so that all the case events are delivered to the SQS queue for later processing.

```
# Create an SQS queue
aws sqs create-queue --queue-name case-events-queue --attributes "{\"Policy\": \"{ \\\"Version\\\": \\\"2012-10-17\\\", \\\"Statement\\\": [{ \\\"Sid\\\": \\\"case-event-subscription\\\", \\\"Effect\\\": \\\"Allow\\\", \\\"Principal\\\": { \\\"Service\\\": \\\"events.amazonaws.com\\\"}, \\\"Action\\\": \\\"SQS:SendMessage\\\", \\\"Resource\\\": \\\"*\\\"}]}\"}"

# Create an rule on the EventBridge default bus that represents the case events
aws events put-rule --name case-events-to-sqs-queue --event-pattern "{\"source\": [\"aws.cases\"]}" --state ENABLED

# Ask event bridge to publish case events to the SQS queue.
aws events put-targets --rule case-events-to-sqs-queue --target "[{
\"Id\": \"target-1\",
\"Arn\": \"arn:aws:sqs:The AWS Region of your Amazon Connect instance:your AWS account ID:case-events-queue\"
}]"
```

## Step 5: Test case event streams
<a name="step5-case-event-streams-enable"></a>

Use the Amazon Connect agent application to: 

1. Accept a chat contact.

1. Create a customer profile and associate that to the chat contact.

1. Create a case. 
**Note**  
The **Create case** button on the **Cases** tab is inactive until you accept a contact and associate that contact with a customer profile.

Navigate to the Amazon SQS console and check that a case event (type: `CASE.CREATED`) for the newly created case is available in your SQS Queue. Similarly, you can modify the case created above and get a corresponding case event (type: `CASE.UPDATED`) in your SQS queue. You can associate the contact to the case, and leave a comment on the case to get case events for those actions, too.

## Step 6: Use cases for the case event streams
<a name="step6-case-event-streams-enable"></a>

Case event streams publish events every time a case is created, case is updated, contact is associated to the case, and comment is added on a case. You can use these events for:
+ Metrics, analytics and dashboards
+ Build Apps that notify users (for example, send emails)
+ Automated actions that are triggered based on certain type of case updates

For example, you can use the SQS target on EventBridge (as shown on step 4) to temporarily store the case events in the SQS queue, and use Lambda functions to process events in the SQS to build custom applications such as sending emails to the customer when their case is updated, automatically resolving any tasks linked to the case, and more. Similarly, you can use the Firehose target on the EventBridge to store the case events into an S3 bucket and then use the AWS Glue for ETL, Athena for ad-hoc analytics, and Quick for dashboards.

# Allow Amazon Connect Cases to send updates to Contact Lens rules
<a name="cases-rules-integration-onboarding"></a>

**Note**  
To perform the instructions in this procedure, you need to have developer skills, or be experienced with Amazon Connect CLI.

Complete this one-time procedure so your users can set up rules that run when a case is created or updated. 

1. Verify Amazon Connect Cases is [enabled](enable-cases.md) for your Amazon Connect instance. 

1. Complete the steps to enable Amazon Connect Cases event streams. For more information see [Set up Amazon Connect Cases event streams](case-event-streams-enable.md). Note the following changes to the procedure:

   1. You can skip the part that asks you to create a SQS queue, as it is not required.

   1. Run the `put-case-event-configuration` CLI command to include all case fields information in the event. Make sure to include all of the fields that you need for the Rules engine to work.
**Note**  
To ensure that Cases SLA Breach rules work properly, you must set `relatedItemData.includeContent` to `true`, as shown in the following example.

      ```
      aws connectcases put-case-event-configuration --domain-id 01310a0e-24ba-4a3c-89e9-9e1daeaxxxx --event-bridge "{
          \"enabled\": true, 
          \"includedData\": {
             \"caseData\": {
                 \"fields\": [
                   {
                     \"id\": \"status\"
                   },
                   {
                     \"id\": \"title\"
                   },
                   {
                     \"id\": \"assigned_queue\"
                   },
                   {
                     \"id\": \"assigned_user\"
                   },
                   {
                     \"id\": \"case_reason\"
                   },
                   {
                     \"id\": \"last_closed_datetime\"
                   },
                   {
                     \"id\": \"created_datetime\"
                   },
                   {
                     \"id\": \"last_updated_datetime\"
                   },
                   {
                     \"id\": \"reference_number\"
                   },
                   {
                     \"id\": \"summary\"
                   }
                 ]
            },
            \"relatedItemData\": {
            \"includeContent\": true
            }
          }
        }"
      ```

   1. If there are custom case fields, make sure to include a custom field ID the fields array in the previous payload as well. You can find field IDs by running the following `list-fields` CLI command:

      ```
      aws connectcases list-fields --domain-id 01310a0e-24ba-4a3c-89e9-9e1daeaxxxx
      ```

   1. Repeat step 2 if you need to add new custom fields. 

1. Make a [CreateEventIntegration](https://docs.aws.amazon.com/appintegrations/latest/APIReference/API_CreateEventIntegration.html) API call, or run the `create-event-integration` CLI command, as shown in the following example command.
   + Payload:

     ```
     aws appintegrations create-event-integration --name amazon-connect-cases --description amazon-connect-cases --event-filter '{"Source":"aws.cases"}' --event-bridge-bus default
     ```
   + The output will look similar to the following sample:

     ```
     {
         "EventIntegrationArn": "arn:aws:app-integrations:us-west-2:111222333444:event-integration/amazon-connect-cases"
     }
     ```

1. Make a [CreateIntegrationAssociation](https://docs.aws.amazon.com/connect/latest/APIReference/API_CreateIntegrationAssociation.html) API call, or run the `create-integration-association` CLI command, as shown in the following example command.
   + Payload:

     The `IntegrationArn` is the response you get from step 3.

     ```
     aws connect create-integration-association --instance-id bba5df5c-6a5f-421f-a81d-9c16402xxxx --integration-type EVENT --integration-arn arn:aws:app-integrations:us-west-2:111222333444:event-integration/amazon-connect-cases --source-type CASES
     ```
   + The output will be similar to the following sample:

     ```
     {
         "IntegrationAssociationId": "d49048cd-497d-4257-ab5c-8de797a123445",
         "IntegrationAssociationArn": "arn:aws:connect:us-west-2:111222333444:instance/bba5df5c-6a5f-421f-a81d-9c16402bxxxx/integration-association/d49048cd-497d-4257-ab5c-8de797a123445"
     }
     ```

Your users should now be able to create rules that run when a case is created or updated.

# Case event payload and schema in Amazon Connect Cases
<a name="case-event-streams-sample"></a>

When you request to include case data in the event payload, the data reflects the version of the case after that particular edit. 

Amazon Connect Cases default limits guarantee that the payload will be less than 256KB (the maximum size of an EventBus event). Since you can customize the case object model (for example, you can define custom fields on case objects to capture business specific information), case event schema reflect the customizations made to the case object as shown in the following examples (for example, see how customer-specific UUIDs are being use as JSON properties). 

## Example case event payload for the case resource
<a name="example-case-event-payload"></a>

```
// Given the limits on the "includedData" configuration
// this payload is guaranteed to less than 256KB at launch.
{
    "version": "0",
    "id": "event ID",
    "detail-type": "Amazon Connect Cases Change",
    "source": "aws.cases",
    "account": "your AWS account ID",
    "time": "2022-03-16T23:43:26Z",
    "region": "The AWS Region of your Amazon Connect instance",
    "resources": [
        "arn:aws:cases:your Amazon Connect AWS Region:your AWS account ID:domain/case domain ID",
        "arn:aws:cases:your Amazon Connect AWS Region:your AWS account ID:domain/case domain ID/case/case ID"
    ],
    "detail": {
        "version": "0",
        "eventType": "CASE.UPDATED",
        "approximateChangeTime": "2022-03-16T23:16:57.893Z",  // Can be used for ordering
        "changedFieldIds": ["status", "last_updated_datetime"],
        "performedBy": {
            "user": {
                "userArn": "arn:aws:connect:your Amazon Connect AWS Region:your AWS account ID:instance/connect instance ID/user/connect user ID"        
            },
            "iamPrincipalArn": "arn:aws:iam::your Amazon Connect AWS Region:role/role name"
        },       
        "case": {
            "caseId": "case ID",
            "templateId": "template ID",
            "createdDateTime": "2022-03-16T23:16:57.893Z",
            
            // This section contains only non-null field values for the 
            // fields that customers have configured in the "includedData".
           
            // Field values included in this section reflects the case
            // after this particular change is applied.
            "fields": {
                "status": {
                    "value": {
                        "stringValue": "open"
                   }
                },
                "case_reason": {
                    "value": {
                        "stringValue": "Shipment lost"
                    }
                },
                "custom-field-uuid-1": {
                    "value": {
                        "stringValue": "Customer didn't receive the product"
                    }
                }
            }
        }
    }
}
```

## Example case event payload for the related-item resource
<a name="example-case-event-payload"></a>

```
// Given the limits on the "includedData" configuration
// this payload is guaranteed to less than 256KB
{
    "version": "0",
    "id": "event ID",
    "detail-type": "Amazon Connect Cases Change",
    "source": "aws.cases",
    "account": "your AWS account ID",
    "time": "2022-03-16T23:43:26Z",
    "region": "The AWS Region of your Amazon Connect instance",
    "resources": [
        "arn:aws:cases:your Amazon Connect AWS Region:your AWS account ID:domain/case domain ID",
        "arn:aws:cases:your Amazon Connect AWS Region:your AWS account ID:domain/case domain ID/case/case ID/related-item/related-item ID"
    ],
    
    "detail": {   
        "version": "0",
        "eventType": "RELATED_ITEM.CREATED",
        "approximateChangeTime": "2022-03-16T23:16:57.893Z", // Can be used for ordering
        "changedAttributes": ["comment.commentText"],
        "performedBy": {
            "user": {
                "userArn": "arn:aws:connect:your Amazon Connect AWS Region:your AWS account ID:instance/connect instance ID/user/connect user ID"        
            },
            "iamPrincipalArn": "arn:aws:iam::your Amazon Connect AWS Region:role/role name"
        },        
        "relatedItem": {
            "relatedItemType": "Comment",
            "relatedItemId": "related-item ID",
            "caseId": "case id that this related item is a sub-resource of",
            "createdDateTime": "2022-03-16T23:16:57.893Z",
            
            // This section includes any attributes that customers have configured
            // in the "includedData" configuration.
            "comment": {               
                "body": "Gave a $5 refund to customer to make them happy",
            },
            
            // if the related item was of type contact.
            // "contact": {
            //      "contactArn": ".......",
            // }
        }
    }
}
```

## Example case event payload for the case resource performed by custom entity
<a name="example-case-event-payload-case-resource-custom-entity"></a>

```
// Given the limits on the "includedData" configuration
// this payload is guaranteed to less than 256KB at launch.
{
    "version": "0",
    "id": "event ID",
    "detail-type": "Amazon Connect Cases Change",
    "source": "aws.cases",
    "account": "your AWS account ID",
    "time": "2022-03-16T23:43:26Z",
    "region": "The AWS Region of your Amazon Connect instance",
    "resources": [
        "arn:aws:cases:your Amazon Connect AWS Region:your AWS account ID:domain/case domain ID",
        "arn:aws:cases:your Amazon Connect AWS Region:your AWS account ID:domain/case domain ID/case/case ID"
    ],
    "detail": {
        "version": "0",
        "eventType": "CASE.UPDATED",
        "approximateChangeTime": "2022-03-16T23:16:57.893Z",  // Can be used for ordering
        "changedFieldIds": ["status", "last_updated_datetime"],
        "performedBy": {
            "user": {
                "customEntity": "your custom entity"        
            },
            "iamPrincipalArn": "arn:aws:iam::your Amazon Connect AWS Region:role/role name"
        },       
        "case": {
            "caseId": "case ID",
            "templateId": "template ID",
            "createdDateTime": "2022-03-16T23:16:57.893Z",
            
            // This section contains only non-null field values for the 
            // fields that customers have configured in the "includedData".
           
            // Field values included in this section reflects the case
            // after this particular change is applied.
            "fields": {
                "status": {
                    "value": {
                        "stringValue": "open"
                   }
                },
                "case_reason": {
                    "value": {
                        "stringValue": "Shipment lost"
                    }
                },
                "custom-field-uuid-1": {
                    "value": {
                        "stringValue": "Customer didn't receive the product"
                    }
                }
            }
        }
    }
}
```