Template
Learn how to use templates in Echobell
Templates in Echobell
Templates in Echobell allow you to create dynamic notifications by incorporating variables into your notification titles and bodies. This feature enables personalized and informative alerts that adapt based on the trigger data.
Basic Template Syntax
In Echobell templates, you can use variables by wrapping them in double curly braces:
When a channel is triggered, these variables are replaced with actual values passed through the trigger. For example, if your title template is You have received ${{amount}}
and you trigger the channel with an amount
value of 100, the resulting notification will display as You have received $100
.
Advanced Template Expressions
Echobell templates support a variety of expressions for more complex scenarios:
- Accessing Object Properties
- Accessing Array Elements
- Using Comparison Operators
- Logical Operators
All standard operators are supported: ==
, !=
, <
, >
, <=
, >=
, &&
, ||
, and !
.
Template Variables from Different Triggers
Webhook Triggers
When triggering via webhook, you can provide variables through:
-
Query string parameters:
-
JSON body (for POST requests):
-
Special variables:
externalLink
: Provides a clickable link in notification recordsbodyAsText
: The plain text content of the request body ifContent-Type
istext/plain
header
: Gives access to HTTP request headers (e.g.,{{header["content-type"]}}
)
Email Triggers
When a channel is triggered via email, the following variables are automatically available:
from
: The sender's email addressto
: The recipient's email addresssubject
: The email subject linetext
: The plain text content of the emailhtml
: The HTML content of the email
Template Use Cases
Conditional Content
You can use templates to show different content based on conditions:
Channel Conditions
In addition to using templates in notification content, you can set Conditions in channel advanced settings that determine whether notifications should be sent at all. These conditions use the same expression syntax (without the curly braces).
For example, to only send notifications for amounts greater than a threshold:
Link Templates
Configure a custom link template in channel advanced settings to create clickable links in notification records:
If no link template is set, the value of the externalLink
variable will be used by default.
Best Practices
-
Default Values: Consider providing default values for optional variables:
-
Informative Templates: Include key information in your templates to make notifications actionable:
-
Keep Templates Concise: Notifications display best when titles and bodies are clear and to the point.
-
Testing: Test your templates with different variable combinations to ensure they render as expected.
Templates are a powerful way to create dynamic, informative notifications that give users exactly the information they need, when they need it.