Differences
This shows you the differences between two versions of the page.
Both sides previous revisionPrevious revision | |||
asterisk:voicemail-system [2007/04/03 14:21] – 151.11.128.13 | asterisk:voicemail-system [2011/06/01 11:17] (current) – 92.112.38.13 | ||
---|---|---|---|
Line 1: | Line 1: | ||
+ | ====== Using Asterisk as Voicemail System for OpenSER ====== | ||
+ | |||
+ | This is a tutorial on how to use OpenSER with Asterisk functioning as a voicemail server. | ||
+ | |||
+ | ===== Create the Database Views ===== | ||
+ | |||
+ | First, create the views described in [[asterisk: | ||
+ | |||
+ | ===== Modify Asterisk Codebase ===== | ||
+ | |||
+ | Next, you will need to modify the asterisk code base. This is unfortunate, | ||
+ | |||
+ | In asterisk-1.2.0/ | ||
+ | |||
+ | < | ||
+ | struct ast_vm_user { | ||
+ | char context[AST_MAX_CONTEXT]; | ||
+ | char mailbox[AST_MAX_EXTENSION];/ | ||
+ | char password[80]; | ||
+ | char fullname[80]; | ||
+ | char email[80]; | ||
+ | char pager[80]; | ||
+ | char serveremail[80]; | ||
+ | char mailcmd[160]; | ||
+ | char language[MAX_LANGUAGE]; | ||
+ | char zonetag[80]; | ||
+ | char callback[80]; | ||
+ | char dialout[80]; | ||
+ | char uniqueid[128]; | ||
+ | char exit[80]; | ||
+ | unsigned int flags; | ||
+ | int saydurationm; | ||
+ | int maxmsg; | ||
+ | struct ast_vm_user *next; | ||
+ | }; | ||
+ | </ | ||
+ | |||
+ | ===== Install Asterisk Add-ons ===== | ||
+ | |||
+ | Now, download the latest Asterisk addons package from the website. Compile and install both asterisk packages. | ||
+ | |||
+ | ===== Configure Asterisk Realtime ===== | ||
+ | |||
+ | Now, it is time to specify where Asterisk should look for its realtime data. In / | ||
+ | |||
+ | < | ||
+ | [settings] | ||
+ | sipusers => mysql, | ||
+ | sippeers => mysql, | ||
+ | voicemail => mysql, | ||
+ | </ | ||
+ | |||
+ | Now you will need to specify how to connect asterisk. In / | ||
+ | |||
+ | < | ||
+ | [general] | ||
+ | dbhost = localhost | ||
+ | dbname = asterisk | ||
+ | dbuser = asterisk | ||
+ | dbpass = asterisk | ||
+ | dbport = 3306 | ||
+ | </ | ||
+ | |||
+ | This assumes that the user asterisk@localhost with password asterisk will be allowed to access the asterisk database. The code for adding this user is: < | ||
+ | |||
+ | ===== Configure Asterisk SIP ===== | ||
+ | |||
+ | Allow sip calls in your sip.conf file (/ | ||
+ | |||
+ | < | ||
+ | [general] | ||
+ | context=default ; | ||
+ | allowguest=yes ; | ||
+ | bindport=5060 ; | ||
+ | bindaddr=0.0.0.0 ; | ||
+ | srvlookup=yes ; | ||
+ | ; | ||
+ | ; | ||
+ | ; | ||
+ | ; | ||
+ | autodomain=yes ; | ||
+ | pedantic=yes ; | ||
+ | ; | ||
+ | ; | ||
+ | ; | ||
+ | ; | ||
+ | ; | ||
+ | checkmwi=10 ; | ||
+ | vmexten=default | ||
+ | ; | ||
+ | ; | ||
+ | disallow=all ; | ||
+ | allow=ulaw ; | ||
+ | language=en ; | ||
+ | ; | ||
+ | ;trustrpid = no ; If Remote-Party-ID should be trusted | ||
+ | ;sendrpid = yes ; If Remote-Party-ID should be sent | ||
+ | useragent=Asterisk PBX ; Allows you to change the user agent string | ||
+ | ;dtmfmode = rfc2833 ; Set default dtmfmode for sending DTMF. Default: rfc2833 | ||
+ | ; Other options: | ||
+ | ; info : SIP INFO messages | ||
+ | ; inband : Inband audio (requires 64 kbit codec -alaw, ulaw) | ||
+ | ; auto : Use rfc2833 if offered, inband otherwise | ||
+ | |||
+ | [openser] | ||
+ | type=friend | ||
+ | context=default | ||
+ | host=localhost | ||
+ | insecure=very | ||
+ | |||
+ | </ | ||
+ | |||
+ | Make sure to substitute the correct host for openser where it says host=localhost, | ||
+ | |||
+ | ===== Configure Voicemail ===== | ||
+ | |||
+ | Edit your voicemail.conf to how you like it. You should remove all default user and other user accounts listed there. | ||
+ | |||
+ | ===== Configure Extensions ===== | ||
+ | |||
+ | This is the equivalent of OpenSER' | ||
+ | |||
+ | < | ||
+ | [general] | ||
+ | static=yes | ||
+ | writeprotect=no | ||
+ | autofallthrough=yes | ||
+ | clearglobalvars=no | ||
+ | priorityjumping=no | ||
+ | |||
+ | [globals] | ||
+ | CONSOLE=Console/ | ||
+ | |||
+ | [default] | ||
+ | exten => _XXXXXXXXXXX, | ||
+ | exten => _XXXXXXXXXXX, | ||
+ | |||
+ | exten => a, | ||
+ | exten => a, | ||
+ | exten => a,3,Hangup | ||
+ | |||
+ | exten => *86, | ||
+ | exten => *86, | ||
+ | </ | ||
+ | |||
+ | |||
+ | |||
+ | |||
+ | ===== Set OpenSER to Route Calls to Voicemail ===== | ||
+ | |||
+ | In your openser.cfg, | ||
+ | |||
+ | < | ||
+ | |||
+ | #tm timeout for voicemail params | ||
+ | modparam(" | ||
+ | modparam(" | ||
+ | modparam(" | ||
+ | |||
+ | # ------------------------- | ||
+ | |||
+ | # main routing logic | ||
+ | #Routing Script | ||
+ | route { | ||
+ | # | ||
+ | if (!mf_process_maxfwd_header(" | ||
+ | { | ||
+ | | ||
+ | | ||
+ | | ||
+ | }; | ||
+ | | ||
+ | # | ||
+ | if (msg:len >= 2048) | ||
+ | { | ||
+ | | ||
+ | | ||
+ | | ||
+ | }; | ||
+ | | ||
+ | # | ||
+ | | ||
+ | { | ||
+ | setflag(1); | ||
+ | | ||
+ | | ||
+ | #do not send to voicemail if BYE or CANCEL | ||
+ | #is used to end call before user pickup or timeout | ||
+ | | ||
+ | { | ||
+ | setflag(10); | ||
+ | }; | ||
+ | |||
+ | # | ||
+ | if (loose_route()) | ||
+ | | ||
+ | | ||
+ | | ||
+ | }; | ||
+ | | ||
+ | # | ||
+ | if (method==" | ||
+ | { | ||
+ | | ||
+ | { | ||
+ | www_challenge(" | ||
+ | return; | ||
+ | } | ||
+ | else | ||
+ | { | ||
+ | if (!check_to()) | ||
+ | { | ||
+ | sl_send_reply(" | ||
+ | return; | ||
+ | }; | ||
+ | |||
+ | #Save into user database, used below when checking if user is available | ||
+ | xlog(" | ||
+ | save(" | ||
+ | return; | ||
+ | }; | ||
+ | }; | ||
+ | | ||
+ | if (method==" | ||
+ | { | ||
+ | if(uri=~" | ||
+ | { | ||
+ | # | ||
+ | | ||
+ | { | ||
+ | proxy_challenge(" | ||
+ | return; | ||
+ | }; | ||
+ | |||
+ | | ||
+ | | ||
+ | } | ||
+ | else | ||
+ | { | ||
+ | if (does_uri_exist()) | ||
+ | { | ||
+ | #Call is to sip client, so do nothing but route | ||
+ | xlog(" | ||
+ | if (!lookup(" | ||
+ | { | ||
+ | | ||
+ | | ||
+ | | ||
+ | }; | ||
+ | } | ||
+ | else | ||
+ | { | ||
+ | #authorize if a call is going to PSTN | ||
+ | if(!proxy_authorize(" | ||
+ | { | ||
+ | | ||
+ | | ||
+ | }; | ||
+ | |||
+ | #Call destination is PSTN, so send it to the gateway (Net.com) | ||
+ | xlog(" | ||
+ | rewritehostport(" | ||
+ | }; | ||
+ | }; | ||
+ | |||
+ | #Make sure that all subsequent requests go through us; | ||
+ | record_route(); | ||
+ | } | ||
+ | else | ||
+ | { | ||
+ | if (does_uri_exist()) | ||
+ | { | ||
+ | #Call is to sip client, so do nothing but route | ||
+ | | ||
+ | if (!lookup(" | ||
+ | { | ||
+ | sl_send_reply(" | ||
+ | log(1, " | ||
+ | return; | ||
+ | }; | ||
+ | } | ||
+ | else | ||
+ | { | ||
+ | #Call destination is PSTN, so send it to the gateway (Net.com) | ||
+ | | ||
+ | | ||
+ | }; | ||
+ | record_route(); | ||
+ | }; | ||
+ | |||
+ | #ALL PROCESSING IS DONE, SO ROUTE | ||
+ | | ||
+ | } | ||
+ | |||
+ | |||
+ | route[1] | ||
+ | { | ||
+ | #send the call outward | ||
+ | |||
+ | | ||
+ | { | ||
+ | t_on_failure(" | ||
+ | }; | ||
+ | |||
+ | if (!t_relay()) | ||
+ | { | ||
+ | xlog(" | ||
+ | sl_reply_error(); | ||
+ | }; | ||
+ | |||
+ | } | ||
+ | |||
+ | failure_route[2] | ||
+ | { | ||
+ | | ||
+ | { | ||
+ | revert_uri(); | ||
+ | rewritehostport(" | ||
+ | append_branch(); | ||
+ | #PREVENT SOME CRAZY VOICEMAIL LOOP | ||
+ | xlog(" | ||
+ | setflag(10); | ||
+ | route(1); | ||
+ | } | ||
+ | } | ||
+ | </ | ||
+ | |||
+ | You can contact me at mikebwilliams@gmail.com | ||
+ | |||
+ | Good Luck! | ||
+ | |||
+ | [[http:// | ||