Getting information which SIP client answered the call

Hi all,

we have dialplan which exeutes Dial(SIP/100&SIP/101&SIP/102), at the end of conversation we record call data with custom AGI script.

What we need to do is to pass to the AGI script which extension answered the call. In log file I can see information who picked the call:

[Jun 10 18:39:44] VERBOSE[7199] app_dial.c:     -- SIP/100-0000001c is ringing
[Jun 10 18:39:44] VERBOSE[7199] app_dial.c:     -- SIP/101-0000001e is ringing
[Jun 10 18:39:44] VERBOSE[7199] app_dial.c:     -- SIP/102-0000001f is ringing
[Jun 10 18:39:52] VERBOSE[7199] app_dial.c:     -- SIP/101-0000001e answered SIP/in_trunk-0000001b

How do I pass this information into a dialplan variable/agi script? I would also need to pass information about a talk duration to an agi script.

Thank you in advance.

you could just use asterisk’s built in cdr

riddlebox thank you for your suggestion.

If I use builtin CDR, I think I have two (three) options:
-either duplicate Perl AGI code in C and build custom CDR application,
-create a C CDR application which is a system wrapper for my Perl AGI script.
-use cdr shell CDR application which is referenced in wiki, but page is not live anymore

Is there any other option?

Basically I wanted to avoid C CDR and have all application logic built into my perl script. I need perl script, because I want to populate some data also at the beggining of a call, which I understand can only be executed as part of an AGI script.