Jump to content

Ticket Office Hours Auto-reply Hook


Hostaka

Recommended Posts

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

Link to comment
Share on other sites

  • 3 weeks later...
  • 4 weeks later...

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

Link to comment
Share on other sites

  • 1 year later...

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