Telecom

Asterisk Dialplan: Another Context Outgoing Call (Latest Versions)

MYLINEHUB Team • 2026-02-10 • 9 min

Updated guide for modern Asterisk (PJSIP era): another context outgoing call with real configs, common mistakes, and troubleshooting steps.

Asterisk Dialplan: Another Context Outgoing Call (Latest Versions)

In real Asterisk deployments, outbound calling is rarely handled inside the same dialplan context as internal extensions.

Instead, production systems route outgoing calls through a separate context dedicated to trunk access, permissions, number formatting, and security control.

This guide explains how to place outbound dialing in another context using modern Asterisk with PJSIP, along with real-world best practices used in call centers.

Why Use a Separate Context for Outgoing Calls

  • Prevents unauthorized trunk access
  • Allows number normalization before dialing
  • Applies per-user dialing permissions
  • Improves security and audit control

Mixing inbound, internal, and outbound logic in one context is a common beginner mistake that creates security risks.

Typical Dialplan Architecture in Production

  • from-internal → extensions and features
  • from-trunk → inbound provider calls
  • outbound → trunk dialing rules

Internal users are allowed to access the outbound context only through controlled routing.

Step 1 — Create the Outbound Context

[outbound]
; Dial 10-digit mobile numbers via trunk
exten => _9XXXXXXXXX,1,NoOp(Outbound call to ${EXTEN})
 same => n,Set(NUMBER=${EXTEN:1})
 same => n,Dial(PJSIP/${NUMBER}@mytrunk,60)
 same => n,Hangup()

Explanation:

  • User dials 9 + number (for example: 99876543210)
  • Dialplan strips prefix 9
  • Routes call through PJSIP trunk

Step 2 — Allow Internal Context to Reach Outbound Context

Internal extensions usually live in:

[from-internal]

To allow outbound dialing safely:

[from-internal]
include => outbound

This keeps logic separated while still enabling access.

Step 3 — Restrict Outgoing Access by Extension

Not all users should call outside numbers.

Create a limited context:

[from-internal-limited]
exten => _9XXXXXXXXX,1,Playback(not-authorized)
 same => n,Hangup()

Assign restricted users in PJSIP:

[2001]
type=endpoint
context=from-internal-limited
...

This is essential for:

  • Preventing toll fraud
  • Controlling call costs
  • Implementing user roles

Step 4 — Format Numbers Before Sending to Provider

Providers often require:

  • Country code
  • No leading zero
  • E.164 format

Example conversion:

exten => _0XXXXXXXXX,1,Set(NUMBER=91${EXTEN:1})
 same => n,Dial(PJSIP/${NUMBER}@mytrunk,60)

This converts 09876543210 → 919876543210.

Step 5 — Handle Failed Outbound Calls

Always check:

${DIALSTATUS}
exten => _9XXXXXXXXX,1,Dial(PJSIP/${EXTEN:1}@mytrunk,60)
 same => n,GotoIf($["${DIALSTATUS}"="BUSY"]?busy)
 same => n,GotoIf($["${DIALSTATUS}"="NOANSWER"]?noanswer)
 same => n,Hangup()

 same => n(busy),Playback(line-busy)
 same => n,Hangup()

 same => n(noanswer),Playback(no-answer)
 same => n,Hangup()

Security Best Practices for Outgoing Contexts

  • Never expose trunk dialing directly in from-trunk
  • Require prefix (like 9) before external dialing
  • Limit dialing patterns (avoid international unless needed)
  • Restrict contexts per user role
  • Monitor unusual call activity

Most telecom fraud happens due to poor outbound context isolation.

Debugging Outgoing Call Routing

Use Asterisk CLI:

asterisk -rvvv
pjsip set logger on
dialplan show outbound

Verify:

  • Call enters correct context
  • Number formatting is correct
  • Trunk endpoint is reachable

Real-World Outbound Flow Example

[from-internal]
include => outbound

[outbound]
exten => _9XXXXXXXXX,1,NoOp(Calling ${EXTEN})
 same => n,Set(NUMBER=91${EXTEN:1})
 same => n,Dial(PJSIP/${NUMBER}@provider-trunk,60,tT)
 same => n,Playback(call-failed)
 same => n,Hangup()

This simple structure powers enterprise PBX and call center outbound dialing.

Key Takeaway

Separating outbound calls into another dedicated context is essential for security, scalability, and clean architecture.

Proper context design prevents fraud, simplifies troubleshooting, and enables production-grade telecom systems.

Try it

Want to see API-driven CRM + Telecom workflows in action? Try the WhatsApp bot or explore the demos.

💬 Try WhatsApp Bot ▶️ Watch CRM YouTube Demos
Tip: Comment “Try the bot” on our YouTube videos to see automation in action.