How to originate call from CLI

I’m trying to figure out the command/syntax of getting freepbx to initiate a call from the command line. The end goal is having python initiate a call when an email is received. The closets I have gotten is channel originate PJSIP/4321 extension 1234@from-internal but this originates a call and then calls the second extension. What am I missing to have freepbx initiate a call to an internal/external number (Bonus points for playing a message or tts). Any ideas? Ive been bashing my head agaisnt a wall trying to understand what I am not understanding.

Its way easier to create a .call file.
Your python script can generate the file with its required contents in a file. Then your script MOVES that file into /var/spool/asterisk/outgoing (don’t create it in the directory because asterisk will process it faster than you can generate it.

heres the info to get you started
https://www.voip-info.org/wiki/view/Asterisk+auto-dial+out

echo something like the following to "test.call"
Channel: LOCAL/5551234 > /var/lib/asterisk/sounds/test.call)
Setvar: playfile=message.wave >> /var/lib/asterisk/sounds/test.call

mv /var/lib/asterisk/sounds/test.call /var/spool/asterisk/outgoing)

2 Likes

I have created the following .call file:

Channel: SIP/<trunk>/<number>
Application: Playback
Data: hello-world

This rings the number, plays “hello world” and hangs up.

How do I change this to call the number and connect from a given extension? The following don’t do anything:

* channel originate SIP/<trunk>/<number> Application Dial Local/200@from-internal/n,,S20
* originate SIP/<number>@sip-outbound 200 s@auto-att

Also: what value must I enter for <trunk>? I have tried with the title of the trunk, but should this be the unique ID? When testing the first code, the CID was unknown.

What I’m basically trying to do is create a form with available extensions and an input field in which a number can be entered. Select both and push a button should initiate a call.

Just a test project btw.

Once you understand that most dialed numbers start in the context from-internal you can use that for pretty much everything. Your originate should look like this:

channel originate local/<number>@from-internal extension 200@from-internal

This is one I use regularly to test for 2way audio when NAT is involved:

channel originate local/<pstn_number>@from-internal application echo

I have tried, but this doesn’t do anything. Is there a way of debugging? All I need to do is put the line in a .call file and cp or mv it to /var/spool/asterisk/outgoing right?

I’ve since corrected a mistake.

Still nothing happens.

This works: asterisk -rx “channel originate local/@from-internal extension @from-internal

Funny thing: if I pick up the phone or not, there are costs.

For the two way audio test what would I need to change to make it dial a local extension and pass caller id? Is it simply replacing local/ with PJSIP?

Yeah this was alot easier. Already got it making an outbound call and playing back a sound file. Just gotta figure out how to remove the + from caller id and figure out why the number is not being recognized as a contact in my phones phonebook.
Channel: local/1234567890@outbound-allroutes
callerid: “WakeUp” <5555>
WaitTime: 10
Application: Playback
Data: not-rqsted-wakeup

I would like to get it to do tts to integrate with the script better but for now this works. And any one know why the waitime is not working? Is it no a large enough integer?

This topic was automatically closed 7 days after the last reply. New replies are no longer allowed.