[asterisk-users] Lookup ${EXTEN} in database, update context/route if found... AGI?

Doug Lytle support at drdos.info
Tue May 11 15:11:22 CDT 2010


Tim Nelson wrote:
> Greetings all-
>
> box on the same network. Instead of paying twice for the call to go out to the PSTN on one channel and back in on another channel, I'd like the ability to lookup the destination number in a MySQL database
>    

I use the mysql add-on, I'd create a subroutine that gets called at dial 
time.  As an example, I set outbound caller-id with the below 
subroutine.  You would use ${EXTEN} for the lookup and decide the route 
to take on the results.

[set_callerid]

exten => s,1,MYSQL(Connect connid 192.168.103.15 username 'password' did)
exten => s,n,GosubIf($["${MYSQL_STATUS}" = "-1"]?mysql_failed,s,6)
exten => s,n,MYSQL(Query resultid ${connid} SELECT setcid FROM Corporate 
WHERE number = ${CALLERID(number)})
exten => s,n,MYSQL(Fetch fetchid ${resultid} set.callerid)
exten => s,n,MYSQL(Disconnect ${connid})
exten => s,n,MYSQL(Clear ${resultid})
exten => s,n,GotoIf($["${set.callerid}" != ""]?8:10)
exten => s,n,Set(CALLERID(number)=${set.callerid})
exten => s,n,Return()
exten => s,n,Set(CALLERID(number)=269xxxxxxx)
exten => s,n,Return()

Doug


-- 

Ben Franklin quote:

"Those who would give up Essential Liberty to purchase a little Temporary Safety, deserve neither Liberty nor Safety."




More information about the asterisk-users mailing list