Getting last caller info for a trunk

is there a way i can get call trace for a trunk? i need to create a version of *69 that will speak the last incoming call for a particular trunk, is this possible?

thanks

You certainly could write an extension to do that. Or look in the CDR. You can generate a CDR report on one Asterisk channel.

are there any guides for CDR manipulation that i can follow/adapt?

I guess I don’t understand the question.

FreePBX provides a report generator for the CDR’s. If you don’t like it you can connect to the CDR db (it’s a standard SQP database) and access it with anything you like.

The Asterisk CDR data schema is documented in the Asterisk docs.

You can also just use the mysql tool and list the columns in the table. All the data types will be declared.

All it requires is a basic understanding of databases. Nothing special to Asterisk or FreePBX.

The DB credentials can be viewed in the advanced settings module or /etc/amportal.conf for earlier versions.

sorry i wasn’t exactly clear on the first post. what the end user has requested is a version of the british 1471, or *69 feature in asterisk. however when they dial this i need the last number from my sipgate trunk to be read out not the last number that dialed that extension. hopefully that makes sense :slight_smile:

That would require a bit of custom programming.

The choice would be that you could learn Asterisk programming and take it on as a project. In my opinion if you have ever programmed in any language, even BASIC, you could pick it up very quickly.

The other option is to engage a programmer. Several work for the FreePBX support team. If you choose that option you are also helping support the project.

Hope this helps.

thanks, i’ll check it out, have programmed in two or three languages :slight_smile:

If you are using Asterisk 1.4 or 1.6 the older “Asterisk, The future of telephony” is your best bet. If using Asterisk 1.8 pick up a copy of “Asterisk, The definitive reference”.

FreePBX provides a facility via /etc/asterisk/extensions_custom.conf for users to place their code. Just remember when you are done you have to pass the call back to FreePBX. Also the FreePBX custom extensions module allows you to register your extension so FreePBX is aware of it and you can use it as the destination of a route, IVR etc.

for anyone who finds this thread, here is the code i used to implement this.

exten => 1471,1,Answer()
exten => 1471,2,Playback(beep)
exten => 1471,3,Playback(info-about-last-call)
exten => 1471,4,MYSQL(Connect connid localhost dbuser dbpass asteriskcdrdb)
exten => 1471,5,MYSQL(Query resultid ${connid} SELECT src FROM cdr WHERE channel LIKE ‘SIP/sg-eaton-torquay-out%’ AND dst != 1471 AND src != ‘anonymous’ ORDER BY calldate DESC LIMIT 0,1)
exten => 1471,6,MYSQL(Fetch foundRow ${resultid} number)
exten => 1471,7,MYSQL(Clear ${resultid})
exten => 1471,8,MYSQL(Disconnect ${connid})
exten => 1471,9,SayDigits(${number})
exten => 1471,10,Hangup()

When 1471 is dialled, asterisk searches the cdr database for the most recent call that is related to the trunk and is not an anonymous number or 1471 being dialled from an external link. it then plays this back to the caller.