How softoft-orga/open-ticket-ai works
Purpose and Runtime Entry Points
Open Ticket AI is a Python runtime that classifies and routes support tickets using ML, then applies results back to ticket systems. Primary startup and composition points are src/open_ticket_ai/main.py, src/open_ticket_ai/app.py, and src/open_ticket_ai/pipeline.py. It is packaged as a core engine with pluggable classifier and ticket-system integrations.
Configuration, Application Assembly, and Workflows
Settings drive assembly of ticket-system services, classifier services, workflows, and API exposure. src/open_ticket_ai/settings.py supplies runtime configuration; src/open_ticket_ai/app.py builds the application; src/open_ticket_ai/workflow_manager.py owns configured workflow lifecycle. Deployment mounts config through OT_AI_CONFIG, with example/container assets in deployment/config.yml, deployment/Dockerfile, and deployment/compose.yml.
Pipe-Based Processing Model
The central execution abstraction is a pipe: units consume and enrich a shared execution context, and may be composed into workflows. Core contracts and context/result models are in src/open_ticket_ai/core/pipes/pipe.py, src/open_ticket_ai/core/pipes/pipe_context_model.py, and src/open_ticket_ai/core/pipes/pipe_models.py. This boundary enables plugins and reusable stages without coupling orchestration to concrete services.
Workflow Execution and Scheduling
Configured pipelines run through composite pipes and sequential orchestration/runner implementations. src/open_ticket_ai/pipes/composite_pipe.py, src/open_ticket_ai/pipes/orchestrators/simple_sequential_orchestrator.py, and src/open_ticket_ai/pipes/pipe_runners/simple_sequential_runner.py define execution flow. src/open_ticket_ai/pipes/interval_trigger_pipe.py periodically triggers work; templates such as src/open_ticket_ai/pipes/templates/classify_and_route.py assemble the standard fetch→classify→route workflow.
Ticket Acquisition and Mutation Boundary
Ticket-system pipes isolate workflow logic from vendor APIs: fetch tickets, update ticket fields/routing, and add notes. These stages are in src/open_ticket_ai/pipes/ticket_system_pipes/fetch_tickets_pipe.py, src/open_ticket_ai/pipes/ticket_system_pipes/update_ticket_pipe.py, and src/open_ticket_ai/pipes/ticket_system_pipes/add_note_pipe.py. The vendor-neutral contract and unified ticket models live in src/open_ticket_ai/core/ticket_system_integration/ticket_system_service.py and src/open_ticket_ai/core/ticket_system_integration/unified_models.py.
Classification Boundary and Implementations
Classification pipes send ticket content to an abstract AI classification service and place predictions into workflow context. Relevant contracts and stage are src/open_ticket_ai/core/ai_classification_services/classification_service.py, src/open_ticket_ai/core/ai_classification_services/classification_models.py, and src/open_ticket_ai/pipes/classification_pipe.py. The included local Hugging Face implementation is src/open_ticket_ai/hf_local/hf_classification_service.py; alternate providers can implement the same core interface.
External Interfaces and Integrations
The FastAPI-style HTTP layer exposes classification, ticket, workflow, and settings endpoints via src/open_ticket_ai/api/app.py, src/open_ticket_ai/api/routers/classify.py, and src/open_ticket_ai/api/routers/workflows.py. Concrete remote ticket-system adapters support Zammad and OTOBO/Znuny in src/open_ticket_ai/zammad/zammad_ticket_system_service.py and src/open_ticket_ai/otobo_znuny/oto_znuny_ts_service.py. Docker deploys the engine on port 8080; external dependencies are configured ticket-system APIs and the selected ML classifier/runtime.
Main entry points: app.py Application assembly · classify_and_route.py Classify & route template · classify.py Classify & workflow routes · workflow_manager.py Workflow manager
Components 20
Runtime Assembly
- Runtime entry
src/open_ticket_ai/main.py - Application assembly · Builds configured services, workflows, and API exposure.
src/open_ticket_ai/app.py - Runtime settings · Loaded from the OT_AI_CONFIG-mounted configuration.
src/open_ticket_ai/settings.py - Workflow manager
src/open_ticket_ai/workflow_manager.py - Pipeline composition
src/open_ticket_ai/pipeline.py
Pipe Workflows
- Pipe contract & context · Shared execution context and result models for reusable stages.
src/open_ticket_ai/core/pipes/pipe.py - Composite workflow
src/open_ticket_ai/pipes/composite_pipe.py - Sequential orchestrator
src/open_ticket_ai/pipes/orchestrators/simple_sequential_orchestrator.py - Sequential runner
src/open_ticket_ai/pipes/pipe_runners/simple_sequential_runner.py - Interval trigger
src/open_ticket_ai/pipes/interval_trigger_pipe.py - Classify & route template · Assembles the standard fetch → classify → route flow.
src/open_ticket_ai/pipes/templates/classify_and_route.py
Integration Boundaries
- Ticket service contract · Vendor-neutral ticket operations and unified ticket models.
src/open_ticket_ai/core/ticket_system_integration/ticket_system_service.py - Ticket fetch, update & note · Reads tickets and applies routing fields or notes.
src/open_ticket_ai/pipes/ticket_system_pipes/fetch_tickets_pipe.py - Classification service contract · Abstract prediction service and classification models.
src/open_ticket_ai/core/ai_classification_services/classification_service.py - Classification stage · Adds ticket predictions to the shared workflow context.
src/open_ticket_ai/pipes/classification_pipe.py - Local Hugging Face classifier
src/open_ticket_ai/hf_local/hf_classification_service.py - Zammad / OTOBO adapters · Concrete remote ticket-system implementations.
src/open_ticket_ai/zammad/zammad_ticket_system_service.py
External Access
- HTTP API · Exposes classification, ticket, workflow, and settings operations.
src/open_ticket_ai/api/app.py - Classify & workflow routes
src/open_ticket_ai/api/routers/classify.py - Ticket-system APIs
Connections 22
- Runtime entry → Application assembly: starts
- Runtime settings → Application assembly: configures
- Application assembly → Pipeline composition: composes
- Application assembly → Workflow manager: registers workflows
- Application assembly → HTTP API: mounts
- Pipeline composition → Classify & route template: uses
- Workflow manager → Interval trigger: manages
- Interval trigger → Composite workflow: triggers
- Classify & route template → Composite workflow: builds
- Composite workflow → Sequential orchestrator: delegates execution
- Sequential orchestrator → Sequential runner: runs stages
- Sequential runner → Pipe contract & context: uses context
- Classify & route template → Ticket fetch, update & note: fetches and mutates
- Classify & route template → Classification stage: classifies
- Ticket fetch, update & note → Ticket service contract: depends on
- Classification stage → Classification service contract: requests prediction
- Local Hugging Face classifier → Classification service contract: implements
- Zammad / OTOBO adapters → Ticket service contract: implements
- Zammad / OTOBO adapters → Ticket-system APIs: calls
- HTTP API → Classify & workflow routes: includes
- Classify & workflow routes → Workflow manager: controls workflows
- Classify & workflow routes → Classification service contract: invokes classification