Skip to main content
Version badge 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

Restrictions

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:
  • Azure Blob Storage Container
  • Amazon S3 Bucket
  • Google Cloud Storage Bucket
  1. Go to the Azure portal 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.
  6. 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.
  7. 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.
  8. 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.
  9. Click Create, then Save.
To test file uploads for the Webchat v2 and Webchat v3 Endpoints, use Demo Webchat. Upload a file in the Demo Webchat interface by either dragging it from your computer or clicking attachment-icon. 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:
{
  "name": "example_file.png",
  "url": "https://example.com/uploads/example_file.png",
  "type": "image"
}
Use CaseDescriptionCognigyScriptExample Output
Confirm uploaded filesTo 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 URLShare the direct URL of the uploaded file with the user.{{input.data.attachments[0].url}}https://example.com/uploads/example_file.png
Validate attachmentsTo 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-

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 ParameterDescription
maxWidthThe maximum width of the image.
maxHeightThe maximum height of the image.
maxFileSizeInBytesThe maximum file size of the image, specified in bytes.
Use CaseDescriptionExampleURL Example
Attach image without changesAn 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 dimensionsIf 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 sizeIf 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 CodeDescription
500Returns if the image can’t be resized according to the specified parameters. For example, if the maxFileSizeInBytes can’t be reached.

More Information

I