bmc_hub/migrations/068_conversations_module.sql
Christian eacbd36e83 feat: Implement Transcription Service for audio files using Whisper API
- Added `transcription_service.py` to handle audio transcription via Whisper API.
- Integrated logging for transcription processes and error handling.
- Supported audio format checks based on configuration settings.

docs: Create Ordre System Implementation Plan

- Drafted comprehensive implementation plan for e-conomic order integration.
- Outlined business requirements, database changes, backend and frontend implementation details.
- Included testing plan and deployment steps for the new order system.

feat: Add AI prompts and regex action capabilities

- Created `ai_prompts` table for storing custom AI prompts.
- Added regex extraction and linking action to email workflow actions.

feat: Introduce conversations module for transcribed audio

- Created `conversations` table to store transcribed conversations with relevant metadata.
- Added indexing for customer, ticket, and user linkage.
- Implemented full-text search capabilities for Danish language.

fix: Add category column to conversations for classification

- Added `category` column to `conversations` table for better conversation classification.
2026-01-11 19:23:21 +01:00

39 lines
1.5 KiB
SQL

-- 068_conversations_module.sql
-- Table for storing transcribed conversations (calls, voice notes)
CREATE TABLE IF NOT EXISTS conversations (
id SERIAL PRIMARY KEY,
customer_id INTEGER REFERENCES customers(id) ON DELETE CASCADE,
ticket_id INTEGER REFERENCES tticket_tickets(id) ON DELETE SET NULL,
user_id INTEGER REFERENCES auth_users(id) ON DELETE SET NULL,
email_message_id INTEGER REFERENCES email_messages(id) ON DELETE SET NULL,
title VARCHAR(255) NOT NULL,
transcript TEXT, -- The full transcribed text
summary TEXT, -- AI generated summary (optional)
audio_file_path VARCHAR(500) NOT NULL,
duration_seconds INTEGER DEFAULT 0,
-- Privacy and Deletion
is_private BOOLEAN DEFAULT FALSE,
deleted_at TIMESTAMP, -- Soft delete
source VARCHAR(50) DEFAULT 'email', -- 'email', 'upload', 'phone_system'
created_at TIMESTAMP DEFAULT CURRENT_TIMESTAMP,
updated_at TIMESTAMP DEFAULT CURRENT_TIMESTAMP
);
-- Index for linkage
CREATE INDEX idx_conversations_customer ON conversations(customer_id);
CREATE INDEX idx_conversations_ticket ON conversations(ticket_id);
CREATE INDEX idx_conversations_user ON conversations(user_id);
-- Full Text Search Index for Danish
ALTER TABLE conversations ADD COLUMN search_vector tsvector GENERATED ALWAYS AS (
to_tsvector('danish', coalesce(title, '') || ' ' || coalesce(transcript, ''))
) STORED;
CREATE INDEX idx_conversations_search ON conversations USING GIN(search_vector);