Inbound and Outbound Extensions


I’ve been reading A LOT everyday all week long. And I can never find the exact answers to my problems. I’ve been to almost all the sites, I have 4 firefox windows open with 15 tabs open per window. All on AGI, TAPI, SAPI, API, Asterisk, Telcos, Asterisk .Net, I really need some help.

  1. What I want to do is when there is an inbound call I want to setup I guess somewhere in the extensions/context to call a FastAGI script. If there is 20 calls I want it to call the same script 20 times simutaneously. What if I run out of bandwidth, what will happen to the calls, they probably wont even get through? And if they do get through I want them to run the same FastAGI script, since there aren’t actual people answering the phones there is no need for a queue, but I don’t know what to do if my bandwidth runs out.

  2. I am making an application that will make outgoing calls through Originate , API, and I want the calls to dial a number (POTS) through a PTSN, and have a different extension/context handle this call, through a different FastAGI script.

a. So I will make one Fast AGI script to take calls, and one to handle outgoing calls. But how to I tell Asterisk to launch different AGI scripts depending if the call is outgoing or incoming?

b. How do I handle calls that are beyond my bandwidth?

c. How can I tell it not to run a queue but just to run the same FastAGI script?

I haven’t done anything to any of the config files could someone please help me out with these, it sucks that the documentation is so limited in giving examples =(

Thanks a lot!!!


a, all calls start with incoming (ok, so there are exceptions :smiley:), you set a context for the originator of the call. e.g. for “outgoing” calls (from UAs on your local network) you’ll use a context like [from-internal] and have a series of actions in there. for “incoming” calls (from SIP/PSTN/IAX etc) you’ll also specify a contect, e.g. [from-external] and have a different dialplan with different AGI scripts etc etc.

b, when you setup your trunk for IAX/SIP you can specify the max number of channels. this max depends on the codec you’re using. there’s a calculator at that you can use. you should probably have some QoS on your gateway/firewall too that can guarantee the bandwidth you need for your max channels of x codec.

c, all calls get a unique ID. they’ll follow the dialplan you’ve configured for the context they enter in. queues only get used if you configure a queue.


Cool, but exactly how do I configure outgoing to use context: [from-internal] and incoming to use context [from-external] ?

Whats the technical answer for this? Like can you show me sample code and where to put the commands exactly? I know what to write withing the context sections, but I dont know what to write to make the system use which specific context.

Please help, thanks a lot


the wiki is your friend, as is make samples when you compile asterisk (but only if you don’t have anything you want to keep in /etc/asterisk)

e.g. in sip.conf

context = from-external
; lots of other stuff here too

callerid="My Name" <100>

in extensions.conf

exten => 200,1,AGI(myOutgoingAGI)

exten => s,1,AGI(myIncomingAGI)

very simplified, but you should get it from that :smiley: