0

I have an SIP Trunk on my Asterisk box. So my Asterisk box has one public number and 100 internal numbers.

external number: 0030XXXXXXXX internal numbers: 2000, 2001, 2002, 2003 ... and so on

I would want to create a kind of menu on the external number. So when a user dials the external number, they can hear a sound playing: "please enter a number and close with a hashtag" And when that number is entered, it calls the entered number.

For example, I dial 0030XXXXXXX (my external number) then Asterisk plays a sound file and asks for a number. I want to dial 2000, and I enter 2000# and 2000 will go ringing.

I tried the WaitExten and Read, but I can't get it to work. I hope some of you can help me out.

Thank you in advance.

1 Answer 1

0

In future, please at least post a sample of the code you've tried so that we can see what you're trying to do. It helps us understand your objectives.

That said, give this a try. Please understand this is untested code I pretty much wrote while having my morning coffee. You will need to alter it to suit your needs / make it work.

I am being pedantic with the way I formatted the "Read" command, but the idea is for you to understand how this is set up. I actually tend to write my production code this way, simply so that it is closer to "self documenting".

[auto_attendant]
  exten => _0030XXXXXXXX,1, Verbose(2, -- New Call For Auto-Attendant)
   same => n, Verbose(2, --- configuring environment)
   same => n, Set(my_aa_PromptFile=my_auto_attendant_greeting)
   same => n, Set(my_aa_MaxDigits=4)
   same => n, Set(my_aa_Options=s)
   same => n, Set(my_aa_Attempts=1)
   same => n, Set(my_aa_TimeOut=6)
   same => n, Set(my_aa_MaxExtension=2003)
   same => n, Set(my_aa_CountStrikes=0)

   same => n, Verbose(2, --- handling call)
   same => n, Answer()
   same => n, Playback(silence/1)
   same => n(try_again), Read(var_DTMF,${my_aa_PromptFile},${my_aa_MaxDigits},${my_aa_Options},${my_aa_Attempts},${my_aa_TimeOut})
   same => n, GotoIf($["${var_DTMF}" = ""]?handle_error) 
   same => n, GotoIf($[${var_DTMF} > ${my_aa_MaxExtension}]?handle_error) 
   same => n, Dial(SIP/${var_DTMF},22)
   same => n, Goto(try_again)

   same => n(handle_error), Verbose(2, --- error condition)
   same => n, Playback(my_auto_attendant_invalid_response)
   same => n, Set(my_aa_CountStrikes=$[${my_aa_CountStrikes} + 1])
   same => n, GotoIf($[${my_aa_CountStrikes} < 4 ]?try_again) 
   same => n, Playback(my_auto_attendant_please_try_again_later)
   same => n, Hangup()

Further Reading:

Please Note:

if this answer turns out to solve your problem, please "accept" it for the benefit of others trying to solve the same problem later

2
  • Thank you for your reaction, I'm sorry i didnt upload a sample of my code. I didn't think it was relevant since I tried 10 kinds of things. Will the Read statement standard check if a hashtag "#" is entered, to determine that the user wants to dial that number? Mar 30, 2015 at 14:30
  • Please read the provided documentation. It explains what the Read command does.
    – MichelV69
    Mar 31, 2015 at 12:33

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .