19 апр. 2017 г.

Asterisk: call web-based CRM when queue agent pick up the call

Asterisk: call web-based CRM when queue agent pick up the call.

We have a realtime queue.
We have to call URL when the agent of the queue pick up the call from it
URL  looks like a:

http://mycrm/socket/call.php?call_id=1492593880.162&operator_id=01&call_number=+73223223232"



1. Add fields to table queue_table:
varchar membermacro - name of the macro, called at pick up.
varchar setinterfacevar - enable to transfer variables to macro.

2. Set fields of queue record:
membermacro=callcenter-hook in the extensions.conf - hook macro name.
setinterfacevar=yes - required to get values in the macro.

3. Change queue call like:
exten => 0,1,Answer
same => n,Set(_QUEUECALLID=${UNIQUEID})
same => n,Queue(callcenter,t,,,300)
same => n,Handup()

4. Add hookup macro:

[macro-callcenter-hook]
exten => s,1,Verbose(User ${MEMBERNAME} on phone ${MEMBERINTERFACE} picked up call with ID=${QUEUECALLID}, callernum=${CONNECTEDLINE(num)} with data2=${UNIQUEID})
exten =>s,n,system(wget -O /dev/null --quiet "http://mycrm/socket/call.php?call_id=${QUEUECALLID}&operator_id=${MEMBERNAME}&call_number=${CONNECTEDLINE(num)}")

That's all.