A ILIAS 9 PageComponent plugin that enables embedding AI-powered chat interfaces directly into learning pages. Each chat instance can be configured with custom system prompts for educational purposes, such as interactive exercises in AI literacy or subject-specific tutoring.
🎯 Modular Architecture: This plugin features a modular LLM service architecture that supports multiple AI providers (RAMSES by OSKI.nrw, OpenAI, and easy integration of additional services). Organizations can configure their preferred AI service or add custom integrations.
AI chat interface showing conversation flow with multimodal capabilities
PageComponent seamlessly integrated into ILIAS learning content
Comprehensive configuration options for educators
Multimodal file upload with image preview functionality
- Multiple AI Chats per Page: Embed unlimited AI chat instances on a single ILIAS page
- Custom System Prompts: Configure each chat with specific educational contexts and roles
- Multimodal Support: Full support for text, images, and PDF document analysis
- Background Files: Upload context documents (text, images, PDFs) that inform AI responses
- Session Management: User-specific chat sessions with message history persistence
- Export/Import Support: Full ILIAS export/import compatibility with chat configurations and background files
- Responsive UI: Modern, accessible interface using ILIAS 9 UI components
- Modular LLM Architecture: Easy integration of multiple AI service providers
- Built-in Services: Pre-configured support for RAMSES (OSKI.nrw) and OpenAI GPT
- Service-Specific Configuration: Independent settings per AI service (API endpoints, models, capabilities)
- Dynamic Model Selection: Automatic model discovery from AI service APIs
- Flexible Routing: Users can select AI service per chat instance (or enforce global default)
- Global Configuration: Administrator limits override local chat settings
- Real-time Validation: Limits with live feedback (character limits, upload limits)
- Session Detection: Automatic ILIAS session validation with user-friendly expiration handling
- File Processing Pipeline: Automatic image optimization, PDF-to-image conversion, multimodal AI integration
- Production Ready: Comprehensive logging, error handling, and security measures
- ILIAS: 9.x
- PHP: 8.1 or higher
- MySQL: 8.0 or higher
- Web Server: Apache 2.4+ or Nginx 1.18+
- AI Service: Compatible with OpenAI-compatible API endpoints (e.g., RAMSES/OSKI.nrw, OpenAI, custom deployments)
- PHP Extensions:
curl,gd,imagick(recommended),ghostscript(for PDF processing) - ILIAS ResourceStorage: For secure file handling (built-in ILIAS 9)
- AIChat Repository Plugin: Provides enhanced RBAC permission control for AI chat component creation. Without this plugin, all content editors can create AI chat components. Recommended for institutions requiring granular access control.
✅ Independent Plugin: This plugin is fully independent and does not require the AIChat base plugin. All AI service integration is handled directly within this plugin.
This plugin implements a two-tier permission system to control who can add AI chat components to pages:
When the AIChat Repository Plugin is installed and active:
- Uses AIChat's
create_xaicpermission for access control - Administrators can precisely control which users/roles can create AI chat components
- Provides granular permission management through ILIAS's standard role system
When AIChat plugin is not available:
- Falls back to basic
writepermission check - Any user with content editing rights can add AI chat components
- Less granular but ensures functionality for content creators
PageComponent plugins cannot integrate directly into ILIAS's standard RBAC system due to technical limitations (only Repository Object plugins support full RBAC integration). This plugin works around this limitation by leveraging the AIChat plugin's existing RBAC implementation when available.
- Recommended Setup: Install AIChat plugin even if not directly used, to enable fine-grained permission control
- Fallback Risk: Without AIChat plugin, all content editors can create AI chats - evaluate if this aligns with your institution's AI usage policies
- Administrator Control: Global configuration settings always override individual chat configurations regardless of permission level
- Navigate to the root directory of your ILIAS installation
- Run the following commands to clone the plugin repository:
mkdir -p Customizing/global/plugins/Services/COPage/PageComponent/AIChatPageComponent
cd Customizing/global/plugins/Services/COPage/PageComponent/
git clone https://github.com/cce-uzk/AIChatPageComponent.git ./AIChatPageComponent
cd AIChatPageComponent
git checkout main- For enhanced RBAC control: Install the AIChat Repository Plugin before this plugin to enable granular permission management
- For basic functionality: This plugin is self-contained and works without additional plugins (uses fallback permission system)
Navigate to the root directory of your ILIAS installation:
composer du
npm install
php setup/setup.php updateThe plugin automatically creates required database tables via sql/dbupdate.php:
pcaic_chats: Chat configurations per PageComponentpcaic_sessions: User sessions per chatpcaic_messages: Messages bound to sessionspcaic_attachments: File attachmentspcaic_config: Plugin-wide configuration settings
In ILIAS Administration:
- Navigate to Administration > Extending ILIAS > Plugins
- Find AIChatPageComponent in the list
- Click Install
- Click Activate
After plugin activation, configure your preferred AI service(s):
- Navigate to Administration > Extending ILIAS > Plugins
- Find AIChatPageComponent and click Configure
- Default AI Service: Select which service to use by default for new chats
- Force Default Service: Optionally enforce the default service (prevents users from selecting other services)
- Default Values: Configure global defaults for chat instances
- File Upload Constraints: Set limits for file sizes and attachments
Each AI service has its own configuration tab:
- Enable Service: Activate RAMSES for use in chat instances
- API Base URL: Set the base API endpoint (default:
https://ramses-oski.itcc.uni-koeln.de) - API Token: Enter your API authentication token
- Selected Model: Choose from available models
- Refresh Models: Fetch latest models from API
- Temperature: Control response randomness (0.0-2.0)
- Enable Streaming: Real-time response streaming
- RAG Configuration: Upload files to RAG collections for efficient retrieval
- Enable Service: Activate OpenAI for use in chat instances
- API Base URL: Set the base API endpoint (default:
https://api.openai.com) - API Token: Enter your OpenAI API key
- Selected Model: Choose from available GPT models
- Refresh Models: Fetch latest models from OpenAI API
- Temperature: Control response randomness (0.0-2.0)
- Enable Streaming: Real-time response streaming
Verify your system has required components:
# Check Ghostscript (for PDF processing)
gs --version
# Check ImageMagick
identify -version
# Check PHP extensions
php -m | grep -E "(curl|gd|imagick)"- Edit any ILIAS page (Course, Learning Module, Wiki, etc.)
- Click Insert > AI Chat
- Configure the chat:
- System Prompt: Define the AI's role and behavior
- Background Files: Upload context documents (optional)
- System Prompt: Customize AI behavior and context
You are a helpful tutor for organic chemistry. Help students understand molecular structures and reactions. Always provide clear explanations with examples. - Background Files: Upload supporting materials
- Text files (.txt, .md, .csv): Added to AI context
- Images (.jpg, .png, .gif, .webp): Visual analysis with automatic optimization
- PDFs (.pdf): Converted to images for multimodal analysis (default up to 20 pages)
- Memory Limit: Number of previous messages to remember (default: 10)
- Global Overrides: Administrator settings take precedence over local configuration
- Navigate to any page containing AI chat components
- Type messages in the chat interface with real-time character counter
- Upload images or documents for AI analysis (drag & drop supported)
- View conversation history with copy/download functionality
- Each chat maintains separate user-specific session context
- Automatic session validation with user-friendly expiration handling
- Images: Direct multimodal analysis and discussion
- PDFs: Automatic page-by-page conversion (ghostscript) and AI analysis
- Text Files: Content integration into conversation context
- File Persistence: Uploads survive page reloads and session changes
- Preview Support: Image previews and download links for all file types
- ILIAS Course Export: AI chat components are automatically included in course exports
- Configuration Preservation: System prompts, settings, and background files are fully preserved
- File Integrity: Background files are exported and re-imported with proper ILIAS ResourceStorage integration
- Independent Instances: Imported chats create new, independent configurations (no shared data with originals)
- Cross-Instance Compatibility: Export from one ILIAS instance, import to another while maintaining full functionality
AIChatPageComponent/
├── classes/ # Core plugin classes
│ ├── ai/ # AI service integrations (modular LLM architecture)
│ │ ├── class.AIChatPageComponentLLM.php # Abstract base class
│ │ ├── class.AIChatPageComponentLLMRegistry.php # Service registry
│ │ ├── class.AIChatPageComponentRAMSES.php # RAMSES implementation
│ │ └── class.AIChatPageComponentOpenAI.php # OpenAI implementation
│ ├── platform/ # Configuration bridge
│ └── class.*.php # ILIAS integration classes
├── src/ # Modern PHP 8+ classes
│ └── Model/ # Database models (ChatConfig, ChatSession, ChatMessage, Attachment)
├── js/ # Frontend JavaScript (ES6+ with comprehensive JSDoc)
├── css/ # Modern CSS with ILIAS 9 UI integration
├── sql/ # Database schema (dbupdate.php)
├── lang/ # Translations (DE/EN)
└── vendor/ # Composer dependencies
The plugin implements a service registry pattern for AI provider integration:
AIChatPageComponentLLM: Abstract base class defining the service contractAIChatPageComponentLLMRegistry: Central registry for service discovery and instantiation- Service Implementations: Each AI service extends the base class with provider-specific logic
New AI services are automatically integrated into:
- Configuration GUI (dynamic tab generation)
- Service selectors (admin and user-facing)
- API routing and message handling
- No core file modifications required!
See the Development section below for step-by-step integration guide.
The plugin uses the following table structure with clean separation of concerns:
pcaic_chats: PageComponent configuration (system_prompt, background_files, AI service, limits)pcaic_sessions: User-specific chat sessions with automatic cleanuppcaic_messages: Conversation history bound to sessionspcaic_attachments: File attachments with ILIAS IRSS integrationpcaic_config: Global plugin configuration (per-service settings, admin overrides)
- Backend-Controlled: All configuration managed server-side
- Clean Frontend: Only sends
chat_id+message+attachment_ids - Session Management: Automatic user session creation and management
- Service Routing: Dynamic LLM selection based on chat configuration
- RAMSES (OSKI.nrw) with RAG support
- OpenAI GPT
- Custom Services: Easy integration of additional providers
- Text Files (txt, md, csv): Direct content integration to system prompt
- Images (jpg, png, gif, webp): ILIAS Flavours compression → Base64 → Multimodal AI
- PDFs: Ghostscript page-wise conversion → PNG images → Base64 → Multimodal AI
- Optimization: Size limits (default: 15MB image data, 20 pages per PDF), automatic compression
- Error Handling: Fallbacks for failed conversions, graceful degradation
- PHP 8.1+ with strict types and modern features
- PSR-4 autoloading via Composer
- ILIAS 9 UI components and services
- Comprehensive PHPDoc documentation for all classes and methods
- Comprehensive JSDoc documentation for all JavaScript functions
- Professional error handling with session validation and user feedback
- Comprehensive logging with structured context
The plugin's modular architecture makes it easy to integrate new AI providers. Follow these steps:
Create a new PHP class in classes/ai/ extending AIChatPageComponentLLM:
<?php declare(strict_types=1);
namespace ai;
/**
* Example AI Service Implementation
*
* @author Your Name <your.email@example.com>
*/
class AIChatPageComponentExample extends AIChatPageComponentLLM
{
// Service Metadata
public static function getServiceId(): string
{
return 'example';
}
public static function getServiceName(): string
{
return 'Example AI';
}
public static function getServiceDescription(): string
{
return 'Example AI Service';
}
// Configuration Management
public function getConfigurationFormInputs(): array
{
$ui_factory = $this->getDIC()->ui()->factory();
$plugin = \ilAIChatPageComponentPlugin::getInstance();
$inputs = [];
// Enable Service Checkbox
$enabled = \platform\AIChatPageComponentConfig::get('example_service_enabled') ?: '0';
$inputs['example_service_enabled'] = $ui_factory->input()->field()->checkbox(
$plugin->txt('config_service_enabled'),
$plugin->txt('config_service_enabled_info')
)->withValue($enabled === '1');
// API URL
$api_url = \platform\AIChatPageComponentConfig::get('example_api_url') ?: 'https://example.com';
$inputs['example_api_url'] = $ui_factory->input()->field()->text(
$plugin->txt('config_api_url'),
$plugin->txt('config_api_url_info')
)->withValue($api_url);
// API Token (Password field)
$inputs['example_api_token'] = $ui_factory->input()->field()->password(
$plugin->txt('config_api_token'),
$plugin->txt('config_api_token_info')
)->withRequired(true);
// Model Selection (with cached models from API)
$selected_model = \platform\AIChatPageComponentConfig::get('example_selected_model');
$cached_models = \platform\AIChatPageComponentConfig::get('example_cached_models');
if (is_array($cached_models) && !empty($cached_models)) {
$model_options = $cached_models; // ['example-1-alpha' => 'Example 1 Alpha']
$select_field = $ui_factory->input()->field()->select(
$plugin->txt('config_selected_model'),
$model_options,
$plugin->txt('config_selected_model_info')
)->withRequired(true);
if ($selected_model && isset($model_options[$selected_model])) {
$select_field = $select_field->withValue($selected_model);
}
$inputs['example_selected_model'] = $select_field;
}
// Add more service-specific fields as needed...
return $inputs;
}
public function saveConfiguration(array $formData): void
{
foreach ($formData as $key => $value) {
// Handle Password objects
if ($value instanceof \ILIAS\Data\Password) {
$value = $value->toString();
}
// Save to config
\platform\AIChatPageComponentConfig::set($key, $value);
}
}
public static function getDefaultConfiguration(): array
{
return [
'example_service_enabled' => '1',
'example_api_url' => 'https://example.com',
'example_selected_model' => 'example-1-alpha',
'example_streaming_enabled' => '1',
'example_file_handling_enabled' => '1',
];
}
// Service Capabilities
public function getCapabilities(): array
{
return [
'streaming' => true,
'rag' => false, // Set to true if your service supports RAG
'multimodal' => true,
'file_types' => ['pdf'],
'max_tokens' => 200000,
];
}
// Message Sending Implementation
public function sendMessage(string $message, array $context = []): array
{
// Implement your service's API call here
// Return format: ['content' => 'AI response', 'model' => 'model-id']
$api_url = \platform\AIChatPageComponentConfig::get('example_api_url');
$api_token = \platform\AIChatPageComponentConfig::get('example_api_token');
$model = \platform\AIChatPageComponentConfig::get('example_selected_model');
// Build request payload according to your API spec
$payload = [
'model' => $model,
'messages' => $context,
'max_tokens' => 4096,
];
// Make API call (use your service's endpoint and format)
$response = $this->makeApiCall($api_url . '/v1/messages', $api_token, $payload);
return [
'content' => $response['content'][0]['text'] ?? '',
'model' => $model
];
}
// Optional: Implement streaming if supported
public function sendMessageStreaming(string $message, array $context = []): void
{
// Implement Server-Sent Events (SSE) streaming
// Similar to sendMessage but with chunk-by-chunk output
}
// Helper method for API calls
private function makeApiCall(string $url, string $token, array $payload): array
{
$ch = curl_init($url);
curl_setopt($ch, CURLOPT_RETURNTRANSFER, true);
curl_setopt($ch, CURLOPT_POST, true);
curl_setopt($ch, CURLOPT_POSTFIELDS, json_encode($payload));
curl_setopt($ch, CURLOPT_HTTPHEADER, [
'Content-Type: application/json',
'x-api-key: ' . $token, // Adjust header based on your API
'example-version: 2026-01-01' // API version
]);
$response = curl_exec($ch);
$httpCode = curl_getinfo($ch, CURLINFO_HTTP_CODE);
curl_close($ch);
if ($httpCode !== 200) {
throw new \Exception("API error: HTTP $httpCode");
}
return json_decode($response, true);
}
}Add your service to the registry in classes/ai/class.AIChatPageComponentLLMRegistry.php:
public static function getAvailableServices(): array
{
return [
'ramses' => AIChatPageComponentRAMSES::class,
'openai' => AIChatPageComponentOpenAI::class,
'example' => AIChatPageComponentExample::class, // <-- Add this line!
];
}Regenerate the Composer autoloader from your ILIAS root:
composer dump-autoloadIf you need service-specific language strings, add them to lang/ilias_en.lang and lang/ilias_de.lang:
example_service#:#Example AI Service
Your new AI service is now:
- ✅ Available in Administration > Configuration > Example AI Tab
- ✅ Selectable in AI Service dropdowns (General Config & Chat Settings)
- ✅ Automatically routed in
api.phpfor message handling - ✅ Fully integrated into the plugin ecosystem
- Navigate to plugin configuration
- Enable your new service in its configuration tab
- Set it as the default AI service
- Create a new chat component and send a message
- Monitor logs for debugging:
/var/www/logs/ilias.log
- Error Handling: Always catch and log API errors gracefully
- Logging: Use
$this->logger->info()for debugging - Validation: Validate all inputs and API responses
- Configuration: Follow the same patterns as existing services (RAMSES/OpenAI)
- Capabilities: Accurately report what your service supports
- API Compatibility: Use OpenAI-compatible formats when possible for easier integration
This plugin implements comprehensive security measures:
- Input Validation: All user inputs are validated and sanitized
- File Upload Security: MIME type validation and size limits
- SQL Injection Prevention: Prepared statements throughout
- XSS Protection: Proper output encoding
- Access Control: Integration with ILIAS permission system
- Secure Logging: Sensitive data excluded from logs
- Ensure AIChat plugin is installed and activated
- Check ILIAS permissions for PageComponent access
- Verify PHP version compatibility (8.1+)
- Ensure database tables were created via dbupdate.php
# Check PHP upload settings
php -i | grep -E "(upload_max_filesize|post_max_size|max_file_uploads)"
# Verify directory permissions
ls -la /var/www/html/ilias/data/- Check OSKI.nrw endpoint connectivity
- Verify API token in plugin configuration
- Review ILIAS logs:
/var/www/logs/ilias.log - Check plugin debug logs for detailed error information
- Ensure selected model exists in OSKI.nrw API response
- Plugin automatically detects ILIAS session expiration
- Users receive user-friendly session expired messages
- No data loss - messages are preserved until proper logout
- ILIAS Component Log: Component-specific logging (
comp.pcaic) - Application Log: ILIAS data directory logs
- Debug Log: Plugin directory
debug.log(development)
This project is licensed under the GPL-3.0 License - see the LICENSE file for details.
- Development: University of Cologne, CompetenceCenter E-Learning
- AI Service: OSKI.nrw by Ruhr-University Bochum and University of Cologne
For support and questions:
- Create an issue in this repository
- Contact: [nadimo.staszak@uni-koeln.de]
This plugin works out-of-the-box with:
- RAMSES (OSKI.nrw): Pre-configured RAMSES Service API
- OpenAI GPT: Pre-configured for OpenAI Service API
- OpenAI-Compatible Services: Any service with OpenAI-compatible endpoints
- Navigate to plugin configuration
- Select your AI service tab (RAMSES or OpenAI)
- Enter your API endpoint and token
- Test connection by refreshing models
- Set as default service in General Configuration
To add your organization's AI service:
- Check API Compatibility: Ensure your service provides OpenAI-compatible endpoints (
/v1/chat/completions,/v1/models) - Create Service Class: Follow the detailed guide in the Development section above
- Register Service: Add to
LLMRegistry::getAvailableServices() - Configure: Set API URL, token, and model selection
- Test: Verify message sending and file handling work correctly
Your AI service should provide:
- Chat Completions Endpoint:
POST /v1/chat/completions- Accept messages array in OpenAI format
- Support system/user/assistant roles
- Return JSON with
choices[0].message.content
- Models Endpoint:
GET /v1/models(optional, for auto-discovery)- Return array of available models
- Format:
{data: [{id: 'model-id', name: 'Model Name'}]}
- Authentication: Bearer token via
Authorizationheader - Multimodal Support: (optional) Accept
image_urlcontent types for file analysis
- Ghostscript: Required for PDF processing (
gs --version) - ImageMagick: Recommended for image optimization (
identify -version) - PHP Extensions: Ensure
curl,gd, andimagickare enabled
For integration assistance:
- Review existing service implementations (RAMSES, OpenAI) as templates
- Check comprehensive code documentation in abstract base class
- Create issues for bugs or feature requests
- Contact: nadimo.staszak@uni-koeln.de



