One way to remove the DND is from the CLI:
asterisk -rx "database del CustomDevstate 9999"
Where 9999 is the extension number. To see if it is busy or on DND:
asterisk -rx "database show" | grep "9999"
From this you could script it in some way. I don’t think there’s anything in the AMI for changing the UserEvent state.