Skip to main content

Configure an Escalation Rule That Sends Email Notifications

Escalation rules in Deepser can trigger email notifications to alert Operators when specific conditions are met. This guide walks through creating an email template, an email event, and linking them to an escalation rule. It covers two practical examples and is intended for administrators managing escalation workflows.

Example 1: Notify the Assigned Operator by Company

In this example, you create a rule that notifies the assigned user whenever the requesting company is "Acme International".

Create the Email Template

  1. Navigate to System -> Tools -> Email -> Template and click Add Mail Template.

  2. Enter a name in the Name field and a code in the Code field.

  3. In the Subject section, insert PHP code for the email subject. Use the following as a reference:

    <?php echo Deep::helper('deep_email')->__('DEEPSER – New ticket from Acme International'); ?>
  4. In the Body section, insert the PHP/HTML code that generates the email body. Use the following as a reference:

    <?php
    $requesterUser = $this->getModel()->getRequesterUser();
    $assignedUser = $this->getModel()->getAssignedUser();
    ?>
    <?php $this->includeTemplate("header") ?>
    <!-- Start of Main Content -->
    <tr style="">
    <td bgcolor="#FFFFFF" align="center" style="">
    <table width="100%" align="center" cellpadding="0" cellspacing="0" border="0" class="devicewidth" style="">
    <tbody style="">
    <!-- Start Spacer -->
    <tr>
    <td class="w22" width="41" style="font-size:1px; line-height:1px;">&nbsp;</td>
    <td class="h26" height="36" style="font-size:1px; line-height:1px;">&nbsp;</td>
    <td class="w22" width="41" style="font-size:1px; line-height:1px;">&nbsp;</td>
    </tr>
    <!-- End Spacer -->
    <tr style="">
    <td class="w22" width="41" style="font-size:1px; line-height:1px;">&nbsp;</td>
    <td class="mktEditable content mktEditable content" id="edit_text_1" valign="middle" style="font-family:Calibri, Helvetica, sans-serif; font-size:16px; color:#505050; text-align:left; line-height:25.6px; font-weight:normal; text-transform:none;">
    <p>
    <br>
    <?php echo Deep::helper('deep_email')->__('Dear %s', $this->getModel()->getAssignedUser()->getDisplayUsername())?>,<br>
    <?php $url = $this->getModel()->getAssignedUser()->isUser() ? $this->getModel()->getPortalUrl() : $this->getModel()->getUrl(); ?>
    <?php echo Deep::helper('deep_email')->__('You have received a new ticket from Acme International')?> <b style="font-weight: 700;"><a href="<?php echo $url ?>"><?php echo $this->getModel()->getId()?></a></b>
    <br>
    <br>
    <strong><?php echo Deep::helper('deep_email')->__('Title')?></strong>:
    <br><?php echo $this->getModel()->getTitle()?><br><br>
    <strong><?php echo Deep::helper('deep_email')->__('Description')?></strong>:
    <br><?php echo $this->getModel()->getDescription()?><br>
    <!-- Status -->
    <?php if($this->getModel()->getStatus()):?>
    <strong><?php echo Deep::helper('deep_email')->__('Status')?></strong>:
    <?php
    $statusList = Deep::helper('deep_list')->loadList(Deep_Service_Model_Operation::LIST_CODE_STATUS);
    $statusValue = $statusList->getValue($this->getModel()->getStatus());
    ?>
    <br><?php echo Deep::helper('deep_email')->__($statusValue->getValueLabel()); ?><br><br>
    <?php endif;?>
    <!-- Requester -->
    <?php if($requesterUser && $requesterUser->getId()):?>
    <strong><?php echo Deep::helper('deep_service')->__('Requester User')?></strong>:
    <?php if($this->getModel()->getRequesterUser()->getAvatar()):?>
    <br><img src="<?php echo $this->getModel()->getRequesterUser()->getAvatarUrl() ?>" border="0" style="-ms-interpolation-mode: bicubic;" width="16" />
    <?php endif;?>
    &nbsp;&nbsp;&nbsp;<?php echo $this->getModel()->getRequesterUser()->getDisplayUsername() ?><br><br>
    <?php endif;?>
    <!-- Assigned -->
    <?php if($assignedUser && $assignedUser->getId()):?>
    <strong><?php echo Deep::helper('deep_service')->__('Assigned User')?></strong>:
    <?php if($this->getModel()->getAssignedUser()->getAvatar()):?>
    <br><img src="<?php echo $this->getModel()->getAssignedUser()->getAvatarUrl() ?>" border="0" style="-ms-interpolation-mode: bicubic;" width="16" />
    <?php endif;?>
    &nbsp;&nbsp;&nbsp;<?php echo $this->getModel()->getAssignedUser()->getDisplayUsername() ?><br><br>
    <?php endif;?>
    <!-- Urgency -->
    <?php if($this->getModel()->getUrgencyId()):?>
    <strong><?php echo Deep::helper('deep_email')->__('Urgency')?></strong>:
    <?php
    $urgencyList = Deep::helper('deep_list')->loadList(Deep_Service_Model_Operation::LIST_CODE_URGENCY);
    $urgencyValue = $urgencyList->getValue($this->getModel()->getUrgencyId());
    ?>
    <br><?php echo Deep::helper('deep_email')->__($urgencyValue->getValueLabel()); ?><br><br>
    <?php endif;?>
    <!-- Priority -->
    <?php if($this->getModel()->getPriorityId()):?>
    <strong><?php echo Deep::helper('deep_email')->__('Priority')?></strong>:
    <?php
    $priorityList = Deep::helper('deep_list')->loadList(Deep_Service_Model_Operation::LIST_CODE_PRIORITY);
    $priorityValue = $priorityList->getValue($this->getModel()->getPriorityId());
    ?>
    <br><?php echo Deep::helper('deep_email')->__($priorityValue->getValueLabel()); ?><br><br>
    <?php endif;?>
    <!-- Solution -->
    <?php if($this->getModel()->getSolution()):?>
    <strong><?php echo Deep::helper('deep_email')->__('Solution')?></strong>:
    <br><?php echo $this->getModel()->getSolution()?>
    <br>
    <?php endif;?>
    </p>
    </td>
    <td class="w22" width="41" style="font-size:1px; line-height:1px;">&nbsp;</td>
    </tr>
    <!-- Start Spacer -->
    <tr>
    <td class="w22" width="41" style="font-size:1px; line-height:1px;">&nbsp;</td>
    <td height="30" style="font-size:1px; line-height:1px;">&nbsp;</td>
    <td class="w22" width="41" style="font-size:1px; line-height:1px;">&nbsp;</td>
    </tr>
    <!-- End Spacer -->
    </tbody>
    </table>
    </td>
    </tr>
    <!-- End of Main Content -->
    <!-- End of Main Content -->
    <?php $url = $this->getModel()->getUrlByUser($assignedUser); ?>
    <!-- start of Button -->
    <tr style="">
    <td bgcolor="#FFFFFF" align="center" class="mktEditable" id="edit_cta_button" style="">
    <table width="100%" border="0" cellspacing="0" cellpadding="0">
    <tbody>
    <tr>
    <td class="w22" width="41" style="font-size: 1px; line-height: 1px;">&nbsp;</td>
    <td align="left">
    <table class="button" cellpadding="0" cellspacing="0" border="0" align="left" bgcolor="#0080ff" style="-webkit-border-radius: 4px; -moz-border-radius: 4px; border-radius: 4px;">
    <tbody>
    <tr>
    <td width="518" align="center" valign="middle" height="65">
    <span style="color: #ffffff; text-decoration: none;">
    <a class="mobButton mktNoTok" href="<?php echo $url ?>" style="font-family: Calibri, Helvetica, sans-serif; font-size: 16px; color: #ffffff; display: block; height: 65px; mso-line-height-rule: exactly; line-height: 65px; font-weight: normal; text-decoration: none; text-align: center!important;" target="_blank" title="Link al ticket">
    <?php echo Deep::helper('deep_email')->__('Go to the Ticket')?>
    </a>
    </span>
    </td>
    </tr>
    </tbody>
    </table> </td>
    <td class="w22" width="41" style="font-size: 1px; line-height: 1px;">&nbsp;</td>
    </tr>
    </tbody>
    </table>
    </td>
    </tr>
    <!-- end of Button -->
    <?php $this->includeTemplate("footer") ?>
  5. Click Save or Apply.

Create the Email Event

  1. Navigate to System -> Tools -> Email -> Event and click Add Event.

  2. Enter a name in the Name field and set Send Attachments to "No".

  3. In Email Template, select the template created above.

  4. In the Event Trigger section, set Model to "DeepService -- Operation".

  5. In Event Expression, insert:

    // if the Company is Acme International
    if($this->getModel()->getData("requester_company_id") == Deep::getModel("deep_company/company")->load("ACME International",'name')->getId() ){
    if ($this->getModel()->getData('escalation_rule')){
    return true;
    }
    }
    return false;
  6. In the To section, insert:

    $user = $this->getModel()->getAssignedUser();
    if ($user && $user->getId()){
    $this->changeLanguage($user->getLocale());
    $this->addTo($user->getEmail());
    }
  7. Click Save or Apply.

Assign the Email Event to the Escalation Rule

  1. Navigate to System -> Service Configuration and open the escalation rule.
  2. In the Email Event field, select the event you just created.
  3. Click Save or Apply.

Example 2: Notify When Contract Hours Are Running Low

In this example, you email the administrator when the remaining hours in a contract line drop below 4.

Create the Email Template

  1. Navigate to System -> Tools -> Email -> Template and click Add Mail Template.

  2. Enter a name and code for the template.

  3. In the Subject section, use:

    <?php $line = $this->getModel() ?>
    The contract line <?php echo $line->getLineNumber() . ' - ' . $line->getName() ?> of the contract <?php echo $line->loadContract()->getContractNumber() . ' - ' . $line->loadContract()->getName() ?> is going low
  4. In the Body section, use:

    <?php $this->includeTemplate("header") ?>
    <style>
    .table{
    width: 100%;
    margin-left:auto;
    margin-right: auto;
    }
    .tr,.td{
    width: 100%;text-align: center;
    vertical-align: middle;
    }
    .cust-container{
    display: flex;
    justify-content: center;
    margin-left: auto;
    margin-right: auto;
    }
    </style>
    <!-- Start of Main Content -->
    <tr style="">
    <td bgcolor="#FFFFFF" align="center" style="">
    <table width="100%" align="center" cellpadding="0" cellspacing="0" border="0" class="devicewidth" style="">
    <tbody style="">
    <!-- Start Spacer -->
    <tr>
    <td class="w22" width="41" style="font-size:1px; line-height:1px;">&nbsp;</td>
    <td class="h26" height="36" style="font-size:1px; line-height:1px;">&nbsp;</td>
    <td class="w22" width="41" style="font-size:1px; line-height:1px;">&nbsp;</td>
    </tr>
    <!-- End Spacer -->
    <tr>
    <td class="w22" width="41" style="font-size:1px; line-height:1px;">&nbsp;</td>
    <td class="mktEditable content mktEditable content" id="edit_text_1" valign="middle" style="font-family:Calibri, Helvetica, sans-serif; font-size:16px; color:#505050; text-align:left; line-height:25.6px; font-weight:normal; text-transform:none;">
    <p>
    <br>
    <div class="cust-container">
    <?php $residuo = sprintf("%02d:%02d", floor($line->getRemainingTime()/3600), floor(($line->getRemainingTime()/60) %60))?>
    The Contract Line &nbsp;<b><?php echo $line->getLineNumber() . ' - ' . $line->getName()?> </b> &nbsp;<?php echo " is going low ({$residuo} Hours remaning ) ";?>
    </div>
    <br>
    <br>
    <table class="table">
    <tr class="tr">
    <td>
    <strong><?php echo Deep::helper('deep_email')->__('Total Time')?></strong>:
    <br><?php echo sprintf("%02d:%02d", floor($line->getTotalTime()/3600), floor(($line->getTotalTime()/60) %60))?><br><br>
    </td>
    <td>
    <strong><?php echo Deep::helper('deep_email')->__('Remaining Time')?></strong>:
    <br><?php echo sprintf("%02d:%02d", floor($line->getRemainingTime()/3600), floor(($line->getRemainingTime()/60) %60))?><br><br>
    </td>
    </tr>
    <tr class="tr">
    <td>
    <strong><?php echo Deep::helper('deep_email')->__('Name')?></strong>:
    <br><?php echo $contract->getName()?><br><br>
    </td>
    <td>
    <strong><?php echo Deep::helper('deep_email')->__('Customer Company')?></strong>:
    <br><?php echo $company && $company->getId() ? $company->getName() : ''?><br><br>
    </td>
    </tr>
    </table>
    </p>
    </td>
    <td class="w22" width="41" style="font-size:1px; line-height:1px;">&nbsp;</td>
    </tr>
    <!-- Start Spacer -->
    <tr>
    <td class="w22" width="41" style="font-size:1px; line-height:1px;">&nbsp;</td>
    <td height="30" style="font-size:1px; line-height:1px;">&nbsp;</td>
    <td class="w22" width="41" style="font-size:1px; line-height:1px;">&nbsp;</td>
    </tr>
    <!-- End Spacer -->
    </tbody>
    </table>
    </td>
    </tr>
    <!-- End of Main Content -->
    <?php $this->includeTemplate("footer") ?>
  5. Click Save or Apply.

Create the Email Event

  1. Navigate to System -> Tools -> Email -> Event and click Add Event.

  2. Enter a name, set Send Attachments to "No", and select the template.

  3. Set Model to "DeepService -- Operation" in the Event Trigger section.

  4. In Event Expression, insert:

    if ($this->getModel()->getData('escalation_rule')){
    return true;
    }
    return false;
  5. In the To section, insert:

    $adminUserToNotify = 'admin';
    $admin = Deep::getModel('deep_admin/user')->loadByUsername($adminUserToNotify);
    if($admin && $admin->getId()){
    $adminEmail = $admin->getEmail();
    if($adminEmail){
    $this->changeLanguage($admin->getLocale());
    $this->addTo($adminEmail);
    }
    }
  6. Click Save or Apply.

Assign the Email Event to the Escalation Rule

  1. Navigate to System -> Service Configuration and open the escalation rule.
  2. Select the event in the Email Event field.
  3. Set Level to 0 and Next Level to 1 so the notification fires only once per Service Operation.
  4. Set the Cron Expression to every 5 minutes using the drop-down menu.
tip

Setting "Level" to 0 and "Next Level" to 1 ensures the notification is sent only once per Service Operation, preventing duplicate alerts.

  1. Click Save or Apply.