Asterisk HowTo's

From AstriPedia

Revision as of 19:35, 30 June 2008; view current revision
←Older revision | Newer revision→
Jump to: navigation, search
--Don.K 06:38, 5 September 2007 (CEST)

Contents

Asterisk Voicemail spool

If you do not want to store your voicemails on your Asterisk PBX server, you can edit voicemail.conf to delete them. However, using a program called Sendmail, you can make Asterisk email your PBX user the new voicemail, and then the voicemail gets deleted off the server. The following option needs to be yes in voicemail.conf

 /etc/asterisk/voicemail.conf

 delete=yes  ; After notification, the voicemail is deleted from the server. [per-mailbox only]
             ; This is intended for use with users who wish to receive their voicemail ONLY by email.

This script to relieve this /bin/delvm, delete every 5 min. voicemail in the vm-spool queue (I'm not sure what this script does, other than maybe check voicemailboxes every 5 minutes, and delete periodically. Please edit in English)

#!/bin/bash
#
# build-in use crontab -e */5 * * * * /bin/delvm
# Autor: Don.K at 6th Nov 2006 
# define here your context, mainly is default cx=default
vmbox=`asterisk -rx "show voicemail users" | grep $cx | awk '{print $2}'`
if [ -e /var/spool/asterisk/voicemail/$cx/$vmbox/INBOX/msg0000.wav ]; then rm /var/spool/asterisk/voicemail/$cx/$vmbox/INBOX/* else exit 0 fi

Call Pickup

In order to be able to take over a call on another telephone, must be registered than first in the configuration features.conf as a pickup extension.

pickupexten = *8

Now we can implement extension the call pickup are with the option callgroup and pickupgroup and the value for the group the calls to take over are in sip.conf for the appropriate telephone registering.

[GXP2000]
type = friend
username = 201
secret = 1234
context = default
dtmfmode = rfc2833
callgroup = 2
pickupgroup = 2
disallow = all
allow=ulaw
allow=alaw
allow=g723.1
allow=g729

Feature Application

An Feature Application will most there used where no appropriate button exist on the phone. For instance the Call Transfer on Siemens Gigaset 450C or often other DECT Telephone without Transfer (TRNF) key.

features.conf 
[general]
#include parking_additional.inc #include features_general_custom.conf
featuredigittimeout => 1000 ; Max time (ms) between digits for
[applicationmap]
#include features_applicationmap_additional.conf
[featuremap]
blindxfer => ## ; Blind Transfer atxfer => **  ; Attended Xfer automon => *1  ; One Touch Record

Re-dialing on Asterisk

If your telephone does not offer a redial feature, the following example can be used to re-dial the last number by dialing *5. The following example fits into extensions.conf

[default]
include => macro-recall 
exten => _X.,1,Macro(recall,${EXTEN}) exten => *5,1,DBget(toCall=redial/${CALLERID}) exten => *5,2,Macro(recall,${toCall}) exten => *5,102,Hangup()
[macro-recall] exten => s,1,DBput(redial/${CALLERID}=${ARG1}) exten => s,1,Dial(SIP/${ARG1},20) exten => s,2,Goto(s-${DIALSTATUS},1) exten => s-NOANSWER,1,Voicemail(u${ARG1}) exten => s-BUSY,1,Voicemail(b${ARG1}) exten => _s-.,1,Goto(s-NOANSWER,1)

Asterisk GSM Soundformat

Sound files made on Windows are usually wave files. These wave files cannot be read and processed by Asterisk, so we will have to change these wave files into an Asterisk-compatible format, such as GSM. Using a software called SOX, we can do so. The following example shows how to convert foo.wav into foo.gsm using SOX.

sox foo.wav -r 8000 -c1 foo.gsm resample -ql

The converted gsm sound files after copy /var/lib/asterisk/sounds/custom there are asterisk compatible wave formats

sox wav_file.wav gsm_file.gsm
sox gsm_file.gsm wav_file.wav
sox unnow_wav_file.wav asterisk_wav_file.wav

Call forwarding

This implementation allow Call forwarding by using dial *72*nnnnnn#, n is the number where the call to forward

exten => _*72*.,1,Answer()
exten => _*72*.,2,Set(DB(CFI/${CALLERID(NUM)})=${EXTEN:4})
exten => _*72*.,n,Playback(vm-saved)
exten => _*72*.,n,SayDigits(${EXTEN:4})
exten => _*72*.,n,Hangup()

Disallow Call forwarding by using dial #73#

exten => #73#,1,Answer()
exten => #73#,n,DBdel(CFI/${CALLERID(num)})
exten => #73#,n,Playback(call-fwd-cancelled)
exten => #73#,n,Hangup()

This will need the macro insert into the appropriate extension, like extension 200

[200]
exten => 200,1,Macro,callforwarding|${EXTEN}
exten => 200,n,Dial(SIP/202,30,mt)
exten => 200,n,Hangup()

insert macro-callforwarding into extensions.conf above the default context and below general section

[macro-callforwarding]
exten => s,1,Set(temp=${DB(CFI/${ARG1})})
exten => s,n,GotoIf(${temp}?cfi:nocfi)
exten => s,n(cfi),Dial(SIP/${temp})
exten => s,n(nocfi),NoOp

Note, if your phone may don't understood the pound key (#) like Grandstream, then apply another char for instance (*) or only numbers

Asterisk Ringtone identification

An Asterisk macro using ringtone identification. In companies, it makes sense to detect the distinction between an internal and an external call.

That provide the following Macro, which in is entered in the configuration file extensions.conf, on FreePBX this is the file extensions_custom.conf.

In this example with SIPAddHeader, this is here for "global" settings, for all external calls now sounds a different tone, the first command generates an additional 0 (Zero) to add automatically a valid prefix for outgoing dial number while call externally.

[macro-exten_did_prefix] 
exten => s,1,Set(CALLERID(num)=0${CALLERID(num)}) exten => s,1,Set(CALLERID(num)=${CALLERID(num)}) exten => s,n,SIPAddHeader("Alert-Info: <http://127.0.0.1>\;info=alert-external\;x-line-id=0;")
Personal tools