Template Rendering
Dieser Inhalt ist noch nicht in deiner Sprache verfügbar.
Template Rendering
Section titled “Template Rendering”Open Ticket AI uses Jinja2 for dynamic template rendering in configuration files and text generation.
Jinja2 Template System
Section titled “Jinja2 Template System”Jinja2 provides:
- Variable substitution
- Conditional logic
- Loops and filters
- Custom extensions
Template Expressions in Configuration
Section titled “Template Expressions in Configuration”Use templates in YAML configuration:
pipes: - pipe_name: add_note note_text: 'Classified as {{ context.queue }} with priority {{ context.priority }}'Custom Template Extensions
Section titled “Custom Template Extensions”Open Ticket AI provides custom Jinja2 extensions:
Context Access
Section titled “Context Access”Access pipeline context directly in templates:
{{ context.ticket.id }}{{ context.classification_result.confidence }}Filters
Section titled “Filters”Custom filters for common operations:
{{ ticket.created_at | format_date }}{{ text | truncate(100) }}{{ value | default("N/A") }}Functions
Section titled “Functions”Helper functions available in templates:
{{ now() }}{{ random_id() }}{{ format_priority(value) }}Template Context and Variables
Section titled “Template Context and Variables”The template context includes:
- Pipeline execution context
- Environment variables
- Configuration values
- Custom variables
Examples
Section titled “Examples”Conditional Note
Section titled “Conditional Note”note_text: > {% if context.priority == 'high' %} URGENT: This ticket requires immediate attention. {% else %} Standard priority ticket. {% endif %}Dynamic Queue Assignment
Section titled “Dynamic Queue Assignment”queue: > {% if 'billing' in context.ticket.subject.lower() %} Billing {% elif 'technical' in context.ticket.subject.lower() %} Technical Support {% else %} General {% endif %}Loop Through Results
Section titled “Loop Through Results”summary: > Processed {{ context.tickets | length }} tickets: {% for ticket in context.tickets %} - Ticket #{{ ticket.id }}: {{ ticket.status }} {% endfor %}Security Considerations
Section titled “Security Considerations”- Templates run in a sandboxed environment
- Dangerous operations are disabled
- User input is automatically escaped
- Use
safefilter only for trusted content