Need to Create an email alert for a phone Queue

I have a phone queue and I would like to create an email alert for when a call is holding in the queue more than 40 secs. I would also like to create an alert for when there is an abandoned call from the phone queue.