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.

Enjoy Shopping? StoreCrowd launches beta on Oct 4th. Join us for an advanced preview & become the Boss of your favourite store

  • i don't quite understand it, someone please explain?
    i try and block CERTAIN celebs i don't like on it i don't want my bot to RT it and i'm still getting stuff like @justinbieber e.t.c.
  • I came across the same problem many commenters here faced - no spacing between username and tweet. As Chris posted below using example: @freemanncm and the beginning word of your message "just", this pipe jumbles the username and first word of the message together (@freemanncmjust).

    The solution:
    In the Loop/String Builder, add another String immediately "item.author.uri" - input anything here (you are going to replace it later anyway) I used }}}}}. After that in the Regex, add another rule to replace those characters with a space. "In item.title replace }}}}} with ".

    Hope this works for you.
  • Did anyone figure out how to do a space between username and description?
  • Is this still working? As I see your profile hasn't been updated since January.

    Thanks
  • megan
    Hi there,

    I was wondering if you could help me out with a little problem I seem to be having with my yahoo pipe? I followed your tutorial but I can't seem to figure out what's going wrong!

    Here is the pipe: http://pipes.yahoo.com/pipes/pipe.info?_id=9f0465d888420358a1e346e714c53201

    Here is the feed on twitter: http://twitter.com/lancehenriksen

    For some reason, it isn't putting a space between the persons username and what they are saying... you'll see what I mean if you check out the twitter page.

    If you could take a moment and tell me what's wrong (probably a simple thing that I'm missing) I would be really grateful!!

    Thank you,

    Megan
  • 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-i-built-an-auto-retweet/
  • 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=@LuckySales (503 Service Unavailable)

    I looked at your example and noticed that I received the same error message. Any ideas on how to fix this?

Previous post:

Next post: