Using AMI events to take action

How can I use AMI Events to take action when a call goes to voicemail?

If you just need an event for when a call goes to voicemail you can use UserEvent[1] in the dialplan to produce an AMI event[2] with the data you need. It is up to you to have an outside application (that you write) listening for said event and taking whatever action.

[1] Asterisk 20 Application_UserEvent - Asterisk Project - Asterisk Project Wiki