Dont Panic


First Successful Node.js program

14 Jun 2012
A while ago i talked about cloud development using Cloud9, my latest project was also written entirely using Cloud9 and is now happly running on as a Heroku app. So what have i been up to ? Well i wanted to play with Node.js and therefore needed a small project. A friend of mine is in the early days of running a new restraunt called smallplates, and being the computer nerd that i am, i decided what he needed was a twitter bot that could return the current menu to any @smallplatenq follower who so desired it. Ive posted my code in its current format to github which is working but still has some improvements needed  Current issues that need to be addressed: The menu is hard coded in as an array. In the future versions im going to work on having this information scrapped from the Small Plates website which is still under construction.
var menu = new Array('The Current Menu at @smallplatesnq looks like this',
                    'BUTTERMILK FRIED CHICKEN w/ roasted peanut sauce\n\n CRISPY PORK CHEEK w/ smoked bacon sauce & Rekordelig mayo',
                    'LAMB MEATBALLS w/ tomato sauce\n\n BREADED WHITEBAIT w/ cockle ‘popcorn’, Rekorderlig mayo',
                    'COD CHEEK IN BEER BATTER w/ mushy peas\n\n MINI SQUID BURGERS w/ lettuce and onion',
                    'MARIS PIPER MASH CAKES w/ cucumber ketchup, smoked salt\n\n YORKSHIRE PUDDINGS w/ whipped blue cheese, chilli jam',
                    'ASPARAGUS SPEARS w/ fondue',
                    '====== Sides (£3.00) ======',
                    'TRIPLE COOKED CHIPS w/ served with ketchup and mayo\n\n ONION RINGS w/ fried in beer batter',
                    'PORK SCRATCHINGS w/ five spice, salt and pepper');
The bot replies with the menu via direct messages to the requesting user. This stops the main feed from getting cloged up and annoying other followers who wouldn't want to see 6/7 identical tweets ever hour or so when a customer makes the menu request. However if the requesting user does not have the correct following/followed set up with the smallplates account then the messages will fail and there is no feedback mechanism for this. In the future i would like to provide a feedback tweet to the user and some auto following fixes to get round as much of this as possible.
Last but by no means least, the activity of the bot is, for the large part, un-monitored. Some reporting / logging abilities would be good so that the owner of the smallplates account could find out stats on who's been asking for
info and how many times etc etc
Bots like this are nothing new. In fact to begin with i started goggling for a pre-coded one that i could spin up on heroku or another server and just get cracking with right away. There didn't seem to be anything out there. This seems odd to me as there must be thousands of support orientated twitter accounts that i would expect to have "canned" responses for simple queries. If i get time i will try to imporve this to the point where it can track multiple user/word combinations and then promote it as a possibility for support or even just general interaction for companies social interaction.