Workflow: How to add images to email notifications sent by business rules

<p>In this workflow, you'll learn to include images in business rule notifications by modifying the Email body with an HTML tag.</p><p>The workflow includes the steps below:</p><div style="margin-bottom: 20px; text-align: right;">
<button id="master-toggle" class="btn fw-semibold text-dark" data-action="expand" style="background-color: #DEF991; border: none; outline: none; border-radius: 7px; padding: 10px 20px; font-size: 15px; transition: background-color 0.2s ease;" onmouseover="this.style.backgroundColor='#cbef6d'" onmouseout="this.style.backgroundColor='#DEF991'">
Expand all tabs
</button>
</div>
<script>
document.addEventListener('DOMContentLoaded', function () {
const toggleBtn = document.getElementById('master-toggle');

toggleBtn.addEventListener('click', function () {
const action = this.getAttribute('data-action');
const headers = document.querySelectorAll('.accordion');

headers.forEach(header => {
const isActive = header.classList.contains('active');
const panel = header.nextElementSibling; // Grabs the corresponding .panel container

if (action === 'expand' && !isActive) {
// Open it by simulating a standard click
header.click();
} else if (action === 'collapse' && isActive) {
// Close it by simulating a standard click
header.click();
}
});

// Flip button text and states
if (action === 'expand') {
this.setAttribute('data-action', 'collapse');
this.textContent = 'Collapse all tabs';
} else {
this.setAttribute('data-action', 'expand');
this.textContent = 'Expand all tabs';
}
});
});
</script><div class="accordion"><h3 id="h_01HXY1BFCAPEN08R87P7ENG6TS">Step 1: Select the image</h3></div><div class="panel"><p>Find the image to include in the email body and get the direct URL for that image. For example, the image below has the direct URL <a href="https://dam.zendesk.com/m/4a25a18730907a7/webimage-Logo_Types_Primary-espresso" target="_blank" rel="noopener noreferrer"><code>https://dam.zendesk.com/m/4a25a18730907a7/webimage-Logo_Types_Primary-espresso</code></a><br><img class="wysiwyg-image-resized" style="aspect-ratio: 292/250; width: 11.06%;" src="https://support.zendesk.com/hc/article_attachments/10798482055194" alt="Zendesk logo" width="292" height="250"></p></div><div class="accordion"><h3 id="01HXY1G18XYBGPX37812NDQPP4">Step 2: Edit the trigger action</h3></div><div class="panel"><p>In the email body of the trigger's action, include <code>&lt;img src="image_url"&gt;</code> and replace the image's direct URL where it says <code>image_url</code>.<br><img class="wysiwyg-image-resized" style="aspect-ratio: 1517/873; width: 50%;" src="https://support.zendesk.com/hc/article_attachments/8953856160154" alt="Add images to email notifications.png" width="1517" height="873"></p></div><div class="accordion"><h3 id="h_01HXY1GYQDRZ3V1Y2A1VJXG88P">Step 3: Test the trigger</h3></div><div class="panel">
<p>Test your trigger to make sure everything looks correct. Add a trigger condition so the trigger only fires on your test ticket. For example, add the condition <strong>Ticket</strong> &gt; <strong>Tags</strong> |<strong> Contains at least one of the following </strong>| <code>testforhtml</code> and add the same tag to the test ticket.<br><img class="wysiwyg-image-resized" style="aspect-ratio: 406/265; width: 50%;" src="https://support.zendesk.com/hc/article_attachments/7873955910682" alt="View of image in email notificaiton.png" width="406" height="265"></p>
<p>You can also use HTML to resize the image. Use the code <code>&lt;img src="image_url" width="" height=""&gt;</code> and specify the width and height values in pixels.</p>
</div><div class="accordion"><h3 id="h_01KS2X19EE8HFF75RH1YBZ764X">Best practices</h3></div><div class="panel">
<p>Email clients use Content Security Policy (CSP) to restrict which external resources are allowed to load in emails. To ensure that the image loads properly, use a publicly accessible image, upload on well-known image hosting sites, and check that the link uses <code>HTTPS</code>.</p>
<p>Target an image that has a file size lower than 200KB in either PNG or JPEG format for a faster load time. If your image struggles to load, use an editing tool that can compress and convert your images to optimize them for emails.</p>
<p>You can send a test email to multiple clients such as Gmail, Outlook, and Apple Mail to see if the image appears correctly instead of a broken image icon.</p>
<div class="note">
<span class="notetitle"><strong>Disclaimer</strong>:</span> This article is provided for instructional purposes only. Zendesk does not support or guarantee the code. Post any issues you have in the comments section or try searching for a solution online.</div>
</div>