On Thursday 15 Sep 2016, tux john wrote:> hi. i am running asterisk 11 and i am using astdb to store all my contacts
> and their numbers. so everytime they call me, i can see their name on the
> screen of the phone. i am making use of the following to retrieve the name
> from the astdb exten =>
> WhatEverIsMyDID,1,Set(CALLERID(name)=${DB(cidname/${CALLERID(num)})})
> exten => WhatEverIsMyDID,n,Answer()
>
> in the same machine i have mysql. i would like to make use of mysql to
> store and retrieve phonebook as well create blacklist of numbers. i
> thought of creating 2 databases
> -phonebook, will contain name, number
> -blacklist, will contain name, number
>
> once i update all the database fiels how can i see the names whenever
> someone calls? regarding the blacklist, i would like to send them to hear
> a sound (eg tt-monkeys) or simply hangup.
Write an AGI script that expects a phone number as its parameter, performs a
database lookup on the number and sets some channel variables with the
caller's name and whether or not they are blacklisted. You probably need
only
one table, really; use VARCHAR() fields for the number and name and something
like a TINYINT(1) for indicating whether or not the number is blacklisted.
After the script exits, the dialplan will see any variables it set. So you
can do something like this;
exten => s,1,Set(from=${CALLERID(num)})
exten => s,n,(Incoming call from ${from})
exten => s,n,AGI(lookup_caller.agi,${from})
; /var/lib/asterisk/agi-bin/lookup_caller.agi sets variables `blocked` to true
; if the caller is blocked, and `callername` to the caller's name
exten => s,n,GotoIf(${blocked}?unwelcome:permitted)
exten => s,n(permitted),NoOp(This call is allowed)
exten => s,n,Set(CALLERID(name)=${callername})
; we can maybe do something else funky with callername here
exten => s,n,Dial(${ALL_EXTS})
exten => s,n,Hangup()
; tell unwanted callers where to stick that phone
exten => s,n(unwelcome),MP3player(/songs/kevin_bloody_wilson/dicktaphone.mp3)
exten => s,n,Hangup()
I used some simple example code to implement a little daemon on users'
workstations; which listened on a UDP port, and created system notifications
informing the user of an incoming call. As this was all on the inside of a
firewall, I also included the capability to open up a web page. The AGI script
was able not only to notified the workstation adjacent to the phone of the
incoming call; but if the number was recognised as belonging to a user within
our system, would bring up their details on screen (all the work was done
through a custom web application).
--
AJS
Note: Originating address only accepts e-mail from list! If replying off-
list, change address to asterisk1list at earthshod dot co dot uk .
-------------- next part --------------
An HTML attachment was scrubbed...
URL:
<http://lists.digium.com/pipermail/asterisk-users/attachments/20160915/eebef70a/attachment.html>