Complex dial statement / variable SIP usernames

Does anyone know of a config to allow a pstn caller calling in through the zaptel interface to enter a username or authenticate then be able to make a sip call with what they entered to be used as the sip username?

look into the DISA() application. it will give you a fake dialtone that lets you ‘dial out’ from another context. it will also ask for a code.

try at the cli-
show application disa

I am aware of disa and the authenticate application. My experience tells me that these can authenticate against a password in brackets or in a password file.

The question is how can I get the user to enter anything as a password, then to pass the password to a variable so I can do things with it. Really I just need a command for the user to input a variable.

you’d want the application read(). from the help:


Reads a #-terminated string of digits a certain number of times from the
user in to the given variable.
  filename   -- file to play before reading digits.
  maxdigits  -- maximum acceptable number of digits. Stops reading after
                maxdigits have been entered (without requiring the user to
                press the '#' key).
                Defaults to 0 - no limit - wait for the user press the '#' key.
                Any value below 0 means the same. Max accepted value is 255.
  option     -- may be 'skip' to return immediately if the line is not up,
                or 'noanswer' to read digits even if the line is not up.
  attempts   -- if greater than 1, that many attempts will be made in the
                event no data is entered.
  timeout    -- if greater than 0, that value will override the default timeout.

Read should disconnect if the function fails or errors out.

so you could Read() the password, GotoIf/ExecIf to authenticate them, do whatever else, and then DISA() with the no-password flag to let them dial

hope that helps!

Thanks very much Iron Helix. That looks like it will do the trick.

I have got the read variable to work but my next stimblick block is the dial statement.

I can get the dial statement to work fine in the format of:

exten => _0.,1,Dial(SIP/lvdx/${EXTEN1})

but when I use

exten => _0.,1,Dial(SIP/${uname}:password@lvdx/${EXTEN})
exten => _0.,1,Dial(SIP/${uname}${EXTEN})
exten => _0.,1,Dial(SIP/${uname}:password@${EXTEN})

the call does not connect and I get “No such host” lvdx/[ext no] etc.

Any help would be greatly appreciated.


This should work:

exten => _X.,1,Read(UNAME,enter-username,5,5)
exten => _X.,2,NoOp(${UNAME})
exten => _X.,3,Read(PASS,enter-password,5,5)
exten => _X.,4,NoOp(${PASS})
exten => _X.,5,Dial(SIP/${UNAME/${EXTEN})

This should work, although I had mine in AEL and just converted now.

Thanks yusuf, but on your dial command, it does not tell Asterisk which provider to dial out using?


unless I have completely misunderstand, this small change will work

exten => _X.,1,Read(UNAME,enter-username,5,5)
exten => _X.,2,NoOp(${UNAME})
exten => _X.,3,Read(PASS,enter-password,5,5)
exten => _X.,4,NoOp(${PASS})
exten => _X.,5,Dial(SIP/${UNAME}:${PASS}@${EXTEN})

just ensure that UNAME and PASS are getting printed correcly, then the Dial sting will work.

I have tried exactly what you said before and I get the error ‘No such host’ but when I try it as Dial(SIP/lvdx/${EXTEN}) in this way which does not allow me to select the username it works.