Hi guys,
I’d like to count the number of time a caller tries to call me on Asterisk. I couldn’t find any function to count the number of calls filtered by incoming callerID.
For eg. If caller A (say has caller ID abcdef) calls me more than 5 times in a day, I’d like to take a specific action -> eg. block or sent to voicemail.
How would I go about implementing this? Any suggestions would be appreciated.
Thanks,
Clive
Thanks @ambiorixg12. The link you provided was helpful. What I’m thinking of is:
- Check whether incoming caller ID has a family, else create one
- Check the number of times the caller has called, and increment by one
But, how do I check the number of times the caller called in, say, the last half an hour? Would you have any suggestions?
I just use AsteriskDB for very simple stuff I rather prefer MYSQL , because I can use the power of the query language " select count(*) from calls where src=’${CALLERID(num)}’ Anyway it is 2AM here, If you havent found an asnwer to your doubt , tomorrow once I get some rest tomorrow I will post you some suggestion
1 Like
Thanks. I was trying to find a way to automatically erase the database every half an hour - this would mean the count stored would represent the no. of times the caller tried to call in in the last half an hour. Anyways, I look forward to hearing from you tomorrow. Enjoy your rest!
1 Like
I wasn’t able to find a solution. I’d appreciate any suggestion. Thanks.
I think you can do this using cdr. However I would also suggest to implement some custom solution as below
(1) Have one simple table in MySQl/MariaDB (or in any database of your choice)
CREATE TABLE caller_count
(
caller
varchar(255) NOT NULL,
calltime
datetime NOT NULL,
index(calltime)
) ENGINE=InnoDB;
(2) Insert record in this table when a new call comes in
(3) Use query like blow to determine count for particular caller.
SELECT count(*) FROM caller_count WHERE caller=’’ AND calltime > (NOW() - INTERVAL 1 DAY)
–Satish Barot
1 Like