ASTERISK BASICS

ASTERISK ON DIGIUM CARD:

A). Starting Asterisk Server:
1).Starting Dahdi.
/etc/init.d/dahdi start
2).Starting Asterisk.
asterisk

B). Restarting Asterisk server:
1). Go to Asterisk Server.
asterisk -vvvvr
2). Type Command to stop asterisk.
core stop gracfully
3). Stopping Dahdi
/etc/init.d/dahdi stop
4). Starting Dahdi
/etc/init.d/dahdi start
5). Starting Asterisk
asterisk

C).Whenever  want to change in script in called Dialplan fallow instructions:
1). Script in file /ets/asterisk/extensions.conf is known as dialplan to make changes in a ivr script using this file. Fiest open thi file
2). to open the file extensions.conf use command:
vi /etc/asterisk/extension.conf
3). Press i for insert mode to edit the file the  Press ESC key for command mode if want to exit from vi editor by saving file use wq command and you won't save file use q! command.

4). Go to Asteris Server (CLI MODE)
asterisk -vvvvvvr
5). Use command if there is any changes made in extension.conf
dialplan relode
6). Exiting from CLI mode use command.
exit

D). Making a simple incoming script writing code in dial plan Suppose context set for all incoming calls is wrms and the numbers are 2592918 and 2592918. Now Go to the /etc/asterisk/extensions.conf using vi editor by using command "vi" on terminal in instert mode (Press i for insert mode)


1). Now look for the context wrms which inclosed within brackect "[", "]" then go write code like below.
[wrms]
exten => _2918,1,Wait(1)
exten => _2918,n,Answer()
exten => _2918,n,Background(/var/www/sample/medium_selection)
exten => _2918,n,Hangup()

exten => _2919,1,Wait(1)
exten => _2919,n,Answer()
exten => _2919,n,Background(/var/www/sample/song_selection)
exten => _2919,n,Hangup()

NOTE: * Save this file by going in to command  mode by pressing "ESC" Key type wq.
** Relode dialplan as mentioned abovein POINT "C"
*** If you want add add new ivr for new number change the number in place of 2919 and choose new file name in Background function with complete path and relode the dialplan again hence you can add several number and sevral IVR's using dialplan.


E). For making an IVR Script some necessary and useful steps!
1). Properties of standard Speech over telephony are 8Bit, 8KHz, Mono channle.
to convert a wav audio file in to desired speech wav aor gsm file use command

sox input.wav -r 8000 -c 1  ouput.wav
or
sox input.wav -r 8000 -c 1 output.gsm

2).  To conver a mp3 file in to wav
mp3123 -w output.wav input.wav


3). To do a operation on a directory including all subdirectories on a samle type file use following command

export IFS=$'\n';for filename in $(find -type f -iname '*.filetype' |sed 's!\.filetype$!!');do " command to perform any operation on the fime filename and file type";done

Example: 1st for operation on wav to convert wav's in to desired wav's and 2nd for operation on mp3 to convert all mp3's files in to wav

export IFS=$'\n';for song in $(find -type f -iname '*.wav'|sed's!\.wav$!!');do sox "$song.wav" -r 8000 -c 1 "$song.gsm";done

export IFS=$'\n';for song in $(find -type f -iname '*.mp3' |sed 's!\.mp3$!!');do mpg123 -w "$song.wav" "$song.mp3";done


F). Making Outgoing calls on Asterisk.
1). Go to server login in to asterisk sever
2). Give command
asterisk -vvvr
3). A CLI mode will start displaying GIVE originate "Dahdi/g1/09307436389  extension demo@default"    .And hit the Enter key now call will originated to client's mobile.
Dahdi/g1/09307436389  extension demo@default  
4). For exiting from CLI mode give command "exit"
exit

NOTE: * You can change clients mobile number by changing mobile number in originate command .
** Ignore double quotes (" ") While giving command on CLI.

"OR USE ALTERNET"

1). Go to /var/spool/asterisk/outgoing_done/
cd /var/spool/asterisk/outgoing_done/
2). Go to vi editor make a file sample.call
vi sample.call
3). Write code going through insert mode (To do this Press "i")
Channel: Dahdi/g1/09307436389
MaxRetries: 1
RetryTime: 60
WaitTime: 30
Context: wrms
Extension: 2918
Priority: 2
Archive: Yes
4). Use command to initiate outgoing call
mv sample.call /var/spool/asterisk/outgoing/
*This How you can make outgoing call.