sol2010 Posted July 28, 2022 Share Posted July 28, 2022 How can I achieve this: Client opens ticket in department e.g. support - and the system sends them the support email. Admin changes the support department to e.g. billing - that triggers the sending of the billing automated reply instead.... 0 Quote Link to comment Share on other sites More sharing options...
pRieStaKos Posted July 30, 2022 Share Posted July 30, 2022 Use TicketDepartmentChange hook to check what you want and trigger SendEmail API function to send the email you want. 0 Quote Link to comment Share on other sites More sharing options...
leemahoney3 Posted July 31, 2022 Share Posted July 31, 2022 Just to add to the above, something like the code below would work. You'd need to set up a custom email template first and then update the variables below in the code. (The department variable is the name of the new department that the ticket has changed to). $department = ''; (e.g. 'Billing') $emailTemplate = ''; (e.g. 'Custom Billing Email') You can improve on the code below, its just a starting point. <?php use WHMCS\Database\Capsule; function change_ticket_department($vars) { # Specify the name of the department (the one you want the custom email to send on when changed to) as well as the name of the email template you want to send $department = 'Billing'; $emailTemplate = 'Billing Automated Reply'; # Define some variables $ticketid = $vars['ticketid']; $deptname = $vars['deptname']; # Get the clients Id $clientId = Capsule::table('tbltickets')->where('id', $ticketid)->first()->userid; # Only send if the new department matches if($deptname == $department) { # Use the local API to send the email $command = 'SendEmail'; $postData = [ 'messagename' => $emailTemplate, 'id' => $clientId ]; $result = localAPI($command, $postData); } } # Run the hook add_hook('TicketDepartmentChange', 1, 'change_ticket_department'); ?> 0 Quote Link to comment Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.