Hostaka Posted March 31, 2012 Share Posted March 31, 2012 Hey guys! Been working for the past half hour or so on an auto-response hook for tickets. Basically this hook checks an array of your business hours and days, and compares them to the current time. If a customer has opened a ticket or replied to a ticket (optional) outside of your business hours, it will auto respond to them with a message of your choice. No fancy UI, but I don't need one. Here's the code... <?php $salesmessage = <<<EOT Hello, Thank you for your interest in Hostaka. Unfortunately our sales hours are Monday-Friday, 9AM-5PM EST/EDT. We may get to your ticket before then, but if not, you will get a reply as soon as we're back in the office. If this is a support related matter, please open your ticket in the support department, or use support@hostaka.com. Thank you, Hostaka Staff EOT; $billingmessage = <<<EOT Hello, Our billing hours are Monday-Friday, 9AM-5PM EST/EDT. We may get to your ticket before then, but if not, you will get a reply as soon as we're back in the office. If this is a support related matter, please open your ticket in the support department, or use support@hostaka.com. Thank you, Hostaka Staff EOT; $config = array( 'Sales' => array( // The key needs to be the name of the department, caps matter 'opendays' => array(1, 2, 3, 4, 5), // 1 is Monday, 7 is Sunday 'openhour' => 9, // What hour do you open (24 hour format) 'closehour' => 17, // What hour do you close (24 hour format) 'message' => $salesmessage, // I am lazy and wanted it to look pretty so I made another var with the message 'username' => 'Sales Department', // Not sure if this does much really 'adminusername' => '', // This needs to be the username of an admin user 'status' => 'Open' // Status of the ticket once it's responded to ), 'Billing' => array( // The key needs to be the name of the department, caps matter 'opendays' => array(1, 2, 3, 4, 5), // 1 is Monday, 7 is Sunday 'openhour' => 9, // What hour do you open (24 hour format) 'closehour' => 17, // What hour do you close (24 hour format) 'message' => $billingmessage, // I am lazy and wanted it to look pretty so I made another var with the message 'username' => 'Billing Department', // Not sure if this does much really 'adminusername' => '', // This needs to be the username of an admin user 'status' => 'Open' // Status of the ticket once it's responded to ), ); function department_hours($vars) { global $config; $hour = date('G'); if(array_key_exists($vars['deptname'], $config)) { $v = $config[$vars['deptname']]; if(!in_array(date('N'), $v['opendays']) || $hour < $v['openhour'] || $hour >= $v['closehour']) { $command = 'addticketreply'; $values = array('ticketid' => $vars['ticketid'], 'message' => $v['message'], 'adminusername' => $v['username'], 'status' => $v['status']); $results = localAPI($command, $values, $v['adminusername']); if ($results['result']!="success") logActivity("An Error Occurred: ".$results['result']); } } } add_hook("TicketOpen",1,"department_hours"); add_hook("TicketUserReply",1,"department_hours"); // Comment this line if you only want responses on new tickets 0 Quote Link to comment Share on other sites More sharing options...
Bubka3 Posted April 20, 2012 Share Posted April 20, 2012 How do you use this? 0 Quote Link to comment Share on other sites More sharing options...
GoofyFrog Posted April 20, 2012 Share Posted April 20, 2012 Awesome. thank you for this. 0 Quote Link to comment Share on other sites More sharing options...
Jbro Posted April 28, 2012 Share Posted April 28, 2012 How do you use this? 0 Quote Link to comment Share on other sites More sharing options...
leemason Posted May 23, 2012 Share Posted May 23, 2012 just to let everyone know, i think this is a great idea hostaka. so good infact ive wrapped it up into a little module which makes it easier to do for the less technically minded people. ive also added to it with the ability to provide a warning on the ticket open page (all customisable of course) when out of hours. check it out here: http://forum.whmcs.com/showthread.php?p=224123#post224123 0 Quote Link to comment Share on other sites More sharing options...
deohosting Posted August 29, 2013 Share Posted August 29, 2013 How do you use this? Same quetion... 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.