Add SIP Users By Phone

HowTo: Add SIP Users By Phone


I know that this is not the best idea, but in case anyone else has a use for something like this, I'm posting it here in the Wiki.

I all of a sudden had the idea that I could automate adding SIP users, voicemail boxes, and extensions all via an extension on my Asterisk box, entering the info by phone. Handy, yes, necessary, no, secure, likely not. But anyhow, I did it for fun, and in case I am ever in a pinch with no computer access, I can add a new user to my system.

Note that my dialplan has no guarantee, and makes no provisions for already existing accounts - use it at your own risk and use it smartly - add only accounts that you know exist.

You could easily extend this to provide other features for yourself, or make IAX accounts instead of SIP accounts, MeetMe conference rooms, etc. Really, with enough planning, you could do almost *anything* with Asterisk and the System command.

Anyhow, here is my dialplan. I have it set up for extension 200, but you can change this to whatever you like. You should also change the password at priorities 3 and 6 too. You'll also have to change or create the sound files for priorities 4, 5, and 18.


[default]
; Allow addition of new SIP user account, mailbox, and extension
exten => 200,1,Answer
exten => 200,2,Wait(1)
exten => 200,3,Authenticate(111)
exten => 200,4,Read(newuser,admin/enter-new-sip-user)
exten => 200,5,Read(newpass,admin/enter-new-sip-pass)
exten => 200,6,Authenticate(222)
; This makes the voice mail box for the new user
exten => 200,7,System(echo "${newuser} => ${newpass}\,Automated User ${DATETIME}" >> /etc/asterisk/voicemail.conf)
; This adds the extension to dial the new user via a macro
exten => 200,8,System(echo "exten => ${newuser}\,1\,Macro(std-vm-exten\,${newuser}\,SIP/${newuser})" >> /etc/asterisk/extensions.conf)
; This adds the SIP account for the new user (messy!)
exten => 200,9,System(echo "[[${newuser}]" >> /etc/asterisk/sip.conf)
exten => 200,10,System(echo "type=friend" >> /etc/asterisk/sip.conf)
exten => 200,11,System(echo "host=dynamic" >> /etc/asterisk/sip.conf)
exten => 200,12,System(echo "secret=${newpass}" >> /etc/asterisk/sip.conf)
exten => 200,13,System(echo "dtmfmode=rfc2833" >> /etc/asterisk/sip.conf)
exten => 200,14,System(echo "context=default" >> /etc/asterisk/sip.conf)
exten => 200,15,System(echo "mailbbox=${newuser}@default" >> /etc/asterisk/sip.conf)
exten => 200,16,System(echo "callerid=\\"Automated User ${DATETIME}\\" <${newuser}>" >> /etc/asterisk/sip.conf)
exten => 200,17,NoOp(created new sip user/mailbox/exten: $newuser} password: ${newpass})
exten => 200,18,Playback(custom/admin/new-user-created)
exten => 200,19,Hangup


I also have a macro that is used. Basically it's the standard macro, but in case you want it set up the same as I do, here it is:


[macro-std-vm-exten]
exten => s,1,Answer
exten => s,2,Wait(1)
exten => s,3,SetMusicOnHold(default)
exten => s,4,Dial(${ARG2},25)
exten => s,5,Goto(s-${DIALSTATUS},1)
exten => s-NOANSWER,1,Voicemail(u${ARG1})
exten => s-NOANSWER,2,Goto(default,s,1)
exten => s-BUSY,1,Voicemail(b${ARG1})
exten => s-BUSY,2,Goto(default,s,1)
exten => _s-.,1,Goto(s-NOANSWER,1)
exten => a,1,VoicemailMain(${ARG1})


Everything that is written out by this dialplan is written at the end of the extensions.conf, voicemail.conf, and sip.conf, so make sure that at the end of the file, you have the proper contexts defined that you want these new users added to, etc.

It's not fancy, it's not brilliant, but it's here. If someone wanted to use it, there ya go. I don't recommend it in a production environment.

HowTo: Add SIP Users By Phone


I know that this is not the best idea, but in case anyone else has a use for something like this, I'm posting it here in the Wiki.

I all of a sudden had the idea that I could automate adding SIP users, voicemail boxes, and extensions all via an extension on my Asterisk box, entering the info by phone. Handy, yes, necessary, no, secure, likely not. But anyhow, I did it for fun, and in case I am ever in a pinch with no computer access, I can add a new user to my system.

Note that my dialplan has no guarantee, and makes no provisions for already existing accounts - use it at your own risk and use it smartly - add only accounts that you know exist.

You could easily extend this to provide other features for yourself, or make IAX accounts instead of SIP accounts, MeetMe conference rooms, etc. Really, with enough planning, you could do almost *anything* with Asterisk and the System command.

Anyhow, here is my dialplan. I have it set up for extension 200, but you can change this to whatever you like. You should also change the password at priorities 3 and 6 too. You'll also have to change or create the sound files for priorities 4, 5, and 18.


[default]
; Allow addition of new SIP user account, mailbox, and extension
exten => 200,1,Answer
exten => 200,2,Wait(1)
exten => 200,3,Authenticate(111)
exten => 200,4,Read(newuser,admin/enter-new-sip-user)
exten => 200,5,Read(newpass,admin/enter-new-sip-pass)
exten => 200,6,Authenticate(222)
; This makes the voice mail box for the new user
exten => 200,7,System(echo "${newuser} => ${newpass}\,Automated User ${DATETIME}" >> /etc/asterisk/voicemail.conf)
; This adds the extension to dial the new user via a macro
exten => 200,8,System(echo "exten => ${newuser}\,1\,Macro(std-vm-exten\,${newuser}\,SIP/${newuser})" >> /etc/asterisk/extensions.conf)
; This adds the SIP account for the new user (messy!)
exten => 200,9,System(echo "[[${newuser}]" >> /etc/asterisk/sip.conf)
exten => 200,10,System(echo "type=friend" >> /etc/asterisk/sip.conf)
exten => 200,11,System(echo "host=dynamic" >> /etc/asterisk/sip.conf)
exten => 200,12,System(echo "secret=${newpass}" >> /etc/asterisk/sip.conf)
exten => 200,13,System(echo "dtmfmode=rfc2833" >> /etc/asterisk/sip.conf)
exten => 200,14,System(echo "context=default" >> /etc/asterisk/sip.conf)
exten => 200,15,System(echo "mailbbox=${newuser}@default" >> /etc/asterisk/sip.conf)
exten => 200,16,System(echo "callerid=\\"Automated User ${DATETIME}\\" <${newuser}>" >> /etc/asterisk/sip.conf)
exten => 200,17,NoOp(created new sip user/mailbox/exten: $newuser} password: ${newpass})
exten => 200,18,Playback(custom/admin/new-user-created)
exten => 200,19,Hangup


I also have a macro that is used. Basically it's the standard macro, but in case you want it set up the same as I do, here it is:


[macro-std-vm-exten]
exten => s,1,Answer
exten => s,2,Wait(1)
exten => s,3,SetMusicOnHold(default)
exten => s,4,Dial(${ARG2},25)
exten => s,5,Goto(s-${DIALSTATUS},1)
exten => s-NOANSWER,1,Voicemail(u${ARG1})
exten => s-NOANSWER,2,Goto(default,s,1)
exten => s-BUSY,1,Voicemail(b${ARG1})
exten => s-BUSY,2,Goto(default,s,1)
exten => _s-.,1,Goto(s-NOANSWER,1)
exten => a,1,VoicemailMain(${ARG1})


Everything that is written out by this dialplan is written at the end of the extensions.conf, voicemail.conf, and sip.conf, so make sure that at the end of the file, you have the proper contexts defined that you want these new users added to, etc.

It's not fancy, it's not brilliant, but it's here. If someone wanted to use it, there ya go. I don't recommend it in a production environment.
Created by: dolson, Last modification: Thu 04 of Nov, 2010 (05:54 UTC) by admin
Please update this page with new information, just login and click on the "Edit" or "Discussion" tab. Get a free login here: Register Thanks! - Find us on Google+