I can use .call files to create outgoing calls from asterisk trunk TRNK
cat /var/spool/asterisk/outgoing/tmp6Rn2aM.call
Channel: IAX2/TRNK/12345
Application: Playback
It works perfectly, but this calls not routed through AGI interface (I suppose because they are not routed internally in asterisk).
So is it possible to create call using call file that will be incoming (or not yet routed) in some trunk(or in some context), and Asterisk will try to route it and will make route request to AGI ?
Make call to extension, then Asterisk will use extension matching and run AGI when necessary.
EDIT:
http://www.voip-info.org/wiki/view/Asterisk+auto-dial+out
If the call answers, connect it here:
Context: <context-name> Context in extensions.conf
Extension: <ext> Extension definition in extensions.conf
Priority: <priority> Priority of extension to start with
Set: Set a variable for use in the extension logic (example: file1=/tmp/to ); in Asterisk 1.0.x use 'SetVar' instead of 'Set'
Application: Asterisk Application to run (use instead of specifiying context, extension and priority)
Data: The options to be passed to application
Related
I am using Asterisk 13.17.0 on a FreePBX 14.0.1.1 distro. I would like to execute a python script whenever a call gets picked up, regardless of whether it is an internal or external one, passing to it as command line parameters the number who's calling and the user who's picking it up. How could I modify my dialplan in order for this to be done? I've tried modifying the [app-pickup] extension in /etc/asterisk/extensions_additional.conf, but picking up an internal call with this modification was to no avail
You should check diall command params, especial G param
https://wiki.asterisk.org/wiki/display/AST/Asterisk+11+Application_Dial
G( context^exten^priority ) - If the call is answered, transfer the calling party to the specified priority and the called party to the specified priority plus one.
context
exten
priority
In freepbx you can change dial params in settings tab.
You also SHOULD NOT ever touch extensions_additional.conf, it even have warning on top of file. File will be rewrited every time you change config. You have do changes in extensions_custom.conf
I am developing a custom application to control an Asterisk based pbx using ami/agi interface. What I have to do is:
receive a call from a pstn external line
answer the call
play a welcome message
transfer the call to a specific extension
park the call
reconnect to the call from a different extension
Everything should be done using ami/agi interfaces. I succesfully developed everything up to point 5) but I am unable to understand how to transfer (using ami/agi) the parked call to a runtime-defined extension.
Can someone give me an idea on how to do it ?
you should originate from Local/XXX#parked_context to the extension you want.
something like this..
Action: Originate Channel: Local/XXX#parked_context (XXX is the number of parked call)
Context: default (here you put the context where you can reach the second party)
Exten: 123 (number who will receive the call)
Priority: 1
Callerid: 3125551212
Timeout: 30000
Variable:
ActionID:
Simplest way is just use async agi or conference or Wait extension instead of parking, i.e redo parking-like logic yourself.
That way you will 100% know channel name and how to transfer it back.
Considering you are gooing use ami - AsyncAGI is best option for you.
Is anybody knows , how we can Originate an external number call using PHP AGI script ?
You have got two possible options. One is use the "Originate" command. See http://www.voip-info.org/wiki/view/Asterisk+manager+Example:+Originate for an example.
The other one, which is what I favor in my solutions, since it does not require AMI, is using spooled call files. See https://wiki.asterisk.org/wiki/display/AST/Asterisk+Call+Files for how to do them. The trick, and I cannot stress it enough, is to create the spool file in /tmp and then "move" the file into the ../spool/asterisk/outgoing directory.
If you assign a unique channel variable key/value to the spooled call, you can then pick it up with your dial plan and route the call appropriately.
I want to pickup call in Asterisk using AMI. I can originate call, but totally don't know, how to answer the phone...
Script for calling:
#login
sock = socket.socket(af, socktype, proto)
sock.connect(sockaddr)
sock.send('Action: login\r\n')
sock.send('Events: off\r\n')
sock.send('Username: '+str(ast_server.login)+'\r\n')
sock.send('Secret: '+str(ast_server.password)+'\r\n\r\n')
#originate call
sock.send('Action: originate\r\n')
sock.send('Channel: ' + str(user.asterisk_chan_type) + '/' + str(user.internal_number)+'\r\n')
sock.send('Timeout: '+str(ast_server.wait_time*1000)+'\r\n')
sock.send('CallerId: '+str(user.callerid)+'\r\n')
sock.send('Exten: '+str(ast_number)+'\r\n')
sock.send('Context: '+str(ast_server.context)+'\r\n')
if ast_server.alert_info and user.asterisk_chan_type == 'SIP':
sock.send('Variable: SIPAddHeader=Alert-Info: '+str(ast_server.alert_info)+'\r\n')
sock.send('Priority: '+str(ast_server.extension_priority)+'\r\n\r\n')
#logout
sock.send('Action: Logoff\r\n\r\n')
time.sleep(1)
sock.close()
I need something similar, but for answering calls.
Can't find any useful command in *CLI> manager show command
Halp me, plox
You can't answer a call directly via AMI. This is because a new call will "arrive" at the given context/priority/extension configured in the dialplan (or it will be rejected if cant find one that applies). So whatever happens with that call will start at the given context/priority/extension in the dialplan.
If you want to handle calls via AMI, try using asynchronous AGI, like this:
exten => _X.,1,AGI(agi:async)
This will handle all calls to any extension that has at least 1 digit, by issuing an event (AsyncAGI) that you can handle with your AMI client.
Then, from your AMI client, you can send AGIAction's, like:
Action: AGI
Channel: SIP/adevice
Command: ANSWER
CommandID: MyCommandID
This will effectively allow you to run AGI commands (and handle a call like you would normally do in any AGI script) from your AMI client.
Hope it helps!
I have started to read about Asterisk::AMI module.
In that module if we want to send the action to the AMI server,we need to use the Action with action name using send_action method.
In that module they mentioned about Action => 'Ping' within send_action method.
Here what is the use of Action => 'Ping'.Can anyone explain me about it.
send_action({ Action => 'Ping',
CALLBACK => \&method,
});
Thanks in advance.
The Asterisk Manager Interface (AMI) allows a client program to connect to an Asterisk instance and issue commands or read events over a TCP/IP stream
Action: A packet sent by the connected client to Asterisk, requesting a particular Action be performed. There are a finite (but extendable) set of actions available to the client, determined by the modules presently loaded in the Asterisk engine. Only one action may be outstanding at a time
Action => Ping
gives Keep alive packet to be sent from the client to Astersik
Action: Ping
Synopsis: Keepalive command
Privilege: <none>
Description: A 'Ping' action will elicit a 'Pong' response. Used to keep the
manager connection open.
Variables: NONE
You can get basic help for any Asterisk AMI command from within the Asterisk CLI
interface by typing
manager show command yourCommand
You can see an entire list of supported commands by typing
manager show commands
BTW the shell command to get to the Asterisk CLI is
asterisk -r
I think this is a just a keep alive. Asterisk Manager Interface is known for being a little unreliable. Astmanproxy is a good way to fix that.