How to get dtmf value in dialplan

I have one dialplan in which I want, if the user presses any key, then the file plays again, but I cannot figure out how to get the dtmf value in the dialplan. this is my dialplan:

 [callme] exten => s,1,Answer exten => s,n,Playback(demo/${FILENAME1}) 

first, how to get the DTMF value, and also, if the user presses any key, then playback should be performed 2 times. But I want to manage all these things with dialplan .

+4
source share
4 answers

Thanks for answering me with the solution, but I get this solution and it works for me ......

 [callme] exten => s,1,Answer exten => s,n,DumpChan() exten => s,n,Playback(sclbrd/welcome) exten => s,n,Wait(2) exten => s,n,Set(i=1) exten => s,n,While($[${i} != 3]) exten => s,n,Playback(sclbrd/${FILENAME1}) exten => s,n,Read(digit|sclbrd/press|1) exten => s,n,Wait(1) exten => s,n,GotoIf($["${digit}x" = "x"]?done:again) exten => s,n(again),Wait(1) exten => s,n,Set(i=$[${i} + 1]) exten => s,n,EndWhile() exten => h,n(done),Wait(1) 
+1
source

You can do this using WaitExten [1]:

 [callme] exten => s,1,Answer exten => s,n,Playback(demo/${FILENAME1}) exten => s,n,WaitExten(3) exten => s,n,Goto(s,1) exten => 1,1,Noop(user pressed 1) exten => 1,n,Goto(however-shall-go-to-when-pressed-1) exten => 2,1,Noop(user pressed 2) exten => 2,n,Goto(however-shall-go-to-when-pressed-2) 

Using extension templates [2]:

 [callme] exten => s,1,Answer exten => s,n,Playback(demo/${FILENAME1}) exten => s,n,WaitExten(3) exten => s,n,Goto(s,1) exten => X,1,Noop(user pressed ${EXTEN}) exten => X,n,Goto(however-shall-go-to-when-pressed-${EXTEN}) 

here is exactly what you requested:

 [callme] exten => s,1,Answer exten => s,n,Playback(demo/${FILENAME1}) exten => s,n,WaitExten(3) exten => s,n,NoOp(going on - no dtmf detectd) exten => X,1,Noop(user pressed ${EXTEN}) exten => X,n,Goto(s,1) 

also pay attention to the background application of the asterisk [3].

LITERATURE:

[1] http://www.voip-info.org/wiki/view/Asterisk+cmd+WaitExten

[2] http://www.voip-info.org/wiki/view/Asterisk+Dialplan+Patterns

[3] http://www.voip-info.org/wiki/view/Asterisk+cmd+BackGround

+2
source

You can also use the Read application. He asks more than once and leads to a much less complex dialplan.

 [test] ;Read(variable[,filename[&filename2[&...]][,maxdigits[,options[,attempts[,timeout]]]]]) exten => s,1,Read(response,file_to_play,3,,4,10) ;will read into response variable,upto 3 digits and ask upto 4 times, timeout 10 sec exten => s,2,GotoIf($[ "${response}" == "123"]?pin_ok,s,1) 

Full details of Read on voip-info.org

+1
source

Here is a simple example context for reading a DTMF value

 [readDTMF] exten => 113,1,Answer() same => n,Read(NUMBER,vm-toenternumber) same => n,Verbose(${NUMBER}) same => n,SayNumber(${NUMBER}) same => n,Hangup() 

Read (variable for the store, readable number, [file name for the game โ€” before reading] [other options])

0
source

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


All Articles