📜 ⬆️ ⬇️

Asterisk: Auto-informing the callee before connecting to the operator

Hello!
I decided to share my own experience in some of the features of the work of Dialplan.

This article does not pretend to scientific discoveries, but as a short reference list it may be useful to someone.

Initial data:
Server with Asterisk 1.8, without a web interface, configured as a phone gateway router.
The configuration is set by editing the configuration files in the / etc / asterisk / directory
It is necessary to reproduce the message to the called subscriber, and then notify the caller of his readiness to listen.
Who cares, welcome under cat.

When an incoming call, the caller listens for a greeting and IVR message (this is configured on a large Call Center with a web interface similar to the standard FreePBX), including that the “message is recorded”. There was a need to reproduce the same message when calling from call center operators to subscribers. There is no possibility to add such a function in the web interface, I had to improvise.
')
At the moment, the server with voice gateway functions and plays the message to the called subscribers, if the calling numbers satisfy the specified condition, as well as notifies the caller that you can talk.

A piece of dialplan responsible for the message:

Hidden text
[call-centr-context] etxen => _X.,n,Macro(SayAllCallsRec) [macro-SayAllCallsRec] exten => s,1,NoOp(${CALLERID(num}) exten => s,n,GotoIf($["${CALLERID(num)}" = "123456789"]?say) ; Other numbers here. NO FULL if-then-else! exten => s,n(notsay),NoOp() exten => s,n,Dial(SIP/${MACRO_EXTEN}@TrunkOut,50) exten => s,n,GoTo(end) exten => s,n(say),NoOp() exten => s,n,Set(LIMIT_PLAYAUDIO_CALLER=yes) exten => s,n,Set(LIMIT_PLAYAUDIO_CALLEE=no) exten => s,n,Set(LIMIT_CONNECT_FILE=/var/lib/asterisk/sounds/beep) exten => s,n,Dial(SIP/${MACRO_EXTEN}@TrunkOut,50,L(9999999)A(/var/lib/asterisk/sounds/AllCallsRec)) exten => s,n,Goto(end) exten => s,n(end),NoOp() exten => s,n,HangUp() 

This section of the dialplan is working and tested. You can safely delete all the lines containing NoOp, since they perform only the functions of writing to the console log.

Now go through some areas.
In the context that the Call-center trunk belongs to, the general extension “For any number” (_X.) Sends a call to the macro, where it happens:
- Check on the "white list".
- raising the tube,
- Reproduction KPV,
- Message to the callee
- Message to the caller.
Unfortunately, the bug (or feature) ( proof ) described back in 2007 with a non-simultaneous message of the file “LIMIT_CONNECT_FILE” still exists in version 1.8, and there is no possibility to update the server.
Thus, if you try to notify both participants in a call using the LIMIT_PLAYAUDIO_CALLER = yes, LIMIT_PLAYAUDIO_CALLEE = yes flags, the message will be played sequentially. First - to subscriber B, then - to subscriber A, and the other subscriber will have silence at this moment.

Now let's look at the dialplan. Let's start with the call command, as the longest.
Dial (SIP / $ {MACRO_EXTEN} @TrunkOut - The call will be sent with the number sent to the macro on the trunk "TrunkOut"
, 50 - We will wait for a response up to 50 seconds
, L (9999999) - connection time limit in milliseconds (not required, but there is no other way to tell the caller that the callee heard the “greeting”.
A (path-to-file) - message to the callee

exten => s, n, Set (LIMIT_PLAYAUDIO_CALLER = yes) - Play caller
exten => s, n, Set (LIMIT_PLAYAUDIO_CALLEE = no) - Play callable
exten => s, n, Set (LIMIT_CONNECT_FILE = / var / lib / asterisk / sounds / beep) - Path to the file to be played.

The variables set just above determine to whom the beep sound will be played. In our case, the one who calls FROM Call-center.

And, actually, what the call itself looks like in steps:
Call Center subscriber dials the number. The call comes to the Asterisk gateway. The call falls into the macro. Number A is compared with the list. In case of a mismatch, the call goes without additional keys. In case of a match, the keys are added to the call.
Subscriber B picks up the phone, listens to the message (Key A ()). At this point, subscriber A will have silence (after long beeps). When the message is finished, subscriber A will hear a sound from the beep.gsm file (must be in the / var / lib / asterisk / sounds / directory). For what reason in the gsm format it is not clear. And only after that, the channels will be connected.

Also, you can replace the silence for subscriber A with dial tone. To do this, change the lines:
 exten => s,n(say),NoOp() exten => s,n,Answer() exten => s,n,Playtones(420) exten => s,n,Set(LIMIT_PLAYAUDIO_CALLER=yes) exten => s,n,Set(LIMIT_PLAYAUDIO_CALLEE=no) exten => s,n,Set(LIMIT_CONNECT_FILE=/var/lib/asterisk/sounds/beep) exten => s,n,Dial(SIP/${MACRO_EXTEN}@TrunkOut,50,L(9999999)A(/var/lib/asterisk/sounds/AllCallsRec)) 

Added Answer () - the channel is collected, and Playtones () - the CPV is played. In this case, the caller will receive the signals generated by the Asterisk-gateway.
Unfortunately, in this case, the RTP messages before the connection from the upstream servers will be replaced with beeps. For example, a message without an answer “Subscriber cannot be called” from cellular and the like, which actually do not lead to the creation of a channel (answer 200 - OK) will be ignored, and the caller will receive a sound of the form (long beeps, long beeps, short beeps. ..), but there will be no silence.

Also, you can add the key r to the Dial () - the generation of the system keywave, but it will be selected from the system sounds and will (most often) be very different from the classic ring back tone.

That's all. I hope the note will help someone else save a day or two, trying to get the gateway to perform the necessary sequence of actions.

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


All Articles