Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Make phone ring through webserver using Asterisk

Tags:

php

asterisk

What is the easiest way? And how can it be implemented?

I thought to something like:

  1. I request a page to the webserver
  2. Php sends to asterisk a number to dial (php and asterisk are running in the same machine)
  3. Asterisk calls the phone

or

  1. A php sip client registers to remote asterisk server
  2. Php sip client sends to asterik the number to dial
  3. Phone rings

i don't care if i can hear something, it's enough that it rings

like image 425
parseINT32 Avatar asked Dec 17 '25 18:12

parseINT32


1 Answers

Call File

The easiest way is to generate a Call File. Asterisk has the feature to initiate Calls through a spool directory.

https://wiki.asterisk.org/wiki/display/AST/Asterisk+Call+Files

Hints and Notes:

  • you have to create the call file in a seperate directory and move it (do not use copy, because asterisk parses the file immediately, but move is safe) into the spool directory.

  • The call file must be owned by the user asterisk runs as

  • asterisk (utime() on the file ) checks the modification timestamp, and schedules the call on it, if the modified timestamp is in the future

AMI - the Asterisk Manager Interface

It is also possible to initiate a Call over a Script (AMI). You have to set up a login (ie. username, password) in manager.conf. Test the AMI with Telnet at the asterisk server ip at port 5038:

Action: Login
Username: username
Secret: password

Action: Originate
Channel: SIP/123
Context: default
Exten: 012345678
Priority: 1
Callerid: AMICall

Action: Logoff

You could also use PHP-AMI (comes with PHP-AGI ) to dial out.

Secutity Note of manager.conf:

 ---------------------------- SECURITY NOTE -------------------------------
; Note that you should not enable the AMI on a public IP address. If needed,
; block this TCP port with iptables (or another FW software) and reach it
; with IPsec, SSH, or SSL vpn tunnel.  You can also make the manager
; interface available over http/https if Asterisk's http server is enabled in
; http.conf and if both "enabled" and "webenabled" are set to yes in
; this file.  Both default to no.  httptimeout provides the maximum
; timeout in seconds before a web based session is discarded.  The
; default is 60 seconds.
;

AJAM - the asynchronous Javascript Asterisk Manager

AJAM is a Webserver which you could enable and use to communicate to the Asterisk Manager Interface (AMI) over http.

like image 64
pce Avatar answered Dec 20 '25 11:12

pce



Donate For Us

If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!