Initiate a call from a file
From Etel
Contents |
Initiate a Call from a File
Problem
You want to initiate a call using a text file.
Solution
Adding these lines to your extension.conf in /etc/asterisk and assuming you have a SIP extension configured at 3000:
[oreilly] exten => _X.,1,Answer() exten => _X.,2,Playback(tt-monkeys) exten => _X.,3,Hangup()
Then add the tese contents to a file, copy this file to /var/spool/asterisk/outgoing/:
Channel: SIP/3000 MaxRetries: 2 RetryTime: 20 WaitTime: 10 Context: oreilly Extension: 123 Priority: 1
Would result in this being executed by Asterisk and the audio 'tt-monkeys' being played from /var/lib/asterisk/sounds/:
-- Attempting call on SIP/3000 for 123@oreilly:1 (Retry 1)
-- Channel SIP/3000-0182c200 was answered.
-- Executing [123@oreilly:1] Answer("SIP/3000-0182c200", "") in new stack
-- Executing [123@oreilly:2] Playback("SIP/3000-0182c200", "tt-monkeys") in new stack
-- Playing 'tt-monkeys' (language 'en')
-- Executing [123@oreilly:3] Hangup("SIP/3000-0182c200", "") in new stack
-- Spawn extension (oreilly, 123, 3) exited non-zero on 'SIP/3000-0182c200'
Discussion
Asterisk provides two mechanisms for initiating new calls from external applications. The first is the Asterisk Manager Interface (AMI) which is a TCP socket that allows one not only to originate calls, but also track events, creating conferences and many other applications.
The second mechanism for initiating new calls is a simple flat file placed in the /var/spool/asterisk/outgoing/ directory of your Asterisk installation. This allows one to simply create a flat file with several lines that instruct Asterisk to first place a call to a certain channel, and then places that call at the appropriate context in the Asterisk dialplan. The syntax of the file is as follows:
- First, where the call should be placed
- Channel: Channel to use for the call, such as an external phone number or an internal extension
- Second, how the call should be made
- CallerID: Caller ID that should be used for the call, (format - CallerID: Some Name <1234>)
- MaxRetries: Number of retries before failing + 1, meaning that it will always try once and then an additional number of times specified here
- RetryTime: Seconds between retries
- WaitTime: Seconds to wait for an answer
- Account: Set the account code to use for CDRs/billing
- Third, if the call connects, place it at this point in the Asterisk dialplan
- Context: Context to deliver the call to in extensions.conf
- Extension: Extension definition in extensions.conf
- Priority: Priority of extension to start with in the range of Extensions specified in the field previously
- Set: Set variable to use in the dialplan
- Fourth, if you want to simply launch an application instead of putting the call in the dialplan, use these options
- Application: Asterisk Application to run
- Data: The options to be passed to application
The Asterisk spooler is quite quick, so it is best to edit the file outside of the directory and then copy it in. One may copy in as many files as they like to initiate multiple calls.
See Also:
- Asterisk Call Files - http://www.voip-info.org/wiki/index.php?page=Asterisk+auto-dial+out
Metadata
- By: Jason Goecke
