Mod dialplan asterisk

From FreeSWITCH Wiki
Jump to: navigation, search

Once loaded in modules.conf.xml it can be used in your sofia profile by adding "asterisk" as the dialplan parameter. You can also transfer calls to it by specifying it as the dialplan param in the transfer or execute_extension apps.

It's not entirely like the real asterisk dialplan but it is at least a close familiarity. You cannot include contexts in each other in ours because we do all our dialplan logic before the call.

It's structured in the same way so you can create context default.

[default]
; and you can use comments the same way
; here is a demo that is close to the extensions.conf in tree that installs by default

[default]
; Things you're used to....
exten => music,n,Dial(SIP/1234@conference.freeswitch.org|120)
; similar pattern matching and caller-id match.
exten => _1XXXXX,n,set(cool=${EXTEN})
exten => _1XXXXX,n,set(myvar=true)
exten => _1XXXXX,n,Goto(default|music)
exten => 2137991400/1000,n,Goto(default|music)
; we also embellished things a bit and added some of our own goodies
; Some new magic you can do.... if you start the exten string with a ~ it implies PCRE regex
; *NOTE* the ,n, is there for familiarity purposes we do not parse it anyway nor will we honor line numbers.
exten => ~^(18(0{2}|8{2}|7{2}|6{2})\d{7})$,n,enum($1)
exten => ~^(18(0{2}|8{2}|7{2}|6{2})\d{7})$,n,bridge(${enum_auto_route})  
; instead of exten, put anyting about the call you would rather match on.
; either the names of a field in caller_profile or a string of variables to expand.
caller_id_number => 2137991400,n,Goto(default|music)
${sip_from_user} => bill,n,Goto(default|music)


Anyway you will find the XML dialplan more flexible but this may serve as a stepping stone for beginners.

See Also