/build/static/layout/Breadcrumb_cap_w.png

Email Notification If Unassigned more than 15 min

I have been reading the message boards, and Kace Knowledge Base in search of a script. I am looking for a script that will email me if a NEW ticket is created and remains Unassigned for more than 15 minutes. Can anyone tell me if this is possible? I have been using Kbox for about 2 years now, but never had a need to create any custom rule. Any help would be appreciated.

0 Comments   [ + ] Show comments

Answers (22)

Posted by: grico 14 years ago
Senior Yellow Belt
1
Thank you much for the speedy response.
Posted by: RichB 14 years ago
Second Degree Brown Belt
1
57:33> mysql error: [1146: Table 'ORG1.HD_QUEUE_ID' doesn't exist]

is what I get.
Posted by: airwolf 14 years ago
Red Belt
1
If you have a mutli-organization KBOX, I believe you'll have to reference the tables differently in the rule by prefixing all of them with ORG1. "ORG1.HD_QUEUE_ID" isn't referenced anywhere in the code I posted.
Posted by: RichB 14 years ago
Second Degree Brown Belt
1
This was my select query:

SELECT T.ID AS TICKNUM, T.TITLE AS TITLE, U.EMAIL AS SUBMITTER_EMAIL, U.FULL_NAME AS SUBMITTER_FULLNAME, 'my.email@asd20.org' /* <<<<<<<<put your email here */
AS EMAIL FROM HD_TICKET T
JOIN HD_STATUS S ON (T.HD_STATUS_ID = S.ID)
JOIN USER U ON (T.SUBMITTER_ID = U.ID)
JOIN HD_QUEUE_ID Q ON T.HD_QUEUE_ID=Q.ID and Q.NAME ='ASD20 Help Desk' /* <<<<< set queue name here */
WHERE HOUR(NOW()) > 6 AND HOUR(NOW()) < 20 AND NOW() < DATE_ADD(T.CREATED, INTERVAL 15 MINUTE) AND T.OWNER_ID = 0 AND S.STATE != 'closed'

So how should be modified for a K1200 box? I understand the concept of prefixing tables with ORG1 but does that mean this:

SELECT T.ID AS TICKNUM, T.TITLE AS TITLE, U.EMAIL AS SUBMITTER_EMAIL, U.FULL_NAME AS SUBMITTER_FULLNAME, 'my.email@asd20.org' /* <<<<<<<<put your email here */
AS EMAIL FROM ORG1.HD_TICKET T
JOIN ORG1.HD_STATUS S ON (T.HD_STATUS_ID = S.ID)
JOIN ORG1.USER U ON (T.SUBMITTER_ID = U.ID)
JOIN ORG1.HD_QUEUE_ID Q ON ORG1.T.HD_QUEUE_ID=Q.ID and Q.NAME ='ASD20 Help Desk' /* <<<<< set queue name here */
WHERE HOUR(NOW()) > 6 AND HOUR(NOW()) < 20 AND NOW() < DATE_ADD(T.CREATED, INTERVAL 15 MINUTE) AND T.OWNER_ID = 0 AND S.STATE != 'closed'
Posted by: airwolf 14 years ago
Red Belt
1
I haven't dealt with a 1200 database, but your modifications seem correct from what I've read. It's just a select query, you can't break anything if you try it out. [;)] If it returns results in the MySQL Browser then it's good to go!
Posted by: RichB 14 years ago
Second Degree Brown Belt
1
I got it working by changing a table called in the third JOIN line as "HD_QUEUE_ID" to ""HD_QUEUE" so here is the final result:

SELECT T.ID AS TICKNUM, T.TITLE AS TITLE, U.EMAIL AS SUBMITTER_EMAIL, U.FULL_NAME AS SUBMITTER_FULLNAME, 'my.email@asd20.org'
AS EMAIL FROM HD_TICKET T
JOIN HD_STATUS S ON (T.HD_STATUS_ID = S.ID)
JOIN USER U ON (T.SUBMITTER_ID = U.ID)
JOIN HD_QUEUE Q ON T.HD_QUEUE_ID=Q.ID and Q.NAME ='ASD20 Help Desk'
WHERE HOUR(NOW()) > 6 AND HOUR(NOW()) < 20 AND NOW() < DATE_ADD(T.CREATED, INTERVAL 15 MINUTE) AND T.OWNER_ID = 0 AND S.STATE != 'closed'
Posted by: airwolf 14 years ago
Red Belt
1
Ah, sorry about that Rich. I just copied/pasted the code Gerald posted; I hadn't tested it. The reference to the table as HD_QUEUE_ID should've been HD_QUEUE, and I didn't notice it when I looked over the code.
Posted by: grico 14 years ago
Senior Yellow Belt
1
This is working for me as far as not sending me emails, but now it seems that it is ignoring the 15min interval. For example I can get notified that a ticket has been sitting for more than 15 min when it was only entered 3 min ago. It is no longer working as Andy stated it would work, but it was working before.

ORIGINAL: airwolf

No, it will only show tickets that were created more than 15 minutes ago. Since the rule runs every 15 minutes (the lowest you can set it), your results may not show a ticket until about 30 minutes. So, your window of results is 15-30 minutes and beyond.


Here is what I am using, remember I only have 1 queue.

SELECT T.ID AS TICKNUM, T.TITLE AS TITLE, U.EMAIL AS SUBMITTER_EMAIL, U.FULL_NAME AS SUBMITTER_FULLNAME, '_helpdesk@uslegalsupport.com' AS EMAIL FROM HD_TICKET T
JOIN HD_STATUS S ON (T.HD_STATUS_ID = S.ID)
JOIN USER U ON (T.SUBMITTER_ID = U.ID)
WHERE HOUR(NOW()) > 6 AND HOUR(NOW()) < 19 AND NOW() < DATE_ADD(T.CREATED, INTERVAL 15 MINUTE) AND T.OWNER_ID = 0 AND S.STATE != 'closed'
Posted by: airwolf 14 years ago
Red Belt
1
Grico, sorry about that - another typo in Gerald's code that I copied/pasted. I used his example, because it's backward compatible with older KBOX models. This should work for you, there was a less-than sign where a greater-than should be!

SELECT T.ID AS TICKNUM, T.TITLE AS TITLE, U.EMAIL AS SUBMITTER_EMAIL, U.FULL_NAME AS SUBMITTER_FULLNAME, '_helpdesk@uslegalsupport.com' AS EMAIL FROM HD_TICKET T
JOIN HD_STATUS S ON (T.HD_STATUS_ID = S.ID)
JOIN USER U ON (T.SUBMITTER_ID = U.ID)
WHERE HOUR(NOW()) > 6 AND HOUR(NOW()) < 19 AND NOW() > DATE_ADD(T.CREATED, INTERVAL 15 MINUTE) AND T.OWNER_ID = 0 AND S.STATE != 'closed'
Posted by: RichB 14 years ago
Second Degree Brown Belt
1
This doesn't know about weekends so if a ticket is left unassigned on a weekend during work hours an email will get sent, right?
Posted by: airwolf 14 years ago
Red Belt
1
ORIGINAL: RichB

If I want the same email to only be sent if a ticket has been unassigned for an hour the interval changes from 15 minutes to Hourly and the SQL Select changes from "INTERVAL 15 MINUTES" to INTERVAL Hourly", right?

INTERVAL 15 MINUTE changes to INTERVAL 1 HOUR
Posted by: airwolf 14 years ago
Red Belt
1
ORIGINAL: RichB

This doesn't know about weekends so if a ticket is left unassigned on a weekend during work hours an email will get sent, right?


SELECT T.ID AS TICKNUM, T.TITLE AS TITLE, U.EMAIL AS SUBMITTER_EMAIL, U.FULL_NAME AS SUBMITTER_FULLNAME, 'my.email@asd20.org'
AS EMAIL FROM HD_TICKET T
JOIN HD_STATUS S ON (T.HD_STATUS_ID = S.ID)
JOIN USER U ON (T.SUBMITTER_ID = U.ID)
JOIN HD_QUEUE Q ON T.HD_QUEUE_ID=Q.ID and Q.NAME ='ASD20 Help Desk'
WHERE DAYNAME(DATE(NOW())) NOT IN ('Saturday','Sunday') AND HOUR(NOW()) > 6 AND HOUR(NOW()) < 20 AND NOW() > DATE_ADD(T.CREATED, INTERVAL 15 MINUTE) AND T.OWNER_ID = 0 AND S.STATE != 'closed'

Comments:
  • Not sure if this is still valid info for K1 v6.3, seems to be the most detailed with explinations of SQL lines.
    This last example seems to be exactly what I want.
    You mention "If you have more than one queue, you'll have to add " AND T.HD_QUEUE_ID = 1" without the quotes to the end of the WHERE clause - replacing 1 with the proper queue ID number."
    I see the join statement with que info, but what happened to the "AND T.HD..... info. - wessdf 9 years ago
    • You would simply add that to the very end of the query in the where clause. If you don't specify the queue ID, it'll pull tickets from every queue. - airwolf 9 years ago
      • Which is fine as I would like to be notified on all queues. When I run now I get:
        09/30/2015 13:06:34> Starting: 09/30/2015 13:06:34 09/30/2015 13:06:34> Executing Select Query... 09/30/2015 13:06:34> selected 13 rows 09/30/2015 13:06:34> Sending ticket notifications... 09/30/2015 13:06:34> sent mail to 0 of 13 09/30/2015 13:06:34> Ending: 09/30/2015 13:06:34
        My rule is not enabled and I do not have any thing in email results.
        Im looking at the "sent mail to 0 of 13" as an error???
        Here is what I am using:
        SELECT T.ID AS TICKNUM, T.TITLE AS TITLE, U.EMAIL AS SUBMITTER_EMAIL, U.FULL_NAME AS SUBMITTER_FULLNAME, 'itoper@mydomain'
        AS EMAIL FROM HD_TICKET T
        JOIN HD_STATUS S ON (T.HD_STATUS_ID = S.ID)
        JOIN USER U ON (T.SUBMITTER_ID = U.ID)
        JOIN HD_QUEUE Q ON T.HD_QUEUE_ID = 25
        WHERE DAYNAME(DATE(NOW())) NOT IN ('Saturday','Sunday') AND HOUR(NOW()) > 6 AND HOUR(NOW()) < 20 AND NOW() > DATE_ADD(T.CREATED, INTERVAL 15 MINUTE) AND
        T.OWNER_ID = 0 AND S.STATE != 'closed' - wessdf 9 years ago
      • If it returned 13 rows and sent 0 emails then your issue likely lies with the config of the email address for the notifications. The query worked if it pulled 13 rows, so the select query is likely fine. - airwolf 9 years ago
      • Thanks for your help, I realized that I had "Column containing email addresses:" wrong. I fixed that and now I get 13 emails sent to the email group I listed. If I replace "JOIN HD_QUEUE Q ON T.HD_QUEUE_ID = 25" with
        "JOIN HD_QUEUE Q ON T.HD_QUEUE_ID = Q.ID and Q.NAME = 'IT - Service Desk Test Queue'
        I get one email.
        Now I would like to have this send the group from all queues. Can it be done by omitting the "JOIN HD_QUEUE Q ON T.HD_QUEUE_ID = Q.ID and Q.NAME = 'IT - Service Desk Test Queue'"? Or will I have to add this rule to all queues, which I can do no problem, but you made it sound like I would just leave it out??? - wessdf 9 years ago
      • Ah, I didn't catch that earlier. The example here is restricting to one queue on the join, so yeah you can just remove the 'and Q.NAME = "ASD20 Help Desk"' part from the above example. This will give you data from all queues. - airwolf 9 years ago
Posted by: RichB 14 years ago
Second Degree Brown Belt
1
It's working great, thanks!
Posted by: airwolf 14 years ago
Red Belt
0
Create a custom rule that runs every 15 minutes. Use the following as the Select Query (which will select all non-closed tickets created over 15 minutes ago with no owner), and only check the box marked "Send Query Results to Someone" and enter your email address.


SELECT * FROM HD_TICKET T
JOIN HD_STATUS S ON (T.HD_STATUS_ID = S.ID)
WHERE TIME_TO_SEC(TIMEDIFF(NOW(),T.CREATED)) > 900 AND T.OWNER_ID = 0 AND S.STATE != 'closed'


If you have more than one queue, you'll have to add " AND T.HD_QUEUE_ID = 1" without the quotes to the end of the WHERE clause - replacing 1 with the proper queue ID number.
Posted by: grico 14 years ago
Senior Yellow Belt
0
If I set it to run every 15 min, what if a new ticket is entered 14 min into the 15 min. Will I then get a email 1 min after the ticket is created?
Posted by: airwolf 14 years ago
Red Belt
0
No, it will only show tickets that were created more than 15 minutes ago. Since the rule runs every 15 minutes (the lowest you can set it), your results may not show a ticket until about 30 minutes. So, your window of results is 15-30 minutes and beyond.
Posted by: grico 14 years ago
Senior Yellow Belt
0
This is what I got in a test email.
Unassigned Ticket over 15 min

Unassigned Ticket over 15 min
# Id Title Hd Priority Id Hd Impact Id Modified Created Owner Id Submitter Id Hd Status Id Hd Queue Id Hd Category Id Cc List Escalated Custom Field Value0 Custom Field Value1 Custom Field Value2 Custom Field Value3 Custom Field Value4 Custom Field Value5 Custom Field Value6 Custom Field Value7 Custom Field Value8 Custom Field Value9 Custom Field Value10 Custom Field Value11 Custom Field Value12 Custom Field Value13 Custom Field Value14 Due Date Time Opened Time Closed Time Stalled Machine Id Satisfaction Rating Satisfaction Comment Resolution Asset Id Parent Id Is Parent Approver Id Approve State Approval Approval Note Id Hd Queue Id Name Ordinal State
1 4 TEST DO NOT DELETE 1 6 2010-03-17 12:09:05 2010-03-17 12:09:05 0 182 4 1 2 0000-00-00 00:00:00 3896 No Texas 2010-03-17 12:09:05 0000-00-00 00:00:00 0000-00-00 00:00:00 0 0 0 0 0 0 4 1 NEW 0 opened


Is is possible to get something as simple as


"Enduser (unduser@mycompany.com) has an unassigned ticket # 8557.

Please click here to review it online at
http://helpdesk.mycompany.com/adminui/ticket?ID=8557"

This is the code that I used to give me the requested info.
$submitter_fullname ($submitter_email) has an Unassigned ticket # $ticknum for more than 15 min.

Please click here to review it online at
http://helpdesk.uslegalsupport.com/adminui/ticket?ID=$ticknum
Posted by: airwolf 14 years ago
Red Belt
0
Simply uncheck the "Send Query Results Checkbox to Someone" and choose "Send an email for each result row". This will send an email to you for each ticket that fits the criteria. Keep in mind, you'll also have to change the Select Query to this (you'll need to put in a valid email address where I've got your@emailaddress.com):


SELECT T.ID AS TICKNUM, T.TITLE AS TITLE, U.EMAIL AS SUBMITTER_EMAIL, U.FULL_NAME AS SUBMITTER_FULLNAME, 'your@emailaddress.com' AS EMAIL FROM HD_TICKET T
JOIN HD_STATUS S ON (T.HD_STATUS_ID = S.ID)
JOIN USER U ON (T.SUBMITTER_ID = U.ID)
WHERE TIME_TO_SEC(TIMEDIFF(NOW(),T.CREATED)) > 900 AND T.OWNER_ID = 0 AND S.STATE != 'closed'


And make sure you have "EMAIL" without the quotes in the Email Column field when setting up your rule. Create your subject line and body however you like, and remember that you can use any column as a variable by putting a $ in front of it (i.e. $title, $submitter_email, $submitter_fullname). Only columns given by the select query can be used as variables, so I've created TICKNUM, TITLE, SUBMITTER_EMAIL, and SUBMITTER_FULLNAME.
Posted by: GillySpy 14 years ago
7th Degree Black Belt
0
Everything Andy says is correct. However, for those with older kboxes that have mysql 4.x the function TIMEDIFF will not work. You could substitute

TIME_TO_SEC(TIMEDIFF(NOW(),T.CREATED)) > 900
with
NOW() < DATE_ADD(T.CREATED, INTERVAL 15 MINUTE)

The way this is written is that even if you have more than one queue this rule will notify you about all tickets that meet this condition in all queues. To limit it to just the queue that the rule exists in you need to add this to the end of the query:

and T.HD_QUEUE_ID=X X is the queue number for this queue. If you don't know the queue number then you can use the queue name like this:

SELECT T.ID AS TICKNUM, T.TITLE AS TITLE, U.EMAIL AS SUBMITTER_EMAIL, U.FULL_NAME AS SUBMITTER_FULLNAME, 'your@emailaddress.com' /* <<<<<<<<put your email here */
AS EMAIL FROM HD_TICKET T
JOIN HD_STATUS S ON (T.HD_STATUS_ID = S.ID)
JOIN USER U ON (T.SUBMITTER_ID = U.ID)
JOIN HD_QUEUE_ID Q ON T.HD_QUEUE_ID=Q.ID and Q.NAME ='Kbox Helpdesk' /* <<<<< set queue name here */
WHERE NOW() < DATE_ADD(T.CREATED, INTERVAL 15 MINUTE) AND T.OWNER_ID = 0 AND S.STATE != 'closed'
Posted by: grico 14 years ago
Senior Yellow Belt
0
This script has been working flawlessly and helping us make sure that all tickets are assigned in a timely manor. However it is working to well, and if someone puts in a ticket after hours I am getting an email every 15 min till I get here in the morning. I thought I saw a script that would allow me to shut off email notification during a certain time frame. Can someone point me to the right place to look?
Posted by: airwolf 14 years ago
Red Belt
0
I am unaware of any such script, Grico. Unfortunately, you can't accomplish this by changing the schedule on the rule either, because it doesn't allow for a "run window" or anything like that.

You CAN solve your problem, however, by modifying the SQL to only return results if NOW() is within a certain range.

SELECT T.ID AS TICKNUM, T.TITLE AS TITLE, U.EMAIL AS SUBMITTER_EMAIL, U.FULL_NAME AS SUBMITTER_FULLNAME, 'your@emailaddress.com' /* <<<<<<<<put your email here */
AS EMAIL FROM HD_TICKET T
JOIN HD_STATUS S ON (T.HD_STATUS_ID = S.ID)
JOIN USER U ON (T.SUBMITTER_ID = U.ID)
JOIN HD_QUEUE_ID Q ON T.HD_QUEUE_ID=Q.ID and Q.NAME ='Kbox Helpdesk' /* <<<<< set queue name here */
WHERE HOUR(NOW()) > 6 AND HOUR(NOW()) < 20 AND NOW() < DATE_ADD(T.CREATED, INTERVAL 15 MINUTE) AND T.OWNER_ID = 0 AND S.STATE != 'closed'


The addition of HOUR(NOW()) > 6 AND HOUR(NOW()) < 20 will only allow the rule to return results after 6am and before 8pm, so we've just created a window of time for the rule!
Posted by: RichB 14 years ago
Second Degree Brown Belt
0
If I want the same email to only be sent if a ticket has been unassigned for an hour the interval changes from 15 minutes to Hourly and the SQL Select changes from "INTERVAL 15 MINUTES" to INTERVAL Hourly", right?
Rating comments in this legacy AppDeploy message board thread won't reorder them,
so that the conversation will remain readable.

Don't be a Stranger!

Sign up today to participate, stay informed, earn points and establish a reputation for yourself!

Sign up! or login

Share

 
This website uses cookies. By continuing to use this site and/or clicking the "Accept" button you are providing consent Quest Software and its affiliates do NOT sell the Personal Data you provide to us either when you register on our websites or when you do business with us. For more information about our Privacy Policy and our data protection efforts, please visit GDPR-HQ