login | register
Sat 19 of Jul, 2008 [23:19 UTC]

voip-info.org

Discuss [20] History

Asterisk Manager API Action Originate

Created by: flobi,Last modification on Sat 26 of Apr, 2008 [12:31 UTC] by ldo
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 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.

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).

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
Callerid: 3125551212

Where Extension 101 is a local SIP phone extension

Example (executing system command):

Action: Originate
Channel: Local/1@dummy
Application: System
Data: /path/to/script

Tip: if you want the Channel end to connect to an arbitrary extension and context, specify a Local channel.





Comments

Comments Filter
222

333Variable Length limitation

by asiby, Monday 28 of January, 2008 [06:20:10 UTC]
Beware of a limitation when passing multiple variables to the Originate Command. The length of the string var1=value1|var2=value2|...|varn=valuen is limited even if the number of variable is under 32. I haven't calculated its limit, but my agi scripts were acting strange and loosing some values with a variable string containing 250 characters. I hope this helps.
222

333Account(code) available only on DESTINATION channel

by mindaugas_kezys, Monday 21 of January, 2008 [12:39:38 UTC]
Testing shows that Account parameter is not available in SOURCE channel (Call Leg 1) but only in DESTINATION channel (Call Leg 2).

I had to send ACCOUNTCODE using Variable parameter to SOURCE channel (Call Leg 1).

222

333timeout not work.and how to detect hookoff

by leatarget, Sunday 30 of September, 2007 [05:31:50 UTC]
hi,
  I'm trying to use the originate command to make a auto-dial-out.
first.
I telnet host 5038.
my command is :
action: Originate
channel: ZAP/1/xxxxxxx
context: default1
exten: s
priority: 1
callerid: ss<804>
timeout: 30000
and the extension is
default1
exten=>s,1,playback(vm-goodbye)
exten =>s,n,hangup
the problem is whatever I set the timeout .it can't work.if i don't hookoff the phone.the extension always play.
222

333Using Asterisk API to make a callback webpage

by Kisecure, Saturday 07 of July, 2007 [18:20:55 UTC]
Hi,

I'm trying to use the originate command to make a web page with a "callback" field. The idea is that someone can enter is phone number to be automatically called by asterisk. Then, this call have to be placed in a queue. Every things work fine but, the only problem is that the music on hold in the queue doesn't start ... I don't know why.
The originate command sent trough the manager interface redirect the call to the context where I defined the queue.

Any ideas ?

Thanks
Benoit.


222

333Using Asterisk API to duplicate the keyboard of a hw phone.

by Pasqu, Sunday 28 of January, 2007 [22:33:18 UTC]
Hi all, like a subject I want to duplicate the keyboard of one hw voip phone in a web browser using the asterisk API.
I do this with php script, user compose the number of second phone in your browser, the phone near PC ring and after picked up the cornet the call is make to second phone.

Exist a way to do this: User keep up the cornet before compose the number in the browser?
I don't want to make first phone ring, but I don't know how do this?

Any ideas?
222

333Re: Matching Originate with Newchannel

by ubi, Wednesday 13 of December, 2006 [12:01:51 UTC]
Hi,
A possible method to match events with the Originate command: Create a unique ID, and pass it with a name to Variable parameter of Originate. When you handle the events you can use command GetVar for getting the value of your variable on the channel. You will find your ID in it, if they matched. You can get the value of your variable also in the dialplan.
222

333Rubification

by derekf, Thursday 30 of November, 2006 [22:23:30 UTC]
Hey all, just wanted to post a little ruby script I wrote to originate calls to the outboundmsg1 context that is posted elsewhere in the wiki. Thought it may be of use to someone.


<code>
require "socket"

number=(if ARGV.length == 1; ARGV.shift; else exit; end)
STDOUT.flush
s = TCPsocket.open('localhost', 5038)

s.write <<EOF
Action: Login
Username: admin
Secret: <your admin secret defined in /etc/asterisk/manager.conf>

Action: Originate
Channel: Zap/g0/#{number}
MaxRetries: 5
RetryTime: 300
WaitTime: 45
Context: outboundmsg1
Extension: s
Priority: 1


Action: Logoff

EOF

s.close
</code>
222

333Matching Originate with Newchannel

by tiko, Monday 30 of October, 2006 [18:01:09 UTC]
Hi there,

Does anyone know how to match an Originate action with the corresponding Newchannel events. For example, when using asynchronous originate with ActionID set to some value OriginateFailure event does return the ActionID of the corresponding originate Action, but other evets for eg. Newchannel, Cdr etc. doesn't have ActionID so it is imposible to determine which Newchannel event was generated by which Originate action. Does anyone know how to solve this problem?

Thanks,
Tigran
222

333Ping the server after login

by xutom2006, Monday 30 of October, 2006 [10:24:07 UTC]
I have used the command "sendto(clifd, bufLogin, BUFFER_SIZE, 0, (struct sockaddr_in *)&servaddr, socklen))" in C program and the bufLogin is :"Action: login\r\nUsername: admin\r\nSecret: admin\r\n\r\n" , and the debug message(is "Response: Success
Message: Authentication accepted") of the remote asterisk server shows that i have logined on successfully. Now i again run another command "sendto(clifd, bufPing, strlen(bufPing), 0, (struct sockaddr_in *)&servaddr, socklen))" and the bufPing is "Action: Ping\r\nParameters: None\r\n\r\n" , this time i get the result :Response: Error
Message: Missing action in request" ,and my /var/log/asterisk/full contains the following message:"Oct 30 03:21:43 DEBUG2627 manager.c: Manager received command '' ",the ping command is NULL ? Why? Can someone help me?

thanks in advance... xutom
222

333Ping the server after login

by xutom2006, Monday 30 of October, 2006 [08:29:12 UTC]
I have used the command "sendto(clifd, bufLogin, BUFFER_SIZE, 0, (struct sockaddr_in *)&servaddr, socklen))" in C program and the bufLogin is :"Action: login\r\nUsername: admin\r\nSecret: admin\r\n\r\n" , and the debug message(is "Response: Success
Message: Authentication accepted") of the remote asterisk server shows that i have logined on successfully. Now i again run another command "sendto(clifd, bufPing, strlen(bufPing), 0, (struct sockaddr_in *)&servaddr, socklen))" and the bufPing is "Action: Ping\r\nParameters: None\r\n\r\n" , this time i get the result :Response: Error
Message: Missing action in request" ,and my /var/log/asterisk/full contains the following message:"Oct 30 03:21:43 DEBUG2627 manager.c: Manager received command '' ",the ping command is NULL ? Why? Can someone help me?

thanks in advance... xutom