Outgoing emails can include expressions like {{ .Recipient.FullName }}, which pull fields from the conversation, contact, inbox, recipient, and author. libredesk replaces them with real values when it sends the email.
Outgoing email templates
Edit outgoing templates under Admin → Templates → Outgoing email templates. You can create several, but only the one marked Is default is used. It wraps every email sent in a conversation: agent replies, AI assistant replies, CSAT requests, and conversation continuity emails.
Notification emails to agents do not use it. See Email notification templates.
Available variables
Conversation variables
| Variable | Value |
|---|---|
{{ .Conversation.ReferenceNumber }} |
The unique reference number of the conversation |
{{ .Conversation.Subject }} |
The subject of the conversation |
{{ .Conversation.Priority }} |
The priority level of the conversation |
{{ .Conversation.UUID }} |
The unique identifier of the conversation |
Inbox variables
| Variable | Value |
|---|---|
{{ .Inbox.Name }} |
Name of the inbox the conversation belongs to |
{{ .Inbox.Channel }} |
Channel of that inbox: email, livechat, or whatsapp |
Contact variables
| Variable | Value |
|---|---|
{{ .Contact.FirstName }} |
First name of the contact/customer |
{{ .Contact.LastName }} |
Last name of the contact/customer |
{{ .Contact.FullName }} |
Full name of the contact/customer |
{{ .Contact.Email }} |
Email address of the contact/customer |
Recipient variables
| Variable | Value |
|---|---|
{{ .Recipient.FirstName }} |
First name of the recipient |
{{ .Recipient.LastName }} |
Last name of the recipient |
{{ .Recipient.FullName }} |
Full name of the recipient |
{{ .Recipient.Email }} |
Email address of the recipient |
The recipient is whoever receives the email. In replies to conversations, Recipient and Contact are the same person. They differ only in email notification templates, where the recipient is an agent.
Author variables
| Variable | Value |
|---|---|
{{ .Author.FirstName }} |
First name of the message author |
{{ .Author.LastName }} |
Last name of the message author |
{{ .Author.FullName }} |
Full name of the message author |
{{ .Author.Email }} |
Email address of the message author |
The author is the sender of the message. When libredesk itself sends the email (automations, conversation continuity), the sender is the built-in System user, so these fields stay empty. Emails would otherwise show "System" as the author's name.
Message variables
| Variable | Value |
|---|---|
{{ .IsAIComposed }} |
true when the reply was written by an AI assistant rather than a person |
{{ .IsContinuityEmail }} |
true when the email is a conversation continuity email, i.e. unread live chat messages emailed to a contact who left the chat |
Use them to disclose AI replies, or to skip parts of the template that don't fit an automated email:
{{ if .IsContinuityEmail }}
<p>You have new messages:</p>
{{ else }}
<p>Dear {{ .Recipient.FirstName }},</p>
{{ end }}
{{ if .IsAIComposed }}
<p>This reply was composed by an AI assistant.</p>
{{ end }}
Previous messages
{{ .PreviousMessages }} lists up to 10 earlier messages exchanged with the contact in this conversation, newest first. Use it to quote the conversation history below a reply. Private notes and failed messages are left out.
Each item has these fields:
| Field | Value |
|---|---|
.SenderName |
Full name of the sender |
.SenderEmail |
Email address of the sender |
.CreatedAt |
Time the message was created. Format it with a Go layout, e.g. {{ .CreatedAt.Format "Jan 2, 2006 15:04" }} |
.IsIncoming |
true when the contact sent the message |
.Content |
Plain text of the message, with line breaks as <br> |
{{ template "content" . }}
{{ range .PreviousMessages }}
<p>On {{ .CreatedAt.Format "Jan 2, 2006 15:04" }}, {{ .SenderName }} <{{ .SenderEmail }}> wrote:</p>
<blockquote>{{ .Content }}</blockquote>
{{ end }}
To quote only the contact's last message, and only in some inboxes, check the item's position, .IsIncoming and .Inbox.Name. eq returns true when the first value matches any of the others, so list as many inbox names as you need:
{{ template "content" . }}
{{ if eq .Inbox.Name "Support" "Billing" }}
{{ range $i, $m := .PreviousMessages }}
{{ if and (eq $i 0) $m.IsIncoming }}
<p>On {{ $m.CreatedAt.Format "2 Jan 2006, 15:04 MST" }}, {{ $m.SenderName }} <{{ $m.SenderEmail }}> wrote:</p>
<blockquote>{{ $m.Content }}</blockquote>
{{ end }}
{{ end }}
{{ end }}
Warning:
Quoted messages include all text of each incoming email except its own quoted history. Text that your systems add to an incoming email for agents, such as account details from a contact form, is sent back to the contact. Store that information in custom attributes instead.
Template functions
These work in any template, alongside the variables above.
| Function | Value |
|---|---|
{{ RootURL }} |
Root URL of the libredesk instance, set under Admin → General |
{{ SiteName }} |
Site name, set under Admin → General |
{{ LogoURL }} |
URL of the uploaded logo |
{{ FaviconURL }} |
URL of the uploaded favicon |
{{ Date "2006-01-02" }} |
Current date and time, formatted with a Go layout. {{ Date "" }} uses the ANSIC layout |
Using variables in replies and private notes
The same expressions work when an agent types them in the reply editor or a private note, and in macros. libredesk replaces them when the message is saved, so the agent sees the final text right away.
Example outgoing email template
Note:
Templates support HTML formatting. Use tags like
<p>and<br />to control spacing and line breaks. Plain text without HTML tags renders without line breaks.
<p>Dear {{ .Recipient.FirstName }},</p>
{{ template "content" . }}
<p>Best regards,<br />
{{ .Author.FullName }}</p>
---
<p>Reference: {{ .Conversation.ReferenceNumber }}</p>
{{ if .IsAIComposed }}
<p>This reply was composed by an AI assistant.</p>
{{ end }}
Full HTML example
This template adds a logo header, the conversation history below the reply, and a footer. Replace the footer text with your own.
Full HTML template
<!doctype html>
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8">
<meta name="viewport" content="width=device-width, initial-scale=1, minimum-scale=1">
<base target="_blank">
<style>
body {
background-color: #F0F1F3;
font-family: 'Helvetica Neue', 'Segoe UI', Helvetica, sans-serif;
font-size: 15px;
line-height: 26px;
margin: 0;
color: #444;
}
pre {
background: #f4f4f4;
padding: 2px;
}
table {
width: 100%;
border: 1px solid #ddd;
}
table td {
border-color: #ddd;
padding: 5px;
}
.wrap {
background-color: #fff;
padding: 30px;
max-width: 525px;
margin: 0 auto;
border-radius: 5px;
}
.footer {
text-align: center;
font-size: 12px;
color: #888;
}
.footer a {
color: #888;
margin-right: 5px;
}
img {
max-width: 100%;
height: auto;
}
.header .logo img {
width: auto;
max-width: 150px;
}
a {
color: #0055d4;
}
a:hover {
color: #111;
}
</style>
</head>
<body style="background-color: #F0F1F3;font-family: 'Helvetica Neue', 'Segoe UI', Helvetica, sans-serif;font-size: 15px;line-height: 26px;margin: 0;color: #444;">
<br>
<div class="wrap" style="background-color: #fff;padding: 30px;max-width: 525px;margin: 0 auto;border-radius: 5px;">
<header class="header">
<div class="logo">
<img src="{{ LogoURL }}" alt="{{ SiteName }}" style="max-width: 300px;" />
</div>
</header>
<br>
Dear {{ .Recipient.FirstName }},
<br>
{{ template "content" . }}
{{ if .PreviousMessages }}
<div style="margin-top: 28px; padding-top: 20px; border-top: 1px solid #ddd;">
<div style="margin-bottom: 16px; font-size: 13px; color: #888;">
Previous messages
</div>
{{ range .PreviousMessages }}
<blockquote style="margin: 0 0 20px; padding: 0 0 0 14px; border-left: 2px solid #ddd;">
<div style="margin-bottom: 6px; font-size: 12px; line-height: 20px; color: #888;">
On {{ .CreatedAt.Format "02 Jan 2006 at 15:04 MST" }},
{{ if .SenderName }}{{ .SenderName }}{{ else }}{{ .SenderEmail }}{{ end }}
wrote:
</div>
<div style="font-size: 14px; line-height: 24px; color: #444; overflow-wrap: anywhere;">
{{ .Content }}
</div>
</blockquote>
{{ end }}
</div>
{{ end }}
{{ if .Author.FirstName }}
<br>
Best regards,<br>
{{ .Author.FirstName }}
<br>
{{ end }}
</div>
<div class="footer" style="text-align: center;font-size: 12px;color: #888;">
Your company address
</div>
</body>
</html>
How the template wraps a message
The template wraps every message an agent sends. Whatever the agent types in the editor goes where {{ template "content" . }} sits.
So if the template already opens with "Dear {{ .Recipient.FirstName }}" and closes with "Best regards, {{ .Author.FullName }}", agents should write neither a greeting nor a sign-off. They write only the body.
Correct usage
Message written in text editor:
Thank you for contacting us. I've reviewed your account and can confirm that your refund has been processed.
Email received by customer:
Dear John,
Thank you for contacting us. I've reviewed your account and can confirm that your refund has been processed.
Best regards,
Sarah Smith
---
Reference: TKT-2024-001
Duplicated greeting and sign-off
Message written in text editor:
Hello John,
Thank you for contacting us. I've reviewed your account and can confirm that your refund has been processed.
Best regards,
Sarah
Email received by customer (with unwanted duplication):
Dear John,
Hello John,
Thank you for contacting us. I've reviewed your account and can confirm that your refund has been processed.
Best regards,
Sarah
Best regards,
Sarah Smith
---
Reference: TKT-2024-001
Other template shapes
A template with no greeting means agents write their own. A template that is only the content placeholder means agents write the whole email, greeting and sign-off included. Read the active template before deciding what to write.
Email notification templates
Edit these under Admin → Templates → Email notification templates. The subject line takes the same expressions as the body.
These emails use a built-in layout. The CSAT request is the exception and uses the default outgoing email template.
Every template gets the Conversation, Contact, Inbox, and Recipient variables. All except the CSAT request go to agents, so {{ .Recipient.* }} is the agent being notified.
| Template | When it is sent | Extra variables |
|---|---|---|
| Conversation assigned | A conversation is assigned to the agent | None |
| New reply from contact | The contact replies on a conversation assigned to the agent | {{ .Author.* }} (the contact), {{ .Message.Content }}, {{ .Message.UUID }} |
| Conversation reopened | The contact's reply reopens a conversation assigned to the agent | Same as New reply from contact |
| New reply on participating conversation | The contact replies on a conversation the agent participates in | Same as New reply from contact |
| Mentioned in conversation | The agent, or a team the agent belongs to, is mentioned in a private note | {{ .MentionedBy.FirstName }}, {{ .MentionedBy.LastName }}, {{ .MentionedBy.FullName }}, {{ .MentionedBy.Email }}, {{ .Message.Content }} (the private note), {{ .Message.UUID }} |
| SLA breach warning, SLA breached | An SLA deadline is close or has passed | {{ .SLA.Metric }} (First response, Resolution, or Next response), {{ .SLA.DueIn }} (time left, for the warning email), {{ .SLA.OverdueBy }} (time past the deadline, for the breach email) |
| CSAT request | A conversation is resolved with CSAT surveys on, or an automation sends one | Everything an outgoing email gets (Conversation, Contact, Inbox, Recipient, Author, {{ .IsAIComposed }}), plus {{ .CSATLink }} (rating page URL, append ?rating=1 to ?rating=5 for one-click rating) and {{ .CSATUUID }} |
Note:
In the CSAT request,
{{ .Author.* }}holds the person who resolved the conversation, and is empty when an automation resolved it.
