Initiate outgoing call from a script

I have FreePBX 13.0.194.10 with Asterisk 13.18.3.
Is there a way to initiate an outgoing call to an internal extension (for ex. 555) from a shell script?

I have a reporting system. Every night this system runs reports. At the end of the night the system will finish and the result will be SUCCESS or FAIL. I can get this report system to ssh into the FreePBX and call in a script. But I don’t know how to create a script to mane the outgoing call.

Thank you.

Not “a way” but there are about a half dozen ways to do things like this, including using Asterisk CLI scripts, AMI scripts, and Call Files.

Call Files:
http://the-asterisk-book.com/1.6/call-file.html

Asterisk Management Interface:
https://wiki.asterisk.org/wiki/pages/viewpage.action?pageId=4817239

Asterisk REST Interface:
https://wiki.asterisk.org/wiki/pages/viewpage.action?pageId=29395573

I am trying out the use of the .call file in /var/spool/asterisk/outgoing/.
This is the content of my .call file:

Channel: SIP/555
Application: Playback
Data: Hello1234
MaxRetries: 1
RetryTime: 60
WaitTime: 30

After i placed the file in /var/spool/asterisk/outgoing/, I did get a call at the extension 555; however, nothing was played back.
These WARNING messages showing up in my asterisk log.

[2018-05-23 11:20:21] WARNING[6352] file.c: File Hello1234 does not exist in any format
[2018-05-23 11:20:21] WARNING[6352] file.c: Unable to open Hello1234 (format (ulaw)): No such file or directory
[2018-05-23 11:20:21] WARNING[6352] app_playback.c: Playback failed on SIP/555-00000c47 for Hello1234

Where can I place my record file?

/var/lib/asterisk/sounds/

I am now receiving this WARNING

[2018-05-23 11:58:50] WARNING[10610] file.c: File /var/www/html/admin/modules/core/sounds/en/please-enter-your-extension-then-press-pound.sln does not exist in any format
[2018-05-23 11:58:50] WARNING[10610] file.c: Unable to open /var/www/html/admin/modules/core/sounds/en/please-enter-your-extension-then-press-pound.sln (format (ulaw)): No such file or directory
[2018-05-23 11:58:50] WARNING[10610] app_playback.c: Playback failed on SIP/555-00000c59 for /var/www/html/admin/modules/core/sounds/en/please-enter-your-extension-then-press-pound.sln

The file /var/www/html/admin/modules/core/sounds/en/please-enter-your-extension-then-press-pound.sln
is available in the specified directory.

I am so confused with the document instruction for the Data part.

Why not just use the “/var/lib/asterisk/sounds/” directory?

Another option: I often do not use data in call files, excluding it entirely. I usually point the call file to a context, which can play a system recording, then hang up. This works very well for us, we use it 1,000s of times per day.

How can I do this?

Read the instructions:

http://the-asterisk-book.com/1.6/call-file.html

The hello-world example works well.

  • You would put the [call-file-test] context in the /etc/asterisk/extension_custom.conf file.

  • Then copy and paste in the call file example, its already built. Remember to change the channel.

  • Once you confirm it works, modify the file and context until they meet your need.

Let us know if you get stuck or need anymore help.

What do you mean?

This is my extensions_custom.conf.

This is that I have in my .call file in the /var/spool/asterisk/outgoing/

Channel: SIP/555
MaxRetries: 2
RetryTime: 60
WaitTime: 30
Context: call-file-test
Extension: 10

The system did call me but there was nothing played back.
This is the WARNING i see from the asterisk log:

[2018-05-23 13:49:56] WARNING[19354][C-000007e0] pbx.c: Channel ‘SIP/255-00000c9a’ sent to invalid extension but no invalid handler: context,exten,priority=call-file-test,10,1

Change all the exten => 10 to exten => s in the call-file-test context. Try again.

I did so. It’s still not working.
I don’t know what the author meant by “extension 10”. I do not have this extension. So I replaced 10 with an existing extension of 252.
And the the result is still the same. I received no play back.
This is the log from asterisk

[2018-05-23 14:11:02] WARNING[22913][C-000007f1] chan_iax2.c: Resyncing the jb. last_delay 0, this delay -13419, threshold 1000, new offset 13419
[2018-05-23 14:11:02] WARNING[22982][C-000007f1] chan_iax2.c: Resyncing the jb. last_delay 0, this delay -352737606, threshold 1000, new offset 352737606
[2018-05-23 14:11:59] VERBOSE[23137] pbx_spool.c: Attempting call on SIP/255 for 10@call-file-test:1 (Retry 1)
[2018-05-23 14:11:59] VERBOSE[23137] netsock2.c: Using SIP VIDEO TOS bits 136
[2018-05-23 14:11:59] VERBOSE[23137] netsock2.c: Using SIP VIDEO CoS mark 6
[2018-05-23 14:11:59] VERBOSE[23137] netsock2.c: Using SIP RTP TOS bits 184
[2018-05-23 14:11:59] VERBOSE[23137] netsock2.c: Using SIP RTP CoS mark 5
[2018-05-23 14:11:59] VERBOSE[23137] dial.c: Called 255
[2018-05-23 14:11:59] VERBOSE[23137] dial.c: SIP/255-00000cb1 is ringing
[2018-05-23 14:12:00] VERBOSE[23137] dial.c: SIP/255-00000cb1 answered
[2018-05-23 14:12:00] WARNING[23137][C-000007f2] pbx.c: Channel ‘SIP/255-00000cb1’ sent to invalid extension but no invalid handler: context,exten,priority=call-file-test,10,1
[2018-05-23 14:12:00] NOTICE[23137][C-000007f2] pbx_spool.c: Call completed to SIP/255
[2018-05-23 14:13:02] VERBOSE[23460] pbx_spool.c: Attempting call on SIP/255 for 252@call-file-test:1 (Retry 1)
[2018-05-23 14:13:02] VERBOSE[23460] netsock2.c: Using SIP VIDEO TOS bits 136
[2018-05-23 14:13:02] VERBOSE[23460] netsock2.c: Using SIP VIDEO CoS mark 6
[2018-05-23 14:13:02] VERBOSE[23460] netsock2.c: Using SIP RTP TOS bits 184
[2018-05-23 14:13:02] VERBOSE[23460] netsock2.c: Using SIP RTP CoS mark 5
[2018-05-23 14:13:02] VERBOSE[23460] dial.c: Called 255
[2018-05-23 14:13:02] VERBOSE[23460] dial.c: SIP/255-00000cb2 is ringing
[2018-05-23 14:13:07] VERBOSE[23460] dial.c: SIP/255-00000cb2 answered
[2018-05-23 14:13:07] WARNING[23460][C-000007f3] pbx.c: Channel ‘SIP/255-00000cb2’ sent to invalid extension but no invalid handler: context,exten,priority=call-file-test,252,1
[2018-05-23 14:13:07] NOTICE[23460][C-000007f3] pbx_spool.c: Call completed to SIP/255

I see an example of call-file-test,10,1 and call-file-test,252,1

Did you change the context to exten s and the .call file?

[call-file-test]
exten => s,1,Answer()
exten => s,n,Wait(1)
exten => s,n,Playback(hello-world)
exten => s,n,Wait(1)
exten => s,n,Hangup()


Channel: SIP/555
MaxRetries: 2
RetryTime: 60
WaitTime: 30
Context: call-file-test
Extension: s

Yes, I did. See the screen capture.

And this is what in in the .call file.
2018-05-23%2014_31_47-root%40localhost__etc_asterisk

Extension: s

Still no thing being played back. :frowning:
2018-05-23%2014_39_35-root%40localhost__etc_asterisk

Maybe you do not have hello-world? What happens if you swap out the playback for something like:

exten => s,n,SayDigits(123)

in the context. Do you hear 123?

The call still come but there is still no thing played back.

What is 255? what kind of extension is it?

255 is a SIP extension which is configured on my desk phone.