Dialplans in Asterisk on Linux




These Dialplan very usefull only for beginners

These dial plan must be write in short lines but i am writing here for bigenners.Because in initial we don't know short cuts by which we can make short dialplan for same recquirement...


****************************************
***CHECK FOR NO OF ATTEMPTS FOR A*******
******PERTICULAR PHONE NO***************
****************************************

[sharjeel]
exten=>_X.,1,Answer()
exten=>_X.,2,Read(var,english_prompt/enterphoneno,10)
exten=>_X.,3,Set(count=${DB(test/${var})})
exten=>_X.,4,GotoIf($[${ISNULL(${count})}]?:7)
exten=>_X.,5,Set(DB(test/${var})=1)
exten=>_X.,6,GoTo(3)
exten=>_X.,7,GotoIf($[${count}<3]?:12)
exten=>_X.,8,SayDigits(${count})
exten=>_X.,9,Set(count=$[${count}+1])
exten=>_X.,10,Set(DB(test/${var})=${count})
exten=>_X.,11,GoTo(13)
exten=>_X.,12,Playback(english_prompt/invalid)
exten=>_X.,13,Hangup()

*******************************************************************************************QUIZ WITHOUT  DATABASE*********************************************
*******************************************************************************************
*1-In This quiz first enter your phone no.(Then programme chek validation of phone no)*****
*2-Enter 3 Digit code.(Then programme chek validation of code)*****************************
*3-Play individual point and total point of entered code by user***************************
*******************************************************************************************

[sharjeel]
exten=>123,1,Answer()
exten=>123,2,Playback(english_prompt/welcome)
exten=>123,3,Set(count=1)
exten=>123,4,Playback(english_prompt/language)
exten=>123,5,Read(var,,1)
exten=>123,6,Set(count=$[${count}+1])
exten=>123,7,GotoIf($[${count}<=4]?:14)
exten=>123,8,GotoIf($[${var}=1]?:10)
exten=>123,9,GoTo(english,s,1)
exten=>123,10,GotoIf($[${var}=2]?:12)
exten=>123,11,GoTo(hindi,s,1)
exten=>123,12,Playback(english_prompt/invalid)
exten=>123,13,GoTo(4)
exten=>123,14,Hangup()



[english]
exten=>s,1,Set(count=1)
exten=>s,2,Set(cnt=1)
exten=>s,3,Playback(english_prompt/enterphoneno)    ;Please enter your phone no
exten=>s,4,Set(count=$[${count}+1])
exten=>s,5,GotoIf($[${count}<=4]?:37)
exten=>s,6,Read(var,,10)
exten=>s,7,Playback(english_prompt/phonenois)        ;Play Entered Phone no
exten=>s,8,Saydigits(${var})
exten=>s,9,Set(a=${LEN(${var})})            ;Check Dialed Digit
exten=>s,10,GotoIf($[${a}=10]?13:11)
exten=>s,11,Playback(english_prompt/notdial)        ;You have dialed invalid digit
exten=>s,12,GoTo(3)
exten=>s,13,Playback(english_prompt/confirmphoneno)  ;press1 to correct 2 to re enter for confermation of phone no
exten=>s,14,Read(var,,1)
exten=>s,15,GotoIf($[${var}=1]?16:3)
exten=>s,16,Set(cnt=$[${cnt}+1])
exten=>s,17,GotoIf($[${cnt}<=4]?:37)
exten=>s,18,Playback(english_prompt/enterpoint)  ;enter 3 digit code
exten=>s,19,Read(varei,,3)
exten=>s,20,GotoIf($[${varei}=333]?:26)
exten=>s,21,Playback(english_prompt/totalpoint)
exten=>s,22,Set(m=30)
exten=>s,23,Saydigits(${m})
exten=>s,24,Playback(english_prompt/thanx)
exten=>s,25,Hangup()
exten=>s,26,GotoIf($[${varei}=111]?:32)
exten=>s,27,Playback(english_prompt/totalpoint)
exten=>s,28,Set(b=10)
exten=>s,29,Saydigits(${b})
exten=>s,30,Playback(english_prompt/thanx)
exten=>s,31,Hangup()
exten=>s,32,GotoIf($[${varei}=222]?:38)
exten=>s,33,Playback(english_prompt/totalpoint)
exten=>s,34,Set(r=20)
exten=>s,35,Saydigits(${r})
exten=>s,36,Playback(english_prompt/thanx)
exten=>s,37,Hangup()
exten=>s,38,Playback(english_prompt/invalidcode)
exten=>s,39,GoTo(18)



[hindi]
exten=>s,1,Set(count=1)
exten=>s,2,Set(cnt=1)
exten=>s,3,Playback(hindi_prompt/enterphoneno)
exten=>s,4,Set(count=$[${count}+1])
exten=>s,5,GotoIf($[${count}<=4]?:37)
exten=>s,6,Read(var,,10)
exten=>s,7,Playback(hindi_prompt/phonenois)
exten=>s,8,Saydigits(${var})
exten=>s,9,Set(a=${LEN(${var})})
exten=>s,10,GotoIf($[${a}=10]?13:11)
exten=>s,11,Playback(hindi_prompt/notdial)
exten=>s,12,GoTo(3)
exten=>s,13,Playback(hindi_prompt/confirmphoneno)  ;press1 to correct 2 to re enter
exten=>s,14,Read(var,,1)
exten=>s,15,GotoIf($[${var}=1]?16:3)
exten=>s,16,Set(cnt=$[${cnt}+1])
exten=>s,17,GotoIf($[${cnt}<=4]?:37)
exten=>s,18,Playback(hindi_prompt/enterpoint)  ;enter 3 digit code
exten=>s,19,Read(varei,,3)
exten=>s,20,GotoIf($[${varei}=333]?:26)
exten=>s,21,Playback(hindi_prompt/totalpoint)
exten=>s,22,Set(m=30)
exten=>s,23,Saydigits(${m})
exten=>s,24,Playback(hindi_prompt/thanx)
exten=>s,25,Hangup()
exten=>s,26,GotoIf($[${varei}=111]?:32)
exten=>s,27,Playback(hindi_prompt/totalpoint)
exten=>s,28,Set(b=10)
exten=>s,29,Saydigits(${b})
exten=>s,30,Playback(hindi_prompt/thanx)
exten=>s,31,Hangup()
exten=>s,32,GotoIf($[${varei}=222]?:38)
exten=>s,33,Playback(hindi_prompt/totalpoint)
exten=>s,34,Set(r=20)
exten=>s,35,Saydigits(${r})
exten=>s,36,Playback(hindi_prompt/thanx)
exten=>s,37,Hangup()
exten=>s,38,Playback(hindi_prompt/invalidcode)



*********************************************
********QUIZ USING ASTERISK DATABASE*********
*********************************************


[incoming]
exten=>123,1,Answer()
exten=>123,2,Set(path=/sharjeel/project_sharjeel/english_prompt/)
exten=>123,3,Set(h_path=/sharjeel/project_sharjeel/hindi_prompt/)
exten=>123,4,Playback(${path}welcome)
exten=>123,5,Set(count=1)
exten=>123,6,Set(count=$[${count}+1])
exten=>123,7,GotoIf($[${count}<=4]?:81)
exten=>123,8,Read(choice,${path}language,1,,,11)
exten=>123,9,Set(len=${LEN(${choice})})
exten=>123,10,GotoIf($[${len}!=0]?11:80)
exten=>123,11,GotoIf($[${choice}=1]?:14)
exten=>123,12,Set(m_path=${path})
exten=>123,13,GoTo(16)
exten=>123,14,GotoIf($[${choice}=2]?:78)
exten=>123,15,Set(m_path=${h_path})
exten=>123,16,Set(cnt=1)
exten=>123,17,Set(cnt=$[${cnt}+1])
exten=>123,18,GotoIf($[${cnt}<=4]?:81)
exten=>123,19,Read(var,${m_path}/enterphoneno,10,,,11)
exten=>123,20,Set(len=${LEN(${var})})
exten=>123,21,GotoIf($[${len}!=0]?:34)
exten=>123,22,Set(count=${DB(test/${var})})
exten=>123,23,GotoIf($[${ISNULL(${count})}]?:26)
exten=>123,24,Set(DB(test/${var})=1)
exten=>123,25,GoTo(22)
exten=>123,26,GotoIf($[${count}<4]?:81)
exten=>123,27,SayDigits(${count})
exten=>123,28,Set(count=$[${count}+1])
exten=>123,29,Set(DB(test/${var})=${count})
exten=>123,30,Playback(${m_path}phonenois)
exten=>123,31,Saydigits(${var})
exten=>123,32,Set(phone_no_len=${LEN(${var})})
exten=>123,33,GotoIf($[${phone_no_len}=10]?36:34)
exten=>123,34,Playback(${m_path}invalidphoneno)
exten=>123,35,GoTo(17)
exten=>123,36,Set(count=1)
exten=>123,37,Set(count=$[${count}+1])
exten=>123,38,GotoIf($[${count}<=4]?:81)
exten=>123,39,Read(code_no,${m_path}enterpoint,3,,,11)
exten=>123,40,Set(len=${LEN(${count})})
exten=>123,41,GotoIf($[${len}!=0]?:75)
exten=>123,42,GotoIf($[${code_no}=111]?:53)
exten=>123,43,Playback(${m_path}totalpoint)


exten=>123,44,GotoIf($[DB_EXISTS(score/record)]?:49)
exten=>123,45,Set(score_value=DB(score/record))
exten=>123,46,set(score_value=${${score_value}+10})
exten=>123,47,SayDigits(${score_value})
exten=>123,48,GoTo(51)
exten=>123,49,Set(DB(score/record)=10)
exten=>123,50,SayDigits(${DB(score/record)})


exten=>123,51,Playback(${m_path}thanx)
exten=>123,52,GoTo(81)
exten=>123,53,GotoIf($[${code_no}=222]?:64)
exten=>123,54,Playback(${m_path}totalpoint)


exten=>123,55,GotoIf($[DB_EXISTS(score/record)]?:60)
exten=>123,56,Set(score_value=DB(score/record))
exten=>123,57,set(score_value=${${score_value}+20})
exten=>123,58,SayDigits(${score_value})
exten=>123,59,GoTo(62)
exten=>123,60,Set(DB(score/record)=20)
exten=>123,61,SayDigits(${DB(score/record)})


exten=>123,62,Playback(${m_path}thanx)
exten=>123,63,GoTo(81)
exten=>123,64,GotoIf($[${code_no}=333]?:75)
exten=>123,65,Playback(${m_path}totalpoint)


exten=>123,66,GotoIf($[DB_EXISTS(score/record)]?:71)
exten=>123,67,Set(score_value=DB(score/record))
exten=>123,68,set(score_value=${${score_value}+30})
exten=>123,69,SayDigits(${score_value})
exten=>123,70,GoTo(73)
exten=>123,71,Set(DB(score/record)=30)
exten=>123,72,SayDigits(${DB(score/record)})
exten=>123,73,Playback(${m_path}thanx)
exten=>123,74,GoTo(81)
exten=>123,75,Playback(${m_path}invalidcode)
exten=>123,76,GoTo(37)
exten=>123,77,GoTo(81)
exten=>123,78,Playback(${m_path}invalid)
exten=>123,79,GoTo(6)
exten=>123,80,Playback(${m_path}thanx)
exten=>123,81,Hangup()


***************************************
****USING TIME OUT*********************
***************************************
[incoming]
exten=>123,1,Answer()
exten=>123,2,Set(path=/sharjeel/project_sharjeel/english_prompt/)
exten=>123,3,Set(h_path=/sharjeel/project_sharjeel/hindi_prompt/)
exten=>123,4,Playback(${path}welcome)
exten=>123,5,Set(count=1)
exten=>123,6,Set(count=$[${count}+1])
exten=>123,7,GotoIf($[${count}<=4]?:19)
exten=>123,8,Set(TIMEOUT(response)=11)
exten=>123,9,Read(choice,${path}language,1)
exten=>123,10,Set(len=${LEN(${choice})})
exten=>123,11,noop(${len})
exten=>123,12,GotoIf($[${len}!=0]?13:19)
exten=>123,13,GotoIf($[${choice}=1]?:16)
exten=>123,14,Set(m_path=${path})
exten=>123,15,GoTo(17)
exten=>123,16,GotoIf($[${choice}=2]?:18)
exten=>123,17,Set(m_path=${h_path})
exten=>123,18,Playback(hello-world)
exten=>123,19,Hangup()

**********************************************
*************TIME OUT WITHOUT USING***********
************USING TIME OUT FUN****************
**********************************************


[incoming]
exten=>123,1,Answer()
exten=>123,2,Set(path=/sharjeel/project_sharjeel/english_prompt/)
exten=>123,3,Set(h_path=/sharjeel/project_sharjeel/hindi_prompt/)
exten=>123,4,Playback(${path}welcome)
exten=>123,5,Set(count=1)
exten=>123,6,Set(count=$[${count}+1])
exten=>123,7,GotoIf($[${count}<=4]?:18)
;exten=>123,8,Set(TIMEOUT(response)=11)
exten=>123,8,Read(choice,${path}language,1,,,11)
exten=>123,9,Set(len=${LEN(${choice})})
exten=>123,10,noop(${len})
exten=>123,11,GotoIf($[${len}!=0]?12:18)
exten=>123,12,GotoIf($[${choice}=1]?:15)
exten=>123,13,Set(m_path=${path})
exten=>123,14,GoTo(17)
exten=>123,15,GotoIf($[${choice}=2]?:17)
exten=>123,16,Set(m_path=${h_path})
exten=>123,17,Playback(hello-world)
exten=>123,18,Hangup()

exten=>s,39,GoTo(18)



Happy Learning!!!

Comments

Popular posts from this blog

Error : DependencyManagement.dependencies.dependency.(groupId:artifactId:type:classifier)' must be unique: com.adobe.aem:uber-jar:jar:apis -> version 6.3.0 vs 6.4.0

Operators in Asterisk with Linux

ERROR Exception while handling event Sitecore.Eventing.Remote.PublishEndRemoteEventException: System.AggregateExceptionMessage: One or more exceptions occurred while processing the subscribers to the 'publish:end:remote'