Sunday, April 4, 2010

Auto Reply twitter bot with YQL and Yahoo Pipes

One of the features that I wanted to implement in TwitteyBot was the ability to automatically reply to people who have certain search term. Unlike the normal updates that only reach the people who follow you, this could be noticed by people whom you are replying to, thereby having a wider, newer audience. Here is the scenerio.
Searching for a term like "#chromeextensions" would show all the people who are talking about Google Chrome extensions. It would make sense to reply back to them and maybe tell them about something like FlashPlus.

You can have your own bot by changing the parameters of this pipe, copying the "Get RSS" link and configuring it in Twitterfeed.

I created such a bot using YQL and Yahoo Pipes. Here is the pipe that spits out a feed that should be tweeted. Twitterfeed can then be used to convert this RSS feed to tweets for a specific twitter account.
The pipe uses this YQL to find all the tweets that have a certain twitter term. It then follows through a loop where the user is extracted and the advertisement line is added. This is spit out as a feed that is configured into Twitterfeed.
The only limitation is that this method has a limit of 5 tweets every 1/2 hour. I tried using Friendfeed to overcome this limit but friend does not seem to pick up the changes in the RSS feed.

If we make the advertisement text dynamic, we could have a bot that sends out answers from a we service. I created a @questionbing bot that tries to fetch the instant answers results from bing for questions sent to it. Here is the pipe that does this. Try asking it questions like [http://twitter.com/home?status=@questionbing how many days in a year] and you should get an answer.

12 comments:

  1. Thanks, this is really useful - will a clone of this pipe run automatically if left alone, or do you need to keep returning it to re-query?

    ReplyDelete
  2. @YourLocalGP Yes, you can clone it, set up an account on TwitterFeed and leave it alone. It will continue working.

    ReplyDelete
  3. Thanks Parashuram. The only issue I'm having now is that I can't seem to get a space at the beginning of the returned text; the name of the user I'm replying to is running into the first word at the moment. Have I cocked something up?

    ReplyDelete
  4. @YourLocalGP.

    Can you send me the details of your pipe ? You can contact me usinghttp://axemclion.github.com/contact.html

    ReplyDelete
  5. Just wanted to leave a note to say THANK YOU!! I am really happy to have this capability, respect to you for the work that went into building it!

    ReplyDelete
  6. Is there a way to tweek this for a mile radius in a certain city? For example 60mile radius of Los Angeles, CA.

    ReplyDelete
  7. @byron The search is based on twitter advanced search. Look for a newer version of this pipe and you can use that to tweak your tweets .

    ReplyDelete
  8. Is it just me or does the Yahoo Pipes RSS feed go down a lot. It seems like my feed only displays content occasionally. Close to 30% uptime, in my experience. Is there something I'm doing wrong?

    ReplyDelete
  9. @JustinMcClelland

    I also noticed with Yahoo Pipes RSS feed. Looks like it is down a lot of time.

    ReplyDelete
  10. Hi Parashuram Narasimhan,

    Your Yahoo pipe works great. I have one more requirement. Where to place a filter to remove all tweets containing the word http:// before automatically reply to people whose tweet contain certain search term.

    I will be very thankful to you if you can help me.

    ReplyDelete
  11. @Stuart, please ping me on http://nparashuram.com/contact.html

    ReplyDelete