How to Use Twitter and Asterisk for Call Notification

200903101607.jpg I’m still old school enough to think that voice conversations still matter. So I call people, and they call me. When I’m out and about I like to know who has called me back at my office (no I don’t want my cell to ring EVERY TIME someone calls my home number, my cosinity number or my home office number). That way I can see who it is and give them a ring right back if it was really something we needed to discus.

200903101608.jpgI’ve had a number of solutions in place for this over the last 2 years or so. From IM messages to SMS messages. The problem with IM is the lack of great notification on mobile devices. The problem with SMS is paying 2-5 cents each.

This led me to think – maybe using Twitter and @ messages or DM’s was a better answer.

Before I give you the code let me first explain how this works. If you are not comfortable with Asterisk, Asterisk AGI, and customizing extensions.conf you should probably stop here.

Essentially I’ve created an AGI script in PHP which decides – by evaluating the assigned account from extensions.conf – what message to send and to whom.

Step One is adding the following 2 lines to extensions.conf where you process your incoming calls:

exten => XXXXX,1,Set(CDR(accountcode)=AccountName)

exten => XXXXX,2,AGI,send-twitter-msg.php

XXXXX is your current extension and AccountName is the account we will use in just a moment to figure out who to message and what to say.

Step Two is to create the following script in /var/lib/asterisk/agi-bin/ (call the script send-twitter-msg.php):

Download the script here. – Putting the whole script in the blog doesn’t work very well. There are instructions in the script.

UPDATE 09/16/2009: If the above download doesn’t work for you you can download the file zipped here.

All that is left is to reload extensions on the Asterisk CLI and make a test call. Everything should work.
One thing to test right away is that the AGI script is executable by root. There are two steps to make sure it is. First, check to make sure the correct path to php is in the first line of the script – try “whereis php” or “whereis php5”. Then update the first line as needed.Second, make sure the script is executable – as root try “chmod 700 /var/lib/asterisk/agi-bin/send-twitter-msg.php”

Have fun… if you have any questions drop a comment below and l’ll get back to you.

4 thoughts on “How to Use Twitter and Asterisk for Call Notification

  1. Hello, I'm Margot from a communication agency from France. We are organizing the AstriEurope Exhibition dedicated to the open source telephony Asterisk.The meeting place place for the Asterisk community: VoIP service providers, equipment manufacturers, designers, integrators, distributors,IP operators and more…I want to know if you would be intersted to make a partenership with our exhibition. We propose to you to speak about your blog in our media and in exchange we would like you put our logo in your blog.We also offer to you an access to the press space during the exhibition.For further information about it, don't hesit to contact us.Is it possible to have your e-mail adress?Best regardsMargot

    Like

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s