Zum Inhalt springen

Template Rendering

Dieser Inhalt ist noch nicht in deiner Sprache verfügbar.

Open Ticket AI uses Jinja2 for dynamic template rendering in configuration files and text generation.

Jinja2 provides:

  • Variable substitution
  • Conditional logic
  • Loops and filters
  • Custom extensions

Use templates in YAML configuration:

pipes:
- pipe_name: add_note
note_text: 'Classified as {{ context.queue }} with priority {{ context.priority }}'

Open Ticket AI provides custom Jinja2 extensions:

Access pipeline context directly in templates:

{{ context.ticket.id }}
{{ context.classification_result.confidence }}

Custom filters for common operations:

{{ ticket.created_at | format_date }}
{{ text | truncate(100) }}
{{ value | default("N/A") }}

Helper functions available in templates:

{{ now() }}
{{ random_id() }}
{{ format_priority(value) }}

The template context includes:

  • Pipeline execution context
  • Environment variables
  • Configuration values
  • Custom variables
note_text: >
{% if context.priority == 'high' %}
URGENT: This ticket requires immediate attention.
{% else %}
Standard priority ticket.
{% endif %}
queue: >
{% if 'billing' in context.ticket.subject.lower() %}
Billing
{% elif 'technical' in context.ticket.subject.lower() %}
Technical Support
{% else %}
General
{% endif %}
summary: >
Processed {{ context.tickets | length }} tickets:
{% for ticket in context.tickets %}
- Ticket #{{ ticket.id }}: {{ ticket.status }}
{% endfor %}
  • Templates run in a sandboxed environment
  • Dangerous operations are disabled
  • User input is automatically escaped
  • Use safe filter only for trusted content