📜 ⬆️ ⬇️

Call Transfer Using Script in Asterisk



Not so long ago, one of our clients felt the need to transfer calls (incoming and outgoing) by clicking from a browser. The logic is as follows: a group of call center operators receives and makes calls, and after talking and clarifying the needs, they need to connect the client with one of the customers or another specialist of the organization.

It would seem that the operator can transfer the call in the classical way - by “blind” transferring the required number from his telephone or softphone, but in fact it turned out that there are more than five hundred numbers that need to be transferred and they are constantly being added and changed, so that even the centralized automatic filling of the softphone phone book does not allow operators to work comfortably and quickly: first you need to find out the client’s need, then find the number with which to connect it in CRM, then or time Learning to enter a number, or find the same number in the softphone phonebook. This leads to the inefficient use of operators' working time, a high probability of translation errors and a decrease in the quality of customer service in general.

In some cases, a similar problem is solved as follows: the event in CRM in a certain database is entered the number of the operator, and the number with which you want to connect his interlocutor. After that, the operator transfers the call to the service number, in the context of the transfer, a request to the database is made and the call is finally transferred to the desired number. Dialplan for outbound in this case looks like this:
')
[operator-out]
exten => _X.,1,Noop(Outgoing call from ${CALLERID(num)} to ${EXTEN})
exten => _X.,n,Set(__TRANSFER_CONTEXT=transfer)
exten => _X.,n,Dial(SIP/provider/${EXTEN},30,T)

[transfer]
exten => 800,1,Set(num=ODBC_GETXFERNUM(${CALLERID(num)}
exten => 800,n,Noop(Transfer to ${num})
exten => 800,n,Goto(some-context,${num},1)


For an outgoing call, the channel variable TRANSFER_CONTEXT is set, which overrides the context for transferring calls, and if the call is transferred to number 800 using ODBC, we get a number to which you actually need to transfer. However, before the translation itself, the unambiguous correspondence of the operator’s internal number and the number to which the call must be transferred must be entered in the appropriate fields of the table, which requires at least one extra action from the employee (in CRM he needs to choose the number where he wants to transfer call, and then on the phone or softphone perform the translation itself), and you also need to ensure that the data in the table is correct: delete the record immediately after the transfer, check and process empty records in the dialplan.

With all the shortcomings, this method can be applied if you know in advance which number you may need to transfer the call to. Suppose a call center works on outgoing calls to customers of several customers. The call is automatically generated from the CRM (using the callfile or via the originate in AMI), where the operator presses the “next call” button and sees the conversation script with the client. Then you can simply add an inherited variable with a number, and transfer the call to it:

In the callfile add the inherited variable __num:

Channel: Local/101@from-internal
Callerid: 74950000000
MaxRetries: 2
RetryTime: 600
WaitTime: 30
Context: from-internal
Extension: 74950000000
Priority: 1
Set: __num=79991112233


And the translation context will look even simpler:

exten => 800,1,Noop(Transfer to ${num})
exten => 800,n,Goto(some-context,${num},1)


However, in our case, as mentioned above, this method is undesirable.

Fortunately, the asterisk developers took care of us, and through cli you can translate a specific channel into the specified context:

channel redirect <[[context,]exten,]priority>

AMI:

Action: Redirect
[ActionID:] value
Channel: value
[ExtraChannel:] value
Exten: value
[ExtraExten:] value
Context: value
[ExtraContext:] value
Priority: value
[ExtraPriority:] value>


: , , .

, . bridge show all .

> bridge show all
Bridge-ID Chans Type Technology
14418b64-0635-46e7-bd48-f4b820461eaa 2 basic simple_bridge


bridge show <bridge-id> , .

, bridge-id , bridge-id, :

> core show channels concise
SIP/RT-00000453!incoming!!1!Up!AppDial!(Outgoing Line)!89063448810!!!3!134!14418b64-0635-46e7-bd48-f4b820461eaa!1479984681.1659
SIP/67-00000452!macro-dialout-trunk!s!23!Up!Dial!SIP/RT/89063448810,300,TtL(7200000)!67!!!3!134!14418b64-0635-46e7-bd48-f4b820461eaa!1479984681.1658


, 2 bridge-id(14418b64-0635-46e7-bd48-f4b820461eaa), . . bash-, ( FreePBX 13):

#!/bin/bash context="from-internal" # , exten=$1 # num=$2 # , bridge=$(asterisk -rx 'core show channels concise' | grep SIP/$exten- | cut -d '!' -f13 ) # bridge-id SIP/xx-aaaaa channel=$(asterisk -rx 'core show channels concise' | grep $bridge | grep -v SIP/$exten- | cut -d '!' -f1) # channel SIP/provider-000000 result=$(asterisk -rx "channel redirect $channel $context,$num,1") # echo $result exit 0

- , . “” CRM .

? , CRM asterisk . , , .

--, , , .
 channel redirect <[[context,]exten,]priority> 

AMI:

Action: Redirect
[ActionID:] value
Channel: value
[ExtraChannel:] value
Exten: value
[ExtraExten:] value
Context: value
[ExtraContext:] value
Priority: value
[ExtraPriority:] value>


: , , .

, . bridge show all .

> bridge show all
Bridge-ID Chans Type Technology
14418b64-0635-46e7-bd48-f4b820461eaa 2 basic simple_bridge


bridge show <bridge-id> , .

, bridge-id , bridge-id, :

> core show channels concise
SIP/RT-00000453!incoming!!1!Up!AppDial!(Outgoing Line)!89063448810!!!3!134!14418b64-0635-46e7-bd48-f4b820461eaa!1479984681.1659
SIP/67-00000452!macro-dialout-trunk!s!23!Up!Dial!SIP/RT/89063448810,300,TtL(7200000)!67!!!3!134!14418b64-0635-46e7-bd48-f4b820461eaa!1479984681.1658


, 2 bridge-id(14418b64-0635-46e7-bd48-f4b820461eaa), . . bash-, ( FreePBX 13):

#!/bin/bash context="from-internal" # , exten=$1 # num=$2 # , bridge=$(asterisk -rx 'core show channels concise' | grep SIP/$exten- | cut -d '!' -f13 ) # bridge-id SIP/xx-aaaaa channel=$(asterisk -rx 'core show channels concise' | grep $bridge | grep -v SIP/$exten- | cut -d '!' -f1) # channel SIP/provider-000000 result=$(asterisk -rx "channel redirect $channel $context,$num,1") # echo $result exit 0

- , . “” CRM .

? , CRM asterisk . , , .

--, , , .
channel redirect <[[context,]exten,]priority>

AMI:

Action: Redirect
[ActionID:] value
Channel: value
[ExtraChannel:] value
Exten: value
[ExtraExten:] value
Context: value
[ExtraContext:] value
Priority: value
[ExtraPriority:] value>


: , , .

, . bridge show all .

> bridge show all
Bridge-ID Chans Type Technology
14418b64-0635-46e7-bd48-f4b820461eaa 2 basic simple_bridge


bridge show <bridge-id> , .

, bridge-id , bridge-id, :

> core show channels concise
SIP/RT-00000453!incoming!!1!Up!AppDial!(Outgoing Line)!89063448810!!!3!134!14418b64-0635-46e7-bd48-f4b820461eaa!1479984681.1659
SIP/67-00000452!macro-dialout-trunk!s!23!Up!Dial!SIP/RT/89063448810,300,TtL(7200000)!67!!!3!134!14418b64-0635-46e7-bd48-f4b820461eaa!1479984681.1658


, 2 bridge-id(14418b64-0635-46e7-bd48-f4b820461eaa), . . bash-, ( FreePBX 13):

#!/bin/bash context="from-internal" # , exten=$1 # num=$2 # , bridge=$(asterisk -rx 'core show channels concise' | grep SIP/$exten- | cut -d '!' -f13 ) # bridge-id SIP/xx-aaaaa channel=$(asterisk -rx 'core show channels concise' | grep $bridge | grep -v SIP/$exten- | cut -d '!' -f1) # channel SIP/provider-000000 result=$(asterisk -rx "channel redirect $channel $context,$num,1") # echo $result exit 0

- , . “” CRM .

? , CRM asterisk . , , .

--, , , .

Source: https://habr.com/ru/post/316138/


All Articles