VoIP Mailing List Archives
Mailing list archives for the VoIP community |
|
View previous topic :: View next topic |
Author |
Message |
atux at null.net Guest
|
Posted: Thu Sep 15, 2016 5:56 am Post subject: [asterisk-users] mysql phonebook |
|
|
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.
Some advice please? |
|
Back to top |
|
|
support at drdos.info Guest
|
Posted: Thu Sep 15, 2016 6:17 am Post subject: [asterisk-users] mysql phonebook |
|
|
I do this. I connect back to the mysql server via odbc, and as you, I have two databases for this, one called blacklisted and the other called speeddials.
My dialplan code below:
exten => _5XXXXXXXXX,1,Answer()
exten => _5XXXXXXXXX,n,Gosub(check_blacklist,s,1)
exten => _5XXXXXXXXX,n,Gosub(get_callerid,s,1)
[check_blacklist]
exten => s,1,GotoIf($["${CALLERID(number)}" = "" ]?2:3)
exten => s,n,Set(CALLERID(all)=Restricted <0>)
exten => s,n,Set(ARRAY(flag,note)=${ODBC_BLACKLIST(${CALLERID(number)})})
exten => s,n,GotoIf($["${flag}" = "YES"]?blacklisted,s,1)
exten => s,n,NoOP(Caller not blacklisted)
exten => s,n,Return
[blacklisted]
exten => s,1,NoOP(Caller: ${CALLERID(number)} is on the black list)
exten => s,n,NoOP(NOTE: ${note})
exten => s,n,Set(CDR(userfield)=Blacklisted)
exten => s,n,Zapateller(answer)
exten => s,n,Hangup(2)
The ODBC query is:
[BLACKLIST]
dsn=MySQL-blacklisted
readsql=SELECT flag, note FROM [putyourdatabasenamehere] WHERE phone=${SQL_ESC("${ARG1}")}
[get_callerid]
exten => s,1,Set(ARRAY(speed.dial,speed.name)=${ODBC_GET_CALLERID(${CALLERID(num)})})
exten => s,n,Set(CALLERID(name)=${speed.name})
exten => s,n,Return()
The ODBC query is:
[GET_CALLERID]
dsn=MySQL-speeddials
readsql=SELECT phone, name, code FROM [putyourdatabasenamehere] WHERE phone = ${ARG2}
Doug
--
_____________________________________________________________________
-- Bandwidth and Colocation Provided by http://www.api-digital.com --
Join the Asterisk Community at the 13th AstriCon, September 27-29, 2016
http://www.asterisk.org/community/astricon-user-conference
New to Asterisk? Start here:
https://wiki.asterisk.org/wiki/display/AST/Getting+Started
asterisk-users mailing list
To UNSUBSCRIBE or update options visit:
http://lists.digium.com/mailman/listinfo/asterisk-users |
|
Back to top |
|
|
asterisk_list at earth... Guest
|
Posted: Thu Sep 15, 2016 7:26 am Post subject: [asterisk-users] mysql phonebook |
|
|
On Thursday 15 Sep 2016, tux john wrote:
Quote: | 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 . |
|
Back to top |
|
|
|
|
|
You cannot post new topics in this forum You cannot reply to topics in this forum You cannot edit your posts in this forum You cannot delete your posts in this forum You cannot vote in polls in this forum
|
Powered by phpBB © 2001, 2005 phpBB Group
|