How to create a Twitter bot
By Steve Poland • April 10, 2007
- Determine what your bot will do. Capabilities include the ability to push information publicly to everyone (i.e. a sports team bot might push the current score of a game after each new point scored; or a world news bot might push headlines with a link to world news items). Another ability is for a user to direct message your bot — essentially sending it a command (i.e. a user could send their zipcode to a weather bot and the bot could send a private direct message back to only that user with the weather for that zipcode; or a stock quote bot could receive a stock symbol from a user and send them back a direct message with the price of that specific stock).
- Register a Twitter username.
- Create the functionality for your bot on a web server. Push (public broadcast of info to anyone that is your bot’s friend) and/or Pull (user provides command, you send them a result) functionality.
- Use Twitter’s API to understand: retrieving direct messages and sending messages.
- Users can only send your bot a direct message if your bot adds that user as a friend. Thus, your bot needs to call the ‘befriend_all’ link, which will befriend anyone that has added your bot as their friend. Hit this link every 30(?) seconds: http://twitter.com/followers/befriend_all.
- An alternative option is to go into the settings of your Twitter username, choose to be alerted by email when someone adds you as a friend, and then monitor those incoming emails and add each user individually that way (automated).
- Adding a username as your bot’s friend is easy, simply use the update function of the Status Methods.
- For push bots (broadcasting a single message to all users that are your friend or following you or viewing your webpage publicly), simply use the update function of the Status Methods.
- For pull bots (a user is your friend, you are their friend, they send you a direct message with some sort of command in it, you process that command on your server, you send them a direct message back with a result/answer to their query), use the direct_messages function of the Direct Message Methods to get the direct messages (”commands”) that users have sent to your bot. Then use the new function of the Direct Message Methods to send that user a direct message (”result/answer”) back to their query (note: direct messages are private, so only that user will see this result).
- Let others know about your bot!
Post it at http://www.twitterbots.com
Related posts:
- “Pull” Twitter Apps Not Practical Until… “Pull” Twitter apps aren’t very practical until a setting is added to each user account. Right now, if someone adds me as a friend — I still can’t receive any direct messages they send me,...
- Twitter - What Will Dominate: Content Push or Content Pull? I don’t know what will blow up and be used more on Twitter — content push plays, or pull plays. Push would be having ‘NFL’ as a friend and getting all the latest NFL news...
- I’m the first Twitter spammer, ugh There’s a lot of things I am, but this wasn’t one of them that I expected to become — particularly given my love for the Twitter service. But things are fine with the Twitter team...
- First Twitter Bots Launched: Sports Teams, Weather, Stock Quotes These might be the first push/pull Twitter applications. For weather forecasts, add Forecast as a Twitter friend. Simply send it a direct message with your zip code, or city name, or city / state —...
- Twitter Syntax for Twitter Bots Fred Wilson just featured a twitter bot for stock quotes. I was also just chatting with Andrew Parker (Fred’s associate) at USV about Twitter syntax. I think we came up with a pretty good idea...
Related posts brought to you by Yet Another Related Posts Plugin.
Comments
12 Responses to “How to create a Twitter bot”
Got something to say?



For automatically adding people as friends, the bot I’ve made checks the friends requests page (http://twitter.com/friend_requests/) and extracts all user ids and then visits the accept url (http://twitter.com/friend_requests/accept/USER_ID/). I couldn’t get the befriend all page to work.
If anybody wants to try it out, add findprice as a friend on twitter, then from your cell phone text: “d findprice playstation 3″ and you will get back the price of a playstation 3 on Amazon UK. It can take up too 2 minutes to get this reply.
Did anyone create an actual working Twitter bot for sending out follow requests? If so, email me. I’m interested
Twitter 411 - your own information system on the top of Twitter. Yes, it is a bot (with user defined responses). See http://t411.linkstore.ru
still confusing, I just modifying some feed from mybloglog, and make new twitter account that acts like a bot. it automatically twits my recent update….
btw what is the benefit for this messanging bot?
>btw what is the benefit for this messanging bot?
twitting updates is like broadcasting. And message bots works by requests
[...] more over at the all-new Who Is Hosting This blog, or more on how to create your own over at Steve Poland’s blog. Bookmark [...]
Here is a a new bot.
http://twitter.com/myflightinfo
I find it useful.
[...] An oldie but a goodie on creating a Twitter bot. [...]
[...] closed out the evening with the BBC’s Ian Forrester pitching Tweetfoxxy, a playful ‘Twitter-bot‘ that helps match people for dates and, um, sexual liasons…almost a ‘booty [...]
If you want to check a bot which provides the results of the main football (Soccer) competitions just check http://www.twitter.com/twitscores
Thanks! I’ve just made a Twitter bot. More info http://download11.com/twitter
Excellent, I’m loving the Twitter bots for pushing sports scores. Thanks!