The Tinyphone server can act as a bridge between Asterisk AGI and remote applications. Currently the Tinyphone server can handle generic TCP connections and Socket.IO connections. Messages are sent as JSON.
Setting up Tinyphone (not necessary if you used the “install_tinyphone” script)
Move to the directory where you want to install Tinyphone. For example, you may want to install it in your Cloud9 workspace folder.
Check out the code from GitHub.
git clone git://github.com/itp-redial/tinyphone
Install Socket.io, if it’s not installed already.
npm install socket.io -g
Set NODE_PATH, if necessary.
export NODE_PATH=/usr/lib/node_modules/ echo "export NODE_PATH=$NODE_PATH" >> ~/.bashrc
Tinyphone Server has two components: A node app called tinyphone_server.js in the tinyphone_server directory, and tinyphone_eagi_client.rb located in the tinyphone_eagi directory.
For convenience, the instructions will assume that you are in the tinyphone_server directory. You can also put the full path to tinyphone_server.js
By default, Tinyphone will accept local AGI connections on port 12001, Remote TCP connections on 12002, and Socket.io connections on port 12003. You can configure Tinyphone by editing the config.json file:
You can temporarily run Tinyphone Server by running “node tinyphone_server.js” but I would recommend using Forever. Forever is a nifty app that will run Node apps as a background service.
npm install forever -g
Start using forever:
forever start tinyphone_server.js
Stop with Forever:
forever stop tinyphone_server.js
Tinyphone uses an AGI script to communicate with Asterisk. Tinyphone comes with a ruby AGI script that will send the appropriate events to Tinyphone, and will parse the audio for peak levels if EAGI is used.
The included AGI script uses redial-ruby-agi, which you may need to install on your server.
gem install redial-ruby-agi
IMPORTANT: Audio level events will dramatically increase the bandwidth to/from the server, so only use EAGI if your client uses audio levels.
ALSO IMPORTANT: If you’re using IPKall for incoming calls, you will need to manually set the correct dialed number. By default the inbound extension will be your IPKall ID, which will mess up the routing in Tinyphone.
exten => ipkallchris,n,Set(CALLERID(DNID)=13605162010)
[inbound] exten => _X.,1,Answer() ;you will need to set the inbound phone number if you're using IPKall exten => _X.,n,Set(CALLERID(DNID)=13605162099) exten => _X.,n,Goto(tinyphone,s,1) [tinyphone] ;replace with EAGI if you want audio levels exten => s,1,AGI(/root/node_workspace/tinyphone/tinyphone_eagi/tinyphone_eagi_client.rb) exten => s,n,Hangup()
Tinyphone can receive SMS from Twilio, or any proprietary web client that posts the same params as Twilio.
Set the URL for SMS in Twilio’s web client at this URL:
Click on the phone number that you’re using for SMS, and change the settings to look something like this:
Take note of the port after the ip address (xxx.xxx.xxx:12004) and the endpoint “/incoming”. Both are necessary if you want your SMS to reach TinyPhone.