Templates Introduction
Templates are reusable content structures that use the Pebble Template Engine to generate dynamic emails and PDF documents. They support variable substitution, allowing you to create personalized content by inserting data values into predefined templates.
What are Templates?
Templates are stored content structures that contain:
- Name: Unique identifier for the template
- Content: The template body with variable placeholders
- Template Type: Either
EMAILorPDF - Metadata: Additional configuration (e.g., email subject for email templates)
- Directory: Organizational grouping for templates
Template Types
Email Templates
Email templates are used to send dynamic email notifications. They include:
- Content: HTML or plain text email body with variable placeholders
- Email Subject: Stored in metadata, also supports variable substitution
- Variable Substitution: Uses
{{variableName}}syntax
PDF Templates
PDF templates are used to generate PDF documents from HTML content. They include:
- Content: HTML template that will be converted to PDF
- Variable Substitution: Uses
{{variableName}}syntax for dynamic content
Template Syntax
Templates use the Pebble Template Engine syntax for variable substitution:
Basic Variables
<p>Dear {{customerName}},</p>
<p>Your order {{orderNumber}} has been confirmed.</p>
<p>Total Amount: {{totalAmount}}</p>Conditional Logic
{% if orderStatus == "shipped" %}
<p>Your order has been shipped!</p>
{% else %}
<p>Your order is being processed.</p>
{% endif %}Loops
<ul>
{% for item in orderItems %}
<li>{{item.name}} - {{item.price}}</li>
{% endfor %}
</ul>Using Templates in Workflows
Templates are used in several workflow functions:
Email Notification
Use templates to send dynamic emails:
{
"templateId": "email-template-uuid",
"dataObject": {
"customerName": "John Doe",
"orderNumber": "ORD-123",
"totalAmount": "$100.00"
}
}Related Function: EmailNotification
HTML to PDF
Generate PDF documents from templates:
{
"templateId": "pdf-template-uuid",
"dataObject": {
"invoiceNumber": "INV-001",
"customerName": "John Doe",
"items": [...]
},
"fileName": "invoice"
}Related Function: HTMLToPDF
User Action
Send email notifications as part of user actions:
{
"templateId": "approval-notification-uuid",
"dataObject": {
"requestType": "Purchase Order",
"amount": "$5,000"
}
}Related Function: UserAction
Key Features
Variable Extraction
The system automatically extracts all variables used in a template, allowing you to see what data fields are required when using the template.
Directory Organization
Templates can be organized into directories for better management and organization.
Template Preview
Preview templates with sample data before using them in production workflows.
Getting Started
- Create Templates: Learn how to create email or PDF templates
- Preview Templates: Test templates with sample data before use
- Use in Workflows: Reference templates by ID in workflow functions
Related Introduction
- EmailNotification - Send emails using templates
- HTMLToPDF - Generate PDFs from templates
- UserAction - Use templates in user actions
- Workflows - Learn about workflow creation and management