Asterisk Newbee Guide and Cookbook
Finally A Guide Full of Quicklinks for New Asterisk Users
As a newbie to Asterisk, if you don't have one of the new web interfaces such as FreePbx, and are just going to edit the config files. Then here are some things you should know. First thing is to know that the configuration directory is /etc/asterisk and the files are extensions.conf and other .conf files.
Dial Rules to Record Prompts
https://www.voip-info.org/asterisk-cmd-record/Voicemail to Email Guide
https://jonathanmanning.com/2011/07/15/how-to-configure-asterisk-to-send-voicemail-email-via-gmail-smtp-guide/CA Bundles
https://raw.githubusercontent.com/bagder/ca-bundle/master/ca-bundle.crtMy Dialplan Cookbook
The first thing to know about Asterisk is the dialplan. You can find this in /etc/extensions.conf. Here you define your Direct Inbound Dial (DID) and system extensions. Here are some of my cookbook examples. To hear them, call this number +19495410155 and +19495410169 and speak with Lenny.
The While Loop - an Example
in extensions.conf, this is a while loop that will count from 1 to 8, and read the numbers to the caller. This will be heard by callers to +19495410155
[from-pstn]
exten => _+19495410155,1,Answer(500)
same => 1,Log(DEBUG,Calling in 0155 ${EXTEN})
same => n,Answer
same => n,Set(i=1)
same => n,While($[${i} < 9])
same => n,SayNumber(${i})
same => n,Set(i=$[${i} + 1])
same => n,EndWhile
The Auto-Attendant Featuring the Voice of Lenny
Callers to +19495410169 will hear "Hello This is Lenny" followed by music on hold. Press 5 to hear Lenny again. Option 5 is a Lenny loop that will play thru all 16 of the Lenny recordings, while recording the call. Lenny will Detect the caller's voice and speak after the caller is done speaking.
exten => _+19495410169,1,Answer(500)
same => n,Log(DEBUG,Calling in 0155 ${EXTEN})
same => n(loop),Background(Lenny/Lenny1)
same => n,WaitExten(300,m)
exten => 0,1,Dial(PJSIP/1001,10)
same => n,VoiceMail(1001@default)
same => n,Hangup
exten => 1,1,Playback(you-entered)
same => n,SayNumber(1)
same => n,Goto(s,loop)
exten => 2,1,Playback(you-entered)
same => n,SayNumber(2)
same => n,Goto(s,loop)
exten => 3,1,Playback(you-entered)
same => n,SayNumber(3)
same => n,VoiceMailMain(${mbx}) ; If they press *, send the user into VoicemailMain
same => n,Return()
exten => 4,1,Dial(PJSIP/2001)
same => n,VoiceMail(1001@default)
same => n,Hangup
exten => 5,1,Set(i=${IF($["0${i}"="016"]?7:$[0${i}+1])})
same => n,ExecIf($[${i}=1]?MixMonitor(${UNIQUEID}.wav))
same => n,Playback(Lenny/Lenny${i})
same => n,BackgroundDetect(Lenny/backgroundnoise,1500)
The Lenny Context for Asterisk
This is the Lenny context that everyone uses. It is a very compact and complex loop that is known to work properly. It records the calls. too
[Lenny]
exten => talk,1,Set(i=${IF($["0${i}"="016"]?7:$[0${i}+1])})
same => n,ExecIf($[${i}=1]?MixMonitor(${UNIQUEID}.wav))
same => n,Playback(Lenny/Lenny${i})
same => n,BackgroundDetect(Lenny/backgroundnoise,1500)
Lenny Answer Bot Loop
This is a complete Lenny Answer bot loop that keep you callers entertained for an infinite amount of time.
[from-pstn]
exten => _+19495410155,1,Answer(500)
same => 1,Log(DEBUG,Calling in 0155 ${EXTEN})
same => n,Answer
same => n,Set(i=1)
same => n,While($[${i} < 7])
same => n,Playback(Lenny/Lenny${i})
same => n,BackgroundDetect(Lenny/backgroundnoise,1500)
same => n,Set(i=$[${i} + 1])
same => n,EndWhile
same => n,Set(i=${RAND(2,15)})
same => n,While($[${i} < 17])
same => n,SayNumber(${i})
same => n,Set(i=${RAND(2,15)})
same => n,EndWhile
same => n,Hangup
SIP Trunk Call Forwarding Dialplan Setup
Here's a scenario. What if you have a SIP trunk service from Twilio and you can get toll free numbers or local numbers and then use their SIP Trunking service to route calls from you assigned numbers to your Asterisk server, then you forward them to another PBX that can route the calls to a call center full of people who can handle the calls? Here's what you need to accomplish that feat. First you need a Twilio SIP trunking service, some Twilio phone numbers and this dialplan below. The dialplan below will answer the call, set the callerID and name, and then dial the call - center using the twilio trunk, this will effectively forward the call, while providing call callerid to the PBX. Line number 6 is a rule that will dial the PJSIP in pjzip_wizard.conf, which will dial +16612723798 then forward the call. In our scenario, this number represents the call center. (in reality, it's the Palmdale, CA automated weather hotline) The number +19495160130 represents the twilio number that will recieve the calls and then forward them. You could use a toll free number in this place as well. Twilio requires that you set the caller ID to be your own assigned number.
in extensions.conf ...
[from-pstn]
....
exten => _+19495160130,1,Answer(500)
same => 1,Log(DEBUG,Calling in 0130 ${EXTEN})
same => n,Answer
same => n,Set(CALLERID(name)=CREDIT-UNION)
same => n,Set(CALLERID(num)=+19495160130)
same => n,Dial(PJSIP/+16612723798@twilio-na-us)
same => n,Hangup
in pjsip_wizard.conf ...
[user_defaults](!)
type=wizard
accepts_registrations = yes
sends_registrations = no
accepts_auth = yes
sends_auth = no
endpoint/context = from-internal
endpoint/tos_audio=ef
endpoint/tos_video=af41
endpoint/cos_audio=5
endpoint/cos_video=4
endpoint/allow = !all,ulaw,alaw,gsm
endpoint/dtmf_mode = rfc4733
endpoint/aggregate_mwi = yes
endpoint/use_avpf = no
endpoint/rtcp_mux = no
endpoint/bundle = no
endpoint/ice_support = no
endpoint/media_use_received_transport = no
endpoint/trust_id_inbound = yes
endpoint/media_encryption = no
endpoint/timers = yes
endpoint/media_encryption_optimistic = no
endpoint/send_pai = yes
endpoint/rtp_symmetric = yes
endpoint/rewrite_contact = yes
endpoint/force_rport = yes
endpoint/language = en
aor/qualify_frequency = 10
...
... (these are the PBX extensions here)
...
[trunk_defaults](!)
type=wizard
endpoint/transport=0.0.0.0-udp
endpoint/allow = !all,ulaw
endpoint/t38_udptl=no
endpoint/t38_udptl_ec=none
endpoint/fax_detect=no
endpoint/trust_id_inbound=no
endpoint/t38_udptl_nat=no
endpoint/direct_media=no
endpoint/rewrite_contact=yes
endpoint/rtp_symmetric=yes
endpoint/dtmf_mode=rfc4733
endpoint/allow_subscribe = no
aor/qualify_frequency = 60
[twilio-na-us](trunk_defaults)
sends_auth = yes
sends_registrations = no
remote_hosts = xxxdnsxxx.pstn.us1.twilio.com
outbound_auth/username = xxxnamexxxx
outbound_auth/password = xxxpasswordxxxxx
endpoint/context = from-pstn
aor/qualify_frequency = 60
Conference Bridges in Asterisk Cookbook
See this first: https://wiki.asterisk.org/wiki/display/AST/ConfBridge
References:
https://blog.acolyer.org/2017/08/28/using-chatbots-against-voicespam-analyzing-lennys-effectiveness/
More Tips
Comments
Post a Comment