Asterisk Manager API Action Originate
Business PBX Solutions
3CX Software PBX for Windows
Become an ITSP Now!
- Channel: Channel on which to originate the call (The same as you specify in the Dial application command)
- Context: Context to use on connect (must use Exten & Priority with it)
- Exten: Extension to use on connect (must use Context & Priority with it)
- Priority: Priority to use on connect (must use Context & Exten with it)
- Timeout: Timeout (in milliseconds) for the originating connection to happen(defaults to 30000 milliseconds)
- CallerID: CallerID to use for the call
- Variable: Channels variables to set (max 32). Variables will be set for both channels (local and connected).
- Account: Account code for the call
- Application: Application to use on connect (use Data for parameters)
- Data : Data if Application parameter is used
- Async: For the origination to be asynchronous (allows multiple calls to be generated without waiting for a response)
- ActionID: The request identifier. It allows you to identify the response to this request. You may use a number or a string. Useful when you make several simultaneous requests.
Sequence of events: first the Channel is rung. Then, when that answers, the Extension is dialled within the Context to initiate the other end of the call. Note that the Timeout only applies to the initial connection to the Channel; any timeout for the other end can be specified, for instance in a Dial command in the definition of the Context.
Using Async leads to an OriginateResponse event which contains the failure reason if any. Reason may be one of the following:
0 = no such extension or number. Also bad dial tech ie. name of a sip trunk that deosn't exist
1 = no answer
4 = answered
5 = busy
8 = congested or not available (Disconnected Number)
See the ast_control_frame_type enum in frame.h for a complete (and up to date) list of possible reasons.
The fallowing was derived from the Asterisk 126.96.36.199 source:
1 = Other end has hungup
2 = Local ring
3 = Remote end is ringing
4 = Remote end has answered
5 = Remote end is busy
6 = Make it go off hook
7 = Line is off hook
8 = Congestion (circuits busy)
Example(Placing a call from a SIP channel to an extension, this will cause the outside call not to be placed until the SIP channel has picked up):
Action: Originate Channel: SIP/101test Context: default Exten: 8135551212 Priority: 1 Callerid: 3125551212 Timeout: 30000 Variable: var1=23|var2=24|var3=25 ActionID: ABC45678901234567890
Where Extension 8135551212 is a local an outbound number
The above example also shows how to set channel variables in an Originate request.
Note: You might have heard that in Asterisk 1.2 variables are no longer separated by |, rather each one has its own line. Well that is not true or maybe it has been that way for a while. Asterisk 1.2 current source code suggests that variable must be separated with | (check the function astman_get_variables). As of 1.6, variables are separated by commas.
The above example will also hangup if the SIP/101test channel is not picked up in 30 seconds.
Example(Placing a call from an outgoing channel to a local extension, this will cause the local extension not to ring until the Zap channel has picked up):
Action: Originate Channel: Zap/g2/8135551212 Context: default Exten: 101 Priority: 1 Timeout: 30000 Callerid: 3125551212
Where Extension 101 is a local SIP phone extension
Example (executing system command):
Action: Originate Channel: Local/1@dummy Application: ((Asterisk cmd System|System)) Data: /path/to/script
Tip: if you want the Channel end to connect to an arbitrary extension and context, specify a Local channel.
Tip: The dialplan extension 1 in the dummy context could be something like: 1,Answer() 2,Wait(30). The Wait is important to give the other side (the system command) enought time to start. If you need a configurable timeout just pass a channel variable to your Originate action and pass it to Wait().
Please update this page with new information, just login and click on the "Edit" or "Discussion" tab. Get a free login here: Register Thanks! - Find us on Google+