Wednesday, February 12, 2020

asterisk call file

Here is some info on how to make asterisk make a phone call from a command line.

This is useful if you want a script to generate a call within asterisk.  There are various reasons for this, maybe a alert to call an extension and play a message, or automate the bridge of 2 resources.

Here's the process

Create a file.call file in a directory of your choice with the data to make the call (examples below)

Make sure its executable chmod 777 file.call
MOVE it to the outgoing folder mv file.call /var/spool/asterisk/outgoing/
(i've encountered situations where i had to make it owned by asterisk, so if the above fails, try: chown asterisk:asterisk file.call before you MV the file.

Important to MOVE it not copy it.  Asterisk will intercept the file mid copy and execute it before its completed.  MOVE it to the folder.

EXAMPLE 1:
I wanted to have a system that would place a call to a meeting bridge (Zoom or Webex) automatically enter in a meeting number, then place a call to extension 501

Due to a limitation on the call file which cannot send extra DTMF events (at time of writing couldn't figure it out anyway), this calls an internal number (500) which in the dialplan places the call to the meeting bridge, waits about 1.5 seconds after answer, then enters in a meeting number.

When the call is answered by the meeting bridge, the extension 501 is called, which is an internal extension and the calls are bridged together.  I've included the extra dialplan which would go into the extensions_custom or extensions_override file.

Channel: Local/500@from-internal/n
MaxRetries: 2
RetryTime: 60
WaitTime: 30
Context: from-internal
Extension: 501

[from-internal-additional-custom]
exten => 500,1,Answer()
exten => 500,2,Dial(IAX2/T28_Y02_Y07/16475580588,,D(www4343584503#))
exten => 500,3,Hangup

EXAMPLE2
This call file dials the number 5551234 (via IAX trunk name T28_Y02_Y07
When it answers, it calls and bridges the local extension 7020

Channel: IAX2/T28_Y02_Y07/5551234
MaxRetries: 2
RetryTime: 60
WaitTime: 30
Context: from-internal
Extension: 7020

EXAMPLE 3
This example calls an external number 5551234.  When that number answers, the system plays "ZIP CODE" to the caller then hangs up.   zip-code is one of the pre-recorded files in the /var/lib/asterisk/sound/en folder, which is normally the default folder.

Channel: IAX2/T28_Y02_Y07/5551234
MaxRetries: 2
RetryTime: 60
WaitTime: 30
application: Playback
data: zip-code

Alternatively, for "DATA" you can specifiy a specific path to a sound file.  


No comments:

Post a Comment

Feel free to leave a comment! If you have any information that you think should be included, please do so here and I'll get it added in.