Upgrade 3CX to v18 and get it hosted free!

Asterisk Manager API Action Originate

Author image

Action: Originate

Parameters:

  • 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 dialed 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 doesn’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 following was derived from the Asterisk 1.6.2.0 source:

1 = Other end has hung up
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 1

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 variables 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 2

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 3

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 an Asterisk local channels 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) enough time to start. If you need a configurable timeout just pass a channel variable to your Originate action and pass it to Wait().

See Also


Article Reviews

Write a Review

Your email address will not be published. Required fields are marked *

Required Field. Minimum 5 characters.

Required Field. Minimum 5 characters, maximum 50.

Required field.There is an error with this field.

Required Field.

This site uses Akismet to reduce spam. Learn how your comment data is processed.

There are no reviews for this article. Be the first one to write a review.

Related Posts:

Get 3CX - Absolutely Free!
Link up your team and customers Phone System Live Chat Video Conferencing

Hosted or Self-managed. Up to 10 users free forever. No credit card. Try risk free.

3CX
A 3CX Account with that email already exists. You will be redirected to the Customer Portal to sign in or reset your password if you've forgotten it.