[question] extensions.conf

I am a beginner who has only studied Asterisk for 10 days.
I was writing and executing a simple extensions.conf because something was wrong.
I’m posting a question.

Asterisk installed asterisk-18.23.1 on Fedora.

[default]
include => test01

extend => 100, 1, Answer()
same => n, NoOp(READ…)
same => n, Background(/var/lib/asterisk/sounds/ko/1_information)
same => n, NoOp(READ…)
same => n, NoOp(READ…)
same => n, Read(dig,2, 5)
same => n, NoOp(READ…DONE)
same => n, gotoif( $[${dig} == 11] ?100-1:100-2)
same => n, NoOp(n is ${dig})
same => n(100-1), NoOp(mynumber is {NUMBER})
same => n, Hangup()

same => n(100-2), NoOp(mynumber ###### is ${dig})
same => n, Hangup()

exten => 11,1, NoOp(mynumber ###### is ${dig})
same => n, Background(/var/lib/asterisk/sounds/ko/Thank you, skip)
same => n, Hangup()

When you press DTMF while playing 1_information in backgroup,
The next line

same => n, NoOp(READ…)

Shouldn’t it be executed?

On cli
*CLI> == Using SIP RTP CoS mark 5

0x7faf280084a0 – Strict RTP learning after remote address set to: 172.30.1.70:57369
– Executing [100@default:1] Answer(“SIP/9001-00000002”, “”) in new stack
0x7faf280084a0 – Strict RTP switching to RTP target address 172.30.1.70:57369 as source
– Executing [100@default:2] NoOp(“SIP/9001-00000002”, “READ…”) in new stack
– Executing [100@default:3] BackGround(“SIP/9001-00000002”, “/var/lib/asterisk/sounds/ko/1_information”) in new stack
– <SIP/9001-00000002> Playing ‘/var/lib/asterisk/sounds/ko/1_infromation.slin’ (language ‘en’)
0x7faf280084a0 – Strict RTP learning complete - Locking on source address 172.30.1.70:57369
– Invalid extension ‘12’ in context ‘default’ on SIP/9001-00000002
– Executing [i@default:1] NoOp(“SIP/9001-00000002”, “invalid …”) in new stack
– Executing [i@default:2] Hangup(“SIP/9001-00000002”, “”) in new stack
== Spawn extension (default, i, 2) exited non-zero on ‘SIP/9001-00000002’

It appeared before play, but after play, neither line appears, so I move on to Read and ask a question.

And when you use the Read function, shouldn’t the 2-digit value you pressed be included in the dig value?
If you press 11 in the Read function, it goes to extension 11.
It’s happening and I’m asking for help.
Well then, thank you.

It shouldn’t be executed. If you key DTMF during background, Asterisk should start trying to match an extension number beginning with that digit, and restart the dialplan at that number.

You should use Playback, not Background, if you are going to follow it with Read.

Hi,

I think there is wrong function usage.

Try this.


[default]
include => test01

exten => 100, 1, Answer()
same => n, NoOp(READ digits from user)
same => n, Background(/var/lib/asterisk/sounds/ko/1_information)
same => n, Read(dig,,2)                ; Read up to 2 digits and store in variable 'dig'
same => n, NoOp(READ...DONE)
same => n, NoOp(The entered digit is: ${dig})  ; Print the value of 'dig' before comparison
same => n, GotoIf($[${dig} == 11]?100-1:100-2) ; Branch based on user input
same => n, NoOp(n is ${dig})
same => n(100-1), NoOp(mynumber is 11)
same => n, Hangup()

same => n(100-2), NoOp(mynumber is ${dig})
same => n, Hangup()

exten => 11,1, NoOp(mynumber ###### is ${dig})
same => n, Background(/var/lib/asterisk/sounds/ko/Thank you, skip)
same => n, Hangup()

Thank you.

This might work, but it might also be interpreted as 99, or even 100.

The playback function continues playing even if you press the digit.
do. When I receive a digit during play, I want to stop playing and input the value.

In that case, you need to use WaitExten, but it does not work like Read. Like Background, if it receives a digit, it restarts dialplan execution in a state where it is trying to assemble an extension number from the digits received, and then runs the dialplan from the start of that extension.