Skip to content

Efficient Document Handling with AI on

This tutorial will guide you through setting up a robust document management system on, utilizing the power of Generative AI to classify documents into categories such as invoices, CVs, quotes, contracts, and others. This system simplifies the process of managing, storing, and retrieving documents, enhancing organizational efficiency.


  • Active account on
  • Access to OpenAI Azure and the Collection app installed in your workspace.

Step 1: Setting Up Your Workspace on

Begin by logging into and navigating to the Builder product to initiate a new workspace specifically for document management.

Workspace Creation:

  1. Click on the "Create Workspace" button.
  2. Name your workspace to reflect its purpose, such as "Document Management System."
  3. Select the necessary settings for your project.

Step 2: Creating a Document Upload Page

This step involves setting up a page within your workspace where users can upload documents to be automatically classified by AI.

Page Setup:

Creating a Document Upload Form on

This form acts as the entry point for document submissions into your system.

1. Initiating a New Page:

  1. Within your workspace, navigate to the section where you can manage or create new pages.
  2. Click on "Create a New Page" and begin customizing the user experience.

2. Naming and Setting Up Your Page:

  1. Give your page a meaningful name like "Document Upload Form."
  2. Assign a slug, e.g., upload-docs, which will be used in the page's URL path.

3. Building the Form:

  1. Locate the form builder section within your page settings.
  2. Click on "Add a Block" and search for "Form" to add it to your page.

4. Configuring Form Specifications:

  1. Add fields for document upload and description:
  2. For Document Field:
    • Add a new field with the property name attachment, set to allow file uploads, specifically .pdf files.
  3. For Description Field:
    • Add a "Description" field as a text area for users to describe the document content.

Configuring Form Specifications

slug: upload-docs
name: Document Upload Form
  - slug: Form
      type: object
          type: string
          ui:widget: upload
          title: Document Upload
          description: Attach your document here.
              accept: .pdf
          type: textarea
          title: Document Description
          placeholder: Describe the document here.
    onSubmit: save

5. Displaying Data Table:

  1. Add a DataTable block to show the uploaded documents along with their classified categories.
  2. Configure columns for ID, description, category, and actions such as delete.
  3. Also, make sure your DataTable block listen to a given event thanks to the updateOn field, here we will choose updateData.
    You can also add an onInit event which will be emitted when the block is loaded in the page by a user.
  - slug: DataTable
      - label: ID
        key: id
        type: string
      - label: Description
        key: description
        type: string
      - label: Category
        key: category
        type: string
      - label: Actions
          - label: Delete
              type: event
              value: deleteData
                id: ${id}
        loading: true
        fr: Uploaded Documents
        en: Uploaded Documents
    updateOn: updateData
    onInit: initData
      - {}
  1. Obtain the URL for your page; each page follows the format: To find it, click on the share icon located between the page name and the "duplicate" action. If you've named your slug "index," access it directly via

Get page URL

Step 3: Automating Document Classification

Set up an automation within that triggers upon document upload to classify the document using AI.

Event Listening automations:

  1. Navigate to the "Automations" section of your workspace.
  2. Create a new automation named "Document Classification Handler".
  3. Configure this automation to use OpenAI Azure for categorizing the documents based on the description provided during upload.

Automation builder

slug: manage-form
name: Manage Form
          persist: true
      model: gpt-3.5-turbo
        - role: system
          content: 'Classify the document within these categories: invoice, CV, quote, contract, others. Provide your categorization based on the content.'
        - role: user
          content: '{{payload.description}}'
      output: data
  - conditions:
        - set:
            name: payload.category
            value: '{{data.choices[0].message.content}}'
            type: merge
        - emit:
              currentSocket: true
              persist: true
            event: error
            payload: '{{data}}'
        - set:
            name: payload.error
            value: '{{data.error.message}}'
            type: merge
  - Collection.insert:
      data: '{{payload}}'
  - emit:
        currentSocket: true
        persist: false
      event: initData
    - save
output: '{{payload}}'

Automation for Retrieving Data

This automation ensures that the latest data is always displayed on your DataTable after any operation, such as uploads or deletions.

Retrieving Data Automation Setup:

  1. Set up a new automation within the "Automations" section called "Get Data".
  2. Configure this automation to fetch all documents from the collection and emit an event to update the data table on the front end.
slug: get-data
name: Get Data
  - Collection.find:
      query: {}
      output: data      
        createdAt: -1        
  - emit:
      event: updateData
        data: '{{data}}'
          loading: false  
    - initData   
output: ''               

Automation for Deleting Data

This automation will handle requests to delete documents from your system, ensuring that data management remains streamlined and secure.

Deleting Data Automation Setup:

  1. Navigate to the "Automations" section of your workspace.
  2. Create a new automation named "Delete Data".
  3. Set up the automation to listen for the deleteData event and execute a deletion from your document collection.
slug: delete-data
name: Delete Data
  - conditions:
        - break: {}            
      default: []
  - Collection.deleteOne:
        _id: '{{}}'
  - emit:
        currentSocket: true
        persist: true
      event: initData   
    - deleteData
output: ''

Version Control and Deployment:

  1. After setting up, push the latest changes and create a version for easy updates or rollbacks.

Push Learn more about Version Control and RBAC to manage access and permissions.

Step 4: Monitoring and Optimization

Regularly check the activity log in to monitor actions from form submissions to document classification.



By following this guide, you've set up a sophisticated AI-powered document management system on that categorizes documents efficiently, improving your organization's document handling capabilities.

Explore further enhancements and adaptations for broader applications using This setup is just the beginning of transforming your business processes into more intelligent and automated operations.