Asterisk + Twitter = Call Monitor — Good idea

Posted on October 2, 2009. Filed under: Linux, Services |

Copied from

It’s a good idea.


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

# Background the curl process incase twitter doesn't respond. It will hang the dialplan.
curl -u username:PASSWORD -d text="$1" \
-d user="recipient" \ &

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:

exten => s,1,NoOp("This is my home phone context")
exten => s,n,Set(_DIDNUM="PUT YOUR DID NUM HERE")
exten => s,n,LookupCIDName
exten => s,n,AGI(twitter.agi|PBX: ${CALLERID(all)} just called on ${EXTEN})

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.

Make a Comment

Leave a Reply

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

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

Google photo

You are commenting using your Google 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 )

Connecting to %s

One Response to “Asterisk + Twitter = Call Monitor — Good idea”

RSS Feed for John's Blog Comments RSS Feed

Love the blog…people are missing out not using Twitter more

Where's The Comment Form?

Liked it here?
Why not try sites on the blogroll...

%d bloggers like this: