13 июн. 2019 г.

Asterisk - отправить звонок в разные очереди, в зависимости от номера звонящего

How to send incoming call to certain queue, depending on CallerID?
Use mysql table with clients phones - filter clients and advertisement calls.

; main callcenter queue entry from outside
exten => 4100,1,Answer
 same => n,Playback(announce/announce)
; Check - is it special user?
; get target queue name by callerID - for certain callers
 same => n,Macro(MySQLConnect,${connid})
 same => n,MySQL(Query resultid ${connid} SELECT ID,NUMBER,INCOMING_ID,QUEUE_NAME,COMMENT from queue_target where NUMBER=${CALLERID(num)})
 same => n,MYSQL(Fetch foundRow ${resultid} id number incoming_id queue_name comment) ; fetch row
 same => n,MYSQL(Disconnect ${connid})
 same => n,Verbose("Skilltagging checking number  - ${id} ${number} ${incoming_id} ${queue_name} ${comment}")
 same => n,GotoIf($[${foundRow}]?:qcallc)
 same => n,Verbose(1,"Caller ${CALLERID(num)} ${foundRow} was found as ${comment} and sent to queue ${queue_name} ")
 same => n,GotoIf($[${foundRow}&$[${queue_name}=insurance]]?qins:)
 same => n,GotoIf($[${foundRow}&$[${queue_name}=advertisement]]?qadvert:)
; usual call
 same => n(qcallc),Queue(callcenter,t,,,60)
 same => n,Hangup()
; insurance company
 same => n(qins),Queue(insurance,t,,,120)
; not serviced (no members or not answered)- goto common queue
 same => n,Goto(qcallc)
 same => n,Hangup()

 same => n(qadvert),Queue(advertisement,t,,,120)
; not serviced (no members or not answered)- goto common queue
 same => n,Goto(qcallc)
 same => n,Hangup()