Build an Auto Retweet Pipe using Twitter Search

by Stuart

If you’re a avid Twitter user it’s more than likely that you’ve been retweeted automatically before. It recently happened to me when I tweeted my excitement for the new Transformers movie.

In this guide we’re going to look at how you can make your own Retweet Pipe using Yahoo Pipes & TweetBots, there’ll also be a live link to the working Yahoo Pipe so you can clone it for yourself.

ReTweet Pipe

Choosing your Topic

Firstly we need to have a topic or keyword we’re planning to ReTweet. There’s been a load of buzz this week about the iPhone 3GS so in this example we’ll ReTweet everyone who’s bought one & ask them to vote for their favourite feature on this iPhone Twtpoll.

Since we’re ReTweeting based on twitter searches choosing the right keywords are crucial, here’s 3 searches that fit our purpose pretty closely:

The method that we’ll be using grabs the data from the RSS Feed of each Twitter search. When you search you’ll see the “Feed for this query” in the top right, grab the URL’s for all the searches you want.

iPhone Twitter RSS

Importing the Feeds into Yahoo Pipes

iPhone FeedOnce in Yahoo Pipes you’ll need to create a new pipe. Since we need to parse RSS Feeds drag across Sources > Fetch Feed from the left hand navigation.

If everything is working correctly you should see the feed output in the debugger window at the bottom of your screen.

Filtering the Feed

Now that we have a constant feed of the data we want there’s a bit of filtering that needs to be done ust to get things in the right format for Twitter & the ReTweets.

There’s a few things that I’ve filtered out from the feed initially:

  • Our own name – we don’t want to ReTweet something to ourselves by mistake
  • ReTweets – we don’t want to ReTweet other people’s ReTweet’s, otherwise we’ll get stuck in an endless loop
  • Anything with an @, just so we’re only retweeting updates not replies

iPhone Filter

To do this just grab the Operator > Filter pipe from the navigation & connect it to the Fetch Feed we created before. This will allow us to filter things out based on the properties of the feed.

In this Filter we’re blocking any authors that match our name, all ReTweets & also anything with an @. You can choose to match any of these Rules (i.e. if you need to match 2 or more) or all of them.

Once you’ve set this up you’ll see the output of this Filter in the Debugger window again.

Looping the Elements we want together

Since some of elements of the feed aren’t all in the same RSS Property we need to combine them. In this example we need to grab the name of the Twitter user that we want to ReTweet & combine it with our ReTweet Message.

iPhone Loop

This bit is slightly trickier, grab the Operators > Loop Pipe & attach it to our previous pipe. Next we need to grab the String > String Builder Pipe & drag it into the middle of the Loop Pipe. The String that we’re building contains the URL of the user we need to ReTweet & will add our message onto the end “Just bought an iPhone 3GS! What’s your favourite new feature? – http://twtpoll.com/1e22eo”

We need to send the results to item.title as that’s the part of the feed that gets picked in the RSS Feed syndication.

Finally we need to just clean up the name of the person that we’re ReTweeting. You’ll notice that debugger still shows the URL of the person so we’ll need to replace http://twitter.com/ with @ so that we reply to them & they see our poll.

To do this just drag in Operators > Regex Pipe & in the item.title replace http://twitter.com/ with @

Replace Twitter

In your debugger window you should now see a nicely formed Tweet that’s ready to be fed into TweetBots.

Using TweetBots to Automate your Tweets

Create an account at Tweetbots & create a new bot. You’ll need to grab the RSS feed of your pipe so click on My Pipes then the pipe you want to grab the RSS Feed for. There’s a “Get an RSS Feed” option, grab the URL from there & input it into Tweet Bots, make sure you also click the “Use Feed Title Only” option.

iPhone ReTweet Pipe

Once the bot is created you should start seeing the Tweets come through every 30mins or so.

Want to build a ReTweet Pipe yourself?

There’s potentially thousands of uses for this type of ReTweet Pipe & of course it can be modified or adapted. If you’ve managed to create something much better than this example post it in the comments & we’ll collate them into the post.

  • bashpr0mpt
    Wow, out of 10,000+ retweets the poll only got 20 votes. I can't believe that! :/
  • ethang
    Thanks for sharing your technique! I've mentioned it in my latest post: http://www.ethancrawford.com/2010/02/28/why-how...
  • Thanks for this great manual. My retweet pipe for "climategate" is runing now.

    But now i would like to know how i can set the pipe so that it reduces long tweets in the middle and not at the end so that the tweeted URL is protected.
    Any hints?
  • that's great I am going test it now awesome idea
  • Mark
    Hey, I used your example, but I keep getting an error message when debugging my FetchFeed: error fetching http://search.twitter.com/search.atom?q=@LuckyS... (503 Service Unavailable)

    I looked at your example and noticed that I received the same error message. Any ideas on how to fix this?
  • Nice post. Playing with the concept tonight. Does anyone notice that this Pipe doesn't work since it doesn't put a space between the user (example: @freemanncm and the beginning word of your message "just"), rather it jumbles the username and first word of the message together (@freemanncmjust)? In other words, the twitter users aren't getting their @ replies because the pipe adds on the "just." Make sense? How do you fix this?
  • thanks for this method. i was not aware of yahoo pipes until last night. i am in the process of trying it out. i'm sure there are all kinds of variations that can be used with this method. i was looking for ways to automatically retweet and this was very helpful.

    good luck!
  • Stuart
    Hey Kaila S, the iPhone one was actually one of our least successful ones.

    Our most successful Twitter experiment to date gets around 750 followers/month. But it provides quite a unique service to the community :)
  • Yes, this is a very great tool thank you! I see that this has not helped your profile at all, as far as followers go. And you've only received 10 votes on the poll. I'll be curious to see what it is in a month, but the general concept is a good one. I think if you couple the efforts above with actual interaction with followers you'll have a better success rate (more poll takers and/or followers).
  • Pls disregard.....Problem solved! ;)
  • Great idea! When I try to run the filter, I lose my feed. Any suggestions?

Previous post: 25 Tools for Bootstrapped Startups

Next post: 90+ Home Office Hacks for Bloggers & Freelancers