Skip to the content
- 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