Trace calls


With an AMP configuration, where can I put my AGI command, to trace incoming calls only when they are answered ?

Somewhere in [macro-dial] ?
Or for each extension in [ext-local] ?
And, how to detect if the called is answered to launch my AGI just in this case, that’s really my problem.

It to make something like a hotline, but not registering calls when they are not answered.