1
votes

So I have been trying to learn asterisk with some limited success. Essentially what I would like to do is record both incoming and outgoing calls. However there seems to be a gap in my understanding.

From what I understand, can one of the asterisk gurus confirm that my understanding is either correct or incorrect.

  1. sip.conf and iax.conf is used to register "channels". These channels could be softphones, analog phones or even other devices that connect to my asterisk server.

  2. extensions.conf defines the route for incoming calls into asterisk. Thus I can say if someone calls extension 100 on my asterisk box connect this call to sip device 100 or play the hello-world sample.

I suspect my understanding of extensions might be flawed a little. Here is what I am trying to do. I want to record both incoming and outgoing calls to asterisk no matter what extension. From what I can see you can use the monitor and mixmonitor commands in the dialplan. So my understanding is that you can only specify what happens to incoming calls in the dialplan.

So for example I could possibly record incoming calls to extension 600 by adding the following to my extension.conf

exten => 600,1,Answer()
same => 600,2,Monitor(wav,,m)

I suspect I am making a terribly wrong assumption on how the dialplan works.

Thanks

2

2 Answers

7
votes

incoming & outgoing call can be record via this dial plane

add this line to extensions.conf

**

exten => _!,n,System(mkdir "/var/spool/asterisk/${CALLERID(number)}")
exten => _!,n,Set(FILENAME=CallingTime(${DATETIME})-Called(${EXTEN}))
exten => _!,n,Set(MONITOR_EXEC_ARGS=&& mv "/var/spool/asterisk/monitor/${FILENAME}.wav" "/var/spool/asterisk/${CALLERID(number)}/")
exten => _!,n,Monitor(wav,${FILENAME},mb)
exten => _!,n,Dial(SIP/100,,r)
exten => _!,n,Hangup()

**

0
votes

Right did a lot more research. The dialplan caters for both incoming and outgoing calls. For example you would hook up your external provider via PSTN card for example. This card will connect the call from asterisk to the external network trunk and thus connect you to a external number.

So in your dial plan you would basically say when a external number is dialled pass the call through to the PSTN card and let the card dial the number.

For example define your PSTN Card in the dial plan:

[globals]
LOCAL=DAHDI/G0           ; assuming you have a PSTN card in your system

Then define the external number ranges with expressions in the dialplan

[external]
exten => _NXXNXXXXXX,1,Dial(${LOCAL}/${EXTEN})  ; 10-digit pattern match for NANP

Basically if you dial a number that matches the _NXXNXXXXXX rule the dialplan will then tell the PSTN card to dial the number you just dialled by passing it in the variable ${EXTEN}. This will connect the call to the outside world. At this point you can add another step in the dialplan to start recording.

Here is the thing. When looking at the dialplan stop thinking about incoming and outgoing but as channels and how you connect them.