The McKenzies' Blog... > Technology > PBX > Asterisk + Twitter = Call Monitor

Asterisk + Twitter = Call Monitor

  • by

Why? Why not. I was wondering how else I could make use of Twitter for other things I thought “How could I use twitter with my Asterisk PABX?” Doing some Google searching showed I wasn’t the first to think of this (as if that would have happened). There are a few people doing various things with asterisk and twitter.

I didn’t really like much of what I found, or found it wasn’t really what I wanted to do with it .. so I decided to use some of that info and came up with something of my own.

The short story is this. When someone calls my Canadian number, my US Toll-Free number any number that ultimately rings the group of phones in the house, I will now get a direct message in Twitter from a special account I setup for this purpose, which also sends a SMS to my phone (device notifications in twitter).

Read more by clicking below… Be warned! Thar be scripts and technical stuff in them thar parts


Ok, so lets see what’s under the bonnet of this beast now.

First, you’ll need an AGI script. Look, here’s one I prepared earlier – twitter.agi

Put the script in /var/lib/asterisk/agi-bin. Don’t forget to chmod +x the script as well.

Pretty simple eh? The only things you’ll have to change in the script are

  • username = your twitter login name
  • PASSWORD = your twitter password
  • recipient = Who will get your direct message

Ok, and to make it work in Asterisk I put this in the extensions.conf file for the exten that I wanted to monitor:

I’ve only shown the first bits of this context, after this is your normal context such as DIAL or whatever else you might now. I actually build in a few seconds of delay to allow the text message a chance to get to my phone before the phone rings. A sort of early warning system ūüôā

The only thing here you need to change really is the value of _DIDNUM (notice the underscore in front of the var name, this isn’t strictly needed, but if you wish to use that variable else where in the context or exten it’s a good idea. Obviously you can change the message after the “pipe” in the AGI line to customize the message you are sent.

The one thing I have left to work out is what asterisk variable to use to actually get the DID number used to call into the PBX with. If I can get that that would make this so much easier and more flexible. If you know what that is please drop me a comment.

Well, that’s really about it. It’s not rocket science by any means, heck, it’s nothing at all but it works.

Share this post :