Jump to content
sol2010

Send New Auto Responder When Support Department Changes

Recommended Posts

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....

 

 

Share this post


Link to post
Share on other sites

Use TicketDepartmentChange hook to check what you want and trigger SendEmail API function to send the email you want.

Share this post


Link to post
Share on other sites

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');

?>

 

Share this post


Link to post
Share on other sites

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Paste as plain text instead

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.


  • Recently Browsing   0 members

    No registered users viewing this page.

×
×
  • Create New...

Important Information

By using this site, you agree to our Terms of Use & Guidelines and understand your posts will initially be pre-moderated