How to block an inbound call if its CID was used before?

Hello everyone, You are all doing a Great Job here!!

I have and IVR working perfectly in my FreePbx, we provide some services for our customers.

I need to allow my clients to try the services we provide on the line giving them the chance to call us free during 10 minutes. (we have a paid number and a free one)

I must allow the customers to use the free line only once, so the system must to check if the CID was used before, for example:

CID: +3491256874–> It calls and the system allows the call to try the services. We need to hung up this call automatically after 10 minutes.

SAME CID: +3491256874–>This customer with same CID try to call again. The system should notice that this CID was used before, and it should play an announcment and hung up the call.

How can i make the system to check he CDR to see if CID matches any other used before? Any suggestions about how to do it?

How could I play an announcement before ending the call automatically after a certain amount of time?

Thank you very much!!

Send inbound calls to a context that you will write that will lookup your criteria in your asteriskcdrdb mysql table and so act appropriately.

mysql pseudo code

SELECT 36000 - SUM(billsecs) from cdr where clid=${CALLERID(num)} AND dst=(your_free_number)

if the result is greater than zero then they still have credit, and you ultimately place the call , modify the dial command’s L option ref:-

http://www.voip-info.org/wiki/view/Asterisk+cmd+Dial

Thbak you very much, but i dont get the thing about contexts. What does context really mean? Where do i write that in FreePbx?

I understand the pseudocode, very well thought, but how do I make it real code and where to write it?

I see you have bitten of rather more than you can chew yet :wink:

As to contexts, start with http://www.voip-info.org/wiki/view/Asterisk+contexts and follow the links therein.

You can’t do it in FreePBX, the recommended place is /etc/asterisk/extensions/extensions_custom.conf

Although you have used up your ten free minutes here, Schmooze offers a paid support option under the support tab at the top of this page for customizations such as you are looking for.