Asterisk PBX Cookbook

PJSIP Channels

; pjsip.conf

[global]
type=global

[transport-udp]
type=transport
protocol=udp
bind=0.0.0.0

[transport-udp6]
type=transport
protocol=udp
bind=::

[endpoint_internal](!) ; template for extensions
type=endpoint
context=from-internal
disallow=all
allow=speex
allow=g722 ; "HD" codec
allow=ulaw
trust_id_outbound=yes

[auth_userpass](!)
type=auth
auth_type=userpass

[aor_dynamic](!)
type=aor
max_contacts=5

SIP Trunks

; pjsip_wizard.conf
[trunk_defaults](!)
type=wizard
endpoint/transport=transport-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

[pstn-trunk](trunk_defaults)
sends_auth=yes
sends_registrations=no
remote_hosts=voip.telco.com
outbound_auth/username=mysipaccount
outbound_auth/password=mysippassword
endpoint/context=from-pstn
aor/qualify_frequency=60

Extensions

; pjsip.conf

[x1001](endpoint_internal)
auth=x1001
aors=x1001
callerid=Alice <1001>
mailboxes=1001@default ; will send SIP notifications when this mailbox has messages so message light will blink
[x1001](auth_userpass)
username=alice
password=verysecret
[x1001](aor_dynamic)

[x1002](endpoint_internal)
auth=x1002
aors=x1002
callerid=Bob <1002>
mailboxes=1002@default ; will send SIP notifications when this mailbox has messages so message light will blink
[x1002](auth_userpass)
username=bob
password=verysecret
[x1002](aor_dynamic)

Dialplan

Internal Extensions

[from-internal]
exten => 1001,1,Dial(PJSIP/x1001,20)
 same => n,VoiceMail(1001@default,u)
exten => 1002,1,Dial(PJSIP/x1002,20)
 same => n,VoiceMail(1002@default,u)

Trunk Lines

; outside line access from internal extensions
[from-internal]
; NANP 10-digit
exten => _91NXXNXXXXXX,1,Set(CALLERID(all)="My Company" <+12128675309>)
 same => n,Dial(PJSIP/+1${EXTEN:2}@pstn-trunk)
 same => n(end),HangUp()
; E.164 format
exten => _+.,1,Set(CALLERID(all)="My Company" <+12128675309>)
 same => n,Dial(PJSIP/${EXTEN}@pstn-trunk)
 same => n(end),HangUp()
; NANP 7-digit local
exten => _9NXXXXXX,1,Set(CALLERID(all)="My Company" <+12128675309>)
 same => n,Dial(PJSIP/+1212${EXTEN:1}@pstn-trunk)
 same => n(end),HangUp()
; international with 011 prefix
exten => _9011.,1,Set(CALLERID(all)="My Company" <+12128675309>)
 same => n,Dial(PJSIP/1${EXTEN:4}@pstn-trunk)
 same => n(end),HangUp()

Voicemail

exten => 6000,1,Answer()
 same => n,Wait(1)
 same => n,VoiceMailMain(101@default,sa(0))

IVR/Menus

Paging

Call Parking

-- StephenCavilia - 09 Feb 2021
Topic revision: r1 - 09 Feb 2021, StephenCavilia
This site is powered by FoswikiCopyright © by the contributing authors. All material on this collaboration platform is the property of the contributing authors.
Ideas, requests, problems regarding CodenamePending? Send feedback