Twitter, a micro-blogging web application that takes a 140 character post, has made a big splash in technology recently. Twitter has overcome all the naysayers saying that there is no real business model set to use the application and recently landed some major funding by big names (Twitter – Opportunity Knocks).

I’ve been using Twitter for about 4 months just trying to wrap my head around its applications, it wasn’t until a few tech coordinators in the state came up with the idea to use a “twitter-bot” to communicate with other tech people at a conference about cool sessions or vendor give-a-ways (Ryan Collins – Group Twitterbot). It was a good experiment and sparked some interest for me on one of my drives into work. Someone mentioned the hash tags for Twitter and how they are cumbersome (eTech Ohio Twitter-bot) and I thought what if the hash tags where used for tagging events or tasks.

Most articles I’ve read about Twitter-bots have been based on using checking an email account and converting those email notices much like Ryan Collins – Group Twitterbot article. The only problem with this, like Ryan mentioned in his article, there’s now real way to check the validity of where the message came from which means a possibility of spam submitted to you bot. Plus it keeps you from being blacklisted.

If you made more than your allotment of requests (which is up to 20,000 per hour for whitelisted IPs and accounts), our operations team may very well block your IP or IP range…

When I created my bot I decided to use the full Twitter API which even gives you the ability to delete direct messages. I use a cron job on a linux box to run the bot script every 60 seconds which only creates a total request less than 2000.

Let me explain the process of my bot first then go into more details as to how to use it.

  1. Create a Twiiter Account common to your department or business.
  2. Create a scheduled task (a possible future post) to run every 60 seconds to check for direct messages to the above account.
  3. If there are any direct messages to the created Twitter account those messages are processed on hash tag

It’s a pretty simple process, the hard part his defining your hash tags. We currently are using 3 hash tags in our department:


#update


I’m fortunate enough to have three people in my tech department where most school districts tech department consist of the one person. The update hash tag is used to update everyone in the department where you are or where you are heading. We are all working on different projects and since I run the department I like to be kept updated. A lot of times I might be in a meeting, which they know about ahead of time, or even just to get a coffee and instead of them trying to find me to tell me they are going to another building to work on something they just send a message to the twitter-bot that might look like this:

d deptacct heading to building1 to fix helpdesk ticket 123456 #update

Everyone then gets a device update that might looks like this:

deptacct: user1 is heading to building1 to fix helpdesk ticket 123456


#todo


The todo hash tag has the ability to keep a todo list for yourself or to assign a task to another person in the department. Its a lot similar to Remember The Milk’s Twitter Service but not as robust yet, I hope to develop this hash tag a little more. We are moving to Microsoft Exchange either this summer or next and I hope to integrate this with the Task List thats available with an Exchange account. The todo messages look like this:

d deptacct update network documentation #todo

To assign an item to another person in the department:

d deptacct @user2 test server restore from backups #todo

If you don’t put a user account in front of the todo item it does a direct message to your twitter account. I find this very useful for todo’s for the following day or while sitting at home or disconnected from the web and just text it via Twitter’s short code (40404).


#inventorymove


While out in the building it is sometimes hard to find a piece of paper to write down the inventory tag numbers on the computers we move around. Then if you have a piece a paper sometimes you forget it at the room or building and really is just hard to keep track where you put it. So I added the inventorymove hash tag that I plan on integrating with our helpdesk package but currently it just repost the direct message as update or tweet on the department twitter account. Those messages look like this:

d deptacct 0012345 from Library to Room 134 #inventorymove

It’s then reposted to the deptacct as a tweet that looks like this:

user1 moved 0012345 from Library to Room 134 #inventorymove

The possibilities are endless I hope to keep releasing new code with new features soon. The coding process can be a little different depending on what you are use to using. Since I’m a Zend Certified Engineer (PHP5 Certification) I’m using the Zend Framework for all of my php programming as it offers a lot as far as frameworks goes. One of the services objects it has is a Twitter API object, and much more and I’m using it for my bot. I understand that a lot people may not know how to work with the object oriented side of PHP with frameworks so I also attached a zip file that uses the same twitterbot class from Ryan’s post just modified to delete direct messages after they are retrieved. The zip file also has the php script that you can run as a scheduled task or cron job.

Code


Resources


 

Tagged with:
 

Leave a Reply