> ## Documentation Index
> Fetch the complete documentation index at: https://docs.cognigy.com/llms.txt
> Use this file to discover all available pages before exploring further.

# File Storage

<a href="/release-notes/2025.14"><Badge className="version-badge" color="blue">Updated in 2025.14</Badge></a>

By default, users can't attach files to chat messages. However, you can configure a *File Storage* in the Endpoint settings that allows users to upload files in the chat interface. To configure the file storage, you need to create a connection to a third-party storage provider.

After uploading a file to the chat interface, the file is saved in the third-party storage and can be viewed by both the sender and the recipient.

## Key Features

* **Improved Conversational Experience**. Users can upload screenshots to illustrate technical issues and share various documents, such as contracts, invoices, order confirmations, and photos of purchased goods. File uploads allow for richer interactions and more capabilities for your Flow.
* **File Manipulation**. You can retrieve file data, resize images, and validate files.
* **Security Measures**. Cognigy.AI performs a virus scan on the file before uploading it to the cloud storage provider, checking for potential malware or viruses, and preventing harmful content from being stored or shared through the cloud.

## Prerequisites

* You have access to one of the following third-party storage providers:
  * [Azure Blob Storage](https://learn.microsoft.com/en-us/azure/storage/blobs/storage-blobs-introduction)
  * [Amazon S3](https://docs.aws.amazon.com/AmazonS3/latest/userguide/Welcome.html)
  * [Google Cloud Storage](https://cloud.google.com/storage/docs/)
* Files in the third-party storage are publicly accessible.

## Restrictions

* Only the following Endpoints support file uploads:
  * [8x8](/ai/agents/deploy/endpoint-reference/8x8)
  * [Webchat v2](/webchat/v2/overview)
  * [Webchat v3](/webchat/v3/overview)
  * [WhatsApp](/ai/agents/deploy/endpoint-reference/whatsapp)

## How to Use the File Storage

### Create Connections to File Storage Providers

To enable file uploads, connect to one of the following file storage providers:

<Tabs>
  <Tab title="Azure Blob Storage Container">
    <AccordionGroup>
      <Accordion title="1. On the Azure Side">
        1. Go to the [Azure portal](https://portal.azure.com/#home) and select **Storage Accounts** in the **Azure services** section.
        2. On the **Storage accounts** page, select the account from the **Name** column.
        3. In the left-side menu, navigate to **Data storage > Containers**. Copy the name of the target container from the **Name** column. This container will store user-uploaded files. Save the container name for later use.
        4. In the left-side menu, go to **Security + networking** and select **Access Keys**.
        5. On the **Access Keys** page, copy the name from the **Storage account name** field and the key from the **Key** field for later use.
      </Accordion>

      <Accordion title="2. On the Cognigy.AI Side">
        1. Open the Project that contains the Endpoint for which you want to configure a file storage. Go to **Deploy > Endpoints** and select an Endpoint or create one.
        2. Depending on the Endpoint you select, proceed as follows:
           * **Webchat v3** — activate the **Allow Attachment Upload** setting in **Webchat Behavior** in the **Attachment Upload** section and select **Azure** from the **File Storage Provider** list.
           * **Other Endpoints** — go to the **File Storage** section and select **Azure** from the **File Storage Provider** list.
        3. Next to the **Azure Connection**, click **+** and fill in the following fields:
           * **Container Name** — enter the name of the container that you copied and saved previously.
           * **Account Name** — enter the storage account name that you copied and saved previously.
           * **Account Key** — enter the key that you copied and saved previously.
        4. Click **Create**, then **Save**.
      </Accordion>
    </AccordionGroup>
  </Tab>

  <Tab title="Amazon S3 Bucket or S3-compatible Storage">
    <AccordionGroup>
      <Accordion title="1. On the AWS or S3-Compatible Storage Side">
        1. Make sure the bucket has the required upload access. AWS uses [IAM policies](https://docs.aws.amazon.com/IAM/latest/UserGuide/reference_policies_elements_statement.html) for the access control. For Amazon S3-compatible cloud storages, use an equivalent access control mechanism. Configure the following AWS IAM policy for AWS buckets:

        ```json theme={null}
        {
          "Version": "2012-10-17",
          "Statement": [
            {
              "Effect": "Allow",
              "Action": "s3:ListBucket",
              "Resource": "arn:aws:s3:::BUCKET-NAME"
            },
            {
              "Effect": "Allow",
              "Action": [
                "s3:PutObject",
                "s3:PutObjectAcl",
                "s3:GetObject"
              ],
              "Resource": "arn:aws:s3:::BUCKET-NAME/*"
            }
          ]
        }
        ```

        2. Make sure that you have access to an [Amazon S3 bucket](https://docs.aws.amazon.com/AmazonS3/latest/userguide/Welcome.html) or to an Amazon S3-compatible cloud, for example, [Open Telekom Cloud](https://docs.otc.t-systems.com/), [DigitalOcean Spaces](https://docs.digitalocean.com/products/spaces/), [Backblaze B2](https://www.backblaze.com/docs). You need at least one bucket, or [create a new one](https://docs.aws.amazon.com/AmazonS3/latest/userguide/create-bucket-overview.html). The bucket must be publicly accessible; otherwise, users can't upload files via the chat interface. For a cloud storage provider compatible with Amazon S3, you need similar information to what is described in the following steps.
        3. In the [Amazon S3 console](https://console.aws.amazon.com/s3/), go to the **General purpose buckets** tab.
        4. From the **Name** column, copy the name of the target bucket. This bucket will store user-uploaded files. Save the bucket name for later use.
        5. From the **AWS Region** column, copy the region ID, for example, `us-east-1`, and save it for later use.
        6. In the upper-right corner, go to your account, then select **Security credentials**.
        7. On the **My Security Credentials** page, go to **Access keys** and click **Create access key**.
        8. On the **Alternatives to root user access keys** page, review the security recommendations. To continue, select the option, and then click **Create access key**. On the **Retrieve access key** page, your access key ID is displayed.
        9. Under **Secret access key**, click **Show** and then copy the access key ID and secret key from your browser window and save them for later use. Click **Done**. If you want to use temporary access with MFA instead of a secret key, you need a [session token](https://docs.aws.amazon.com/STS/latest/APIReference/API_GetSessionToken.html#:~:text=Returns%20a%20set%20of%20temporary,key%2C%20and%20a%20security%20token). To set up a session token, obtain this value via AWS API and specify the token in the `AWS_SESSION_TOKEN` variable in the `values.yaml` file. For more information, read [Using temporary credentials with AWS resources](https://docs.aws.amazon.com/IAM/latest/UserGuide/id_credentials_temp_use-resources.html).
      </Accordion>

      <Accordion title="2. On the Cognigy.AI Side">
        1. Open the Project that contains the Endpoint for which you want to configure a file storage. Go to **Deploy > Endpoints** and select an Endpoint or create one.
        2. Depending on the Endpoint you select, proceed as follows:
           * **Webchat v3** — activate the **Allow Attachment Upload** setting in **Webchat Behavior** in the **Attachment Upload** section and select **AWS** from the **File Storage Provider** list.
           * **Other Endpoints** — go to the **File Storage** section and select **AWS** from the **File Storage Provider** list.
        3. Next to **AWS Connection**, click **+** and fill in the following fields:
           * **Access Key ID** — enter the access key ID that you copied and saved previously.
           * **Secret Access Key** — enter the secret key that you copied and saved previously.
           * **Region** — enter the AWS region that you copied and saved previously.
           * **Bucket Name** — enter the name of the bucket that you copied and saved previously.
           * **Custom URL** — enter the custom URL of your S3-compatible storage. This parameter applies only for Amazon S3-compatible cloud storages.
        4. Click **Create**, then **Save**.
      </Accordion>
    </AccordionGroup>
  </Tab>

  <Tab title="Google Cloud Storage Bucket">
    <AccordionGroup>
      <Accordion title="1. On the Google Cloud Console Side">
        1. In the [Google Cloud console](https://console.cloud.google.com/), select **Cloud Storage > Buckets** in the left-side menu.
        2. On the **Buckets** page, copy the name of the target bucket from the **Bucket** column. This bucket will store user-uploaded files. Save the bucket name for later use.
        3. In the left-side menu, select **IAM & Admin > Service Accounts**.
        4. From the **Email** field, copy the email address and save it for later use.
        5. In the **Actions** column, click **Actions > Manage Keys**.
        6. On the **Keys** tab, click **Add Key > Create New Key** and select the JSON key type. The key will be downloaded to your computer. Open the JSON file and copy the entire value of the `private_key` parameter, including the lines:

        ```txt theme={null}
        -----BEGIN PRIVATE KEY-----
        -----END PRIVATE KEY-----
        ```

        Save the key for later use.
      </Accordion>

      <Accordion title="2. On the Cognigy.AI Side">
        1. On the Cognigy.AI side, open the Project that contains the Endpoint for which you want to configure a file storage. Go to **Deploy > Endpoints** and select an Endpoint or create one.
        2. Depending on the Endpoint you select, proceed as follows:
           * **Webchat v3** — activate the **Allow Attachment Upload** setting in **Webchat Behavior** in the **Attachment Upload** section and select **Google Cloud** from the **File Storage Provider** list.
           * **Other Endpoints** — go to the **File Storage** section and select **Google Cloud** from the **File Storage Provider** list.
        3. Next to **Google Cloud Connection**, click **+** and fill in the following fields:
           * **Bucket Name** — enter the bucket name that you copied and saved previously.
           * **Client Email** — enter the email address that you copied and saved previously.
           * **Private Key** — enter the key that you copied and saved previously.
        4. Click **Create**, then **Save**.
      </Accordion>
    </AccordionGroup>
  </Tab>
</Tabs>

To test file uploads for the Webchat v2 and Webchat v3 Endpoints, use [Demo Webchat](/webchat/demo). Upload a file in the Demo Webchat interface by either dragging it from your computer or clicking <img src="https://mintcdn.com/cognigy-15abf2ba/Aanuo4ANeXDMmSVF/_assets/icons/black-and-white/attach-files.svg?fit=max&auto=format&n=Aanuo4ANeXDMmSVF&q=85&s=b9e54f8a3b77b9edf320f354ce07836f" alt="attachment-icon" width="20" height="20" data-path="_assets/icons/black-and-white/attach-files.svg" />.

For other Endpoints, testing only works in the production environment. Upload a file to the chat interface and go to the file storage on your provider's side. If the file appears in the storage, the file was successfully uploaded.

### Access the File Storage through the Input Object

By default, the data of uploaded files is stored in the `input.data.attachments` array. Each file object in this array contains a file name, type, and URL pointing to the uploaded file:

```json theme={null}
{
  "name": "example_file.png",
  "url": "https://example.com/uploads/example_file.png",
  "type": "image"
}
```

<Accordion title="Use Cases">
  | Use Case                    | Description                                                                                                                        | CognigyScript                           | Example Output                                 |
  | --------------------------- | ---------------------------------------------------------------------------------------------------------------------------------- | --------------------------------------- | ---------------------------------------------- |
  | Confirm uploaded files      | To ensure the user uploaded the correct file, display the file name for confirmation.                                              | `{{input.data.attachments[0].name}}`    | `example_file.png`                             |
  | Provide the direct file URL | Share the direct URL of the uploaded file with the user.                                                                           | `{{input.data.attachments[0].url}}`     | `https://example.com/uploads/example_file.png` |
  | Validate attachments        | To check if a valid file has been uploaded in the most recent user input, verify the length of the `input.data.attachments` array. | `{{input.data.attachments.length}} > 0` | -                                              |
</Accordion>

### Resize Images

For image file types, such as JPEG, PNG, GIF, WebP, and others, you can automatically resize images based on the query parameters in the URL.
The available parameters are in the table.

| Query Parameter      | Description                                             |
| -------------------- | ------------------------------------------------------- |
| `maxWidth`           | The maximum width of the image.                         |
| `maxHeight`          | The maximum height of the image.                        |
| `maxFileSizeInBytes` | The maximum file size of the image, specified in bytes. |

<Accordion title="Use Cases">
  | Use Case                      | Description                                                                                                                                        | Example                                                                                                 | URL Example                                                             |
  | ----------------------------- | -------------------------------------------------------------------------------------------------------------------------------------------------- | ------------------------------------------------------------------------------------------------------- | ----------------------------------------------------------------------- |
  | Attach image without changes  | An attachment is uploaded with the original URL.                                                                                                   | The image has dimensions of 3840 x 2160 and a size of 8 MB.                                             | `https://files-trial.cognigy.ai/123/456/789`                            |
  | Resize to specific dimensions | If you provide the `maxWidth` and `maxHeight` parameters, the image is resized to fit these parameters while maintaining the aspect ratio.         | To resize the image to a maximum of 640x480, append the `maxWidth=640` and `maxHeight=480` parameters.  | `https://files-trial.cognigy.ai/123/456/789?maxWidth=640&maxHeight=480` |
  | Limit file size               | If you provide the `maxFileSizeInBytes` parameter, the image quality is gradually reduced until the image file size meets the specified file size. | To ensure the image is less than 100 KB (102,400 bytes), use the `maxFileSizeInBytes=102400` parameter. | `https://files-trial.cognigy.ai/123/456/789?maxFileSizeInBytes=102400`  |

  **HTTP Error Codes**

  | Error Code | Description                                                                                                                             |
  | ---------- | --------------------------------------------------------------------------------------------------------------------------------------- |
  | `500`      | Returns if the image can't be resized according to the specified parameters. For example, if the `maxFileSizeInBytes` can't be reached. |
</Accordion>

## More Information

* [Azure Blob Storage](https://learn.microsoft.com/en-us/azure/storage/blobs/storage-blobs-introduction)
* [Amazon S3](https://docs.aws.amazon.com/AmazonS3/latest/userguide/Welcome.html)
* [Google Cloud Storage](https://cloud.google.com/storage/docs)
* [Create a Bucket in Azure Blob Storage](https://learn.microsoft.com/en-us/azure/storage/blobs/storage-quickstart-blobs-portal#create-a-container)
* [Create a Bucket in Amazon S3](https://docs.aws.amazon.com/AmazonS3/latest/userguide/create-bucket-overview.html)
* [Create a Bucket in Google Cloud Storage](https://cloud.google.com/storage/docs/creating-buckets)
