This tutorial guides you through building an intelligent document classification system using Prisme.ai. You’ll create a solution that automatically categorizes uploaded documents into types such as invoices, CVs, quotes, contracts, and more using the power of generative AI.

What You’ll Build

A complete document management system with:

  • A user-friendly document upload interface
  • Automatic AI-based document classification
  • A searchable and filterable document repository
  • Document management capabilities (view, categorize, delete)

This solution integrates AI Knowledge for classification with Collection for document storage, creating a powerful yet simple document management system.

Prerequisites

Before starting this tutorial, make sure you have:

  • An active Prisme.ai account
  • The Knowledge Client app installed in your workspace
  • The Collection app installed in your workspace
  • Basic familiarity with Prisme.ai Builder

Step 1: Creating Your Document Management Workspace

Let’s start by setting up a dedicated workspace for our document management system:

1

Access AI Builder

Log in to your Prisme.ai account and navigate to the AI Builder product

2

Create a New Workspace

Click the “Create Workspace” button to start a new project

3

Configure Workspace Settings

Name your workspace “Document Management System” (or a name of your choice) and configure any additional settings as needed

Step 2: Building the Document Upload Interface

Now, let’s create a user-friendly interface for document uploads and management:

1

Create a New Page

In your workspace, navigate to the Pages section and click “Create Page”

2

Configure Page Properties

  • Name your page “Document Upload Form”
  • Set the slug to “upload-docs” (this will be used in the URL)
3

Add a Form Block

Add a Form block to your page for document uploads with the following configuration:

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

Add a Data Table Block

Add a DataTable block to display uploaded documents and their classifications:

- slug: DataTable
  columns:
    - label: ID
      key: id
      type: string
    - label: Description
      key: description
      type: string
    - label: Category
      key: category
      type: string
    - label: Actions
      actions:
        - label: Delete
          action:
            type: event
            value: deleteData
            payload:
              id: ${_id}
  config:
    customProps:
      loading: true
    title:
      fr: Uploaded Documents
      en: Uploaded Documents
  updateOn: updateData
  onInit: initData
  data:
    - {}
5

Save Your Page

Save your page configuration. You should now have a form for uploads and a table to display documents

Step 3: Creating the Document Classification Automation

Next, let’s set up the automation that will classify documents when they’re uploaded:

1

Navigate to Automations

In your workspace, go to the Automations section

2

Create Document Classification Automation

Create a new automation named “Manage Form” with the following configuration:

slug: manage-form
name: Manage Form
do:
  - Knowledge Client.chat-completion:
      messages:
        - 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:
      '{{data.response}}':
        - set:
            name: payload.category
            value: '{{data.response}}'
            type: merge
      default:
        - emit:
            target:
              currentSocket: true
            options:
              persist: true
            event: error
            payload: '{{data}}'
        - set:
            name: payload.error
            value: '{{data.error.message}}'
            type: merge
  - Collection.insert:
      data: '{{payload}}'
  - emit:
      target:
        currentSocket: true
      options:
        persist: false
      event: initData
when:
  events:
    - save
output: '{{payload}}'
3

Create Data Retrieval Automation

Create another automation named “Get Data” to fetch and display documents:

slug: get-data
name: Get Data
do:
  - Collection.find:
      query: {}
      output: data      
      sort:
        createdAt: -1        
  - emit:
      event: updateData
      payload:
        data: '{{data}}'
        customProps:
          loading: false  
when:
  events:
    - initData   
output: ''
4

Create Document Deletion Automation

Create a final automation named “Delete Data” to handle document removal:

slug: delete-data
name: Delete Data
do:
  - conditions:
      '!{{payload.data._id}}':
        - break: {}            
      default: []
  - Collection.deleteOne:
      query:
        _id: '{{payload.data._id}}'
  - emit:
      target:
        currentSocket: true
      options:
        persist: true
      event: initData   
when:
  events:
    - deleteData
output: ''
5

Deploy Your Automations

Save all automations and make sure they’re properly configured to work together

Step 4: Testing and Using Your Document Classification System

Now it’s time to test your document management system:

1

Access Your Document Upload Page

Navigate to your document upload page using the URL format: workspace-slug.pages.host/lang/upload-docs

2

Upload a Test Document

  • Upload a sample document (PDF) through the form
  • Add a description that gives context about the document’s content
  • Submit the form
3

Verify Classification

After a moment, the document should appear in the data table with its AI-determined classification

4

Test Document Management

Try deleting a document to ensure the delete functionality works correctly

Step 5: Version Control and Deployment

To finalize your document classification system:

1

Push Your Changes

Use the “Push” button in your workspace to save the current state of your project

2

Create a Version

Create a version of your workspace for easy rollback if needed in the future

3

Configure Access Controls

Set up appropriate Role-Based Access Control (RBAC) to determine who can use your document management system

Monitoring and Improving Your System

After deployment, regularly check the system’s performance:

1

Monitor Activity Logs

Review the activity logs to track document uploads and classifications

2

Review Classification Accuracy

Periodically check if documents are being classified correctly and refine your system as needed

3

Optimize for Performance

Make adjustments to improve speed and accuracy as your document volume grows

Extending Your Document Classification System

Your base system is powerful, but consider these enhancements:

  • Advanced Classification: Train a more specialized model for your specific document types
  • Content Extraction: Extract key information from documents based on their category
  • Automated Workflows: Trigger specific actions based on document type (e.g., route invoices to accounting)
  • Search Functionality: Add search capabilities to find documents by content or metadata
  • Integration: Connect with other systems like CRM or ERP platforms

Next Steps