TwitterReplyPipe - Technical Details

Previously, I had posted about TwitterReplyPipe, a Yahoo Pipe that scanned the public twitter time line with a search criteria that you specify and reply with a message from your set of replies. This post is about some of the interesting technical problems encountered while building the application.
The pipe itself is a simple, starting off by scanning the public twitter time line using the search feed. The parameters to this URL are as specified in the twitter advanced search page. This feed is then pruned for tweets by unique author and author's URL is replaced with @usernameand the reply that the user specified is appended to this from another pipe.
This is set as the title of the feed. The GUID of every item is the author's name to prevent more than one reply to a user. This is then passed on to twitterfeed and sent as replies.
Two interesting issues deserve a mention here.

1. Combining 2 feeds into one.
The Yahoo Pipes union operator only appends one feed to the other; I could not find a way to combine the properties of an item of one feed into the items of another. That was the reason a second pipe was used to give out a random reply from a file with list of replies. A loop in the first pipe uses the second pipe as the operator to combine the feeds.

2. Generating random numbers in YAHOO pipes
I could have picked up random numbers after parsing the output from random.org, but that seems too tedious for this. I simply used the date operator and obtained the utime of the date as a random number. Interestingly, I was not able to get the %S operator working on V2 of pipes and had to resort to multiplying the "seconds" in the time with a very large number and then mod it to the total number of lines to get a random line. This however is not random when the pipe gets called within a second.

You can  read about the steps to use this pipe here and please let me know if you have any questions.

Auto Reply to tweets using Yahoo Pipes - TwitterReplyPipe

TwitterReplyPipe is a simple mash-up that can search the public twitter time line based on a search criteria you define and reply to the tweets with a message from a set of messages that you define. Some use cases include
  • Look for mentions of your product and send replies telling users to look at products that you can cross sell.
  • Search for the category of your product and tell users to look at what you have to offer.
  • Search for tweets mentioning your competition and redirect them to a comparison page.
To set it up,
  1. Visit http://pipes.yahoo.com/axemclion/twitter_replier and enter the three inputs as explained below. 
    •  Query Key is the key as specified in the twitter advanced search page. To search for a phrase, use "phrase" and to search to a list of terms, try "q" as the input.
    • The Tweet file is a simple text file hosted on the internet with a set of messages that will be sent at random. You can host your files at http://pastebin.org using the steps below
      1. Visit http://pastebin.org and type in all the messages that you would like to send, one in each line. 
      2. Enter your name in, select that you would like to save the file forever and click "send"
      3. In the next page, copy the "download" link. It will look something like http://pastebin.org/pastebin.php?dl=
    • should be the phrase or the terms that you would like to search for.
  2. Click on"Run Pipe" button and you can see a preview of what the tweets will look like. Copy the "Get RSS" link which you will need for setting up the twitter feed account.
  3. Visit twitterfeed.com and create a new feed. In the RSS feed URL, paste the Pipes URL that you just copied. 
  4. Expand "Advanced Settings" and ensure that the "Post Content" is title only, "Post Sorting" is based on GUID and "feed is sorted" is unchecked. Also, uncheck the "Post Link"
  5. Continue to next step and associate your twitter account and complete the process
Once twitterfeed is also setup, replies would automatically be sent.
This is a followup to a post that I had written about a way to use YAHOO pipes to automatically reply to tweets that mentioned certain keywords. The initial pipe was rudimentary in a way that it could only tweet one message and could not use the extensive search capabilities of twitter.
If you have questions, please write to me and I would he happy to help.  You can follow this space to check out updates to this pipe.

More APIs illustrated with TrialTool

Some of the previous posts talk about TrialTool and using it to illustrate various client side APIs. An older post also featured the procedure to create your own example. All the examples are now hosted in a github project. At present, there are three APIs that are featured.

Jquery Templates
This project is a Jquery Templating engine and is hosted here. As Rey Bango put it in his blog,
the cool thing about templates is that it lets you easily structure your content display without all the hassle of string concatenation.The first set of examples used this this are from  Rey's blog. The second set of examples uses the code listed on the github gh-pages of the project.

Firefox 4
Babu Srithar put together a set of examples showing some of the newer developer features that were released in Firefox 4 Beta. I could import only the examples for IndexedDB. This is exposed using the window.moz_indexedDB in Firefox. You can find more details about this on his blog post. This is interesting given that these APIs not documented in detailed and this would help developers get a feel of thenew APIs. 

YUI Examples 
This was a set of examples that I had written to show case YUI examples during the recent YAHOO India hack day. You can read more about this in the blog post. The examples were scraped from the index of examples from the YUI developer network and added to the project.



I am also talking to a couple of other people who said would be interested in using TrialTool to publish their examples. If you have client side API that you would like to have examples for, please do contact me, and I would be glad to help you with a version.

Using TrialTool to create your own examples

I had previously posted about TrialTool, an API viewer to showcase your Javascript APIs. This post describes the way to use the tool to showcase your own applications.
TrialTool has support to "Fork" existing examples. Reload the page with the &fork=true appended to the end of the URL and a "Fork" link would appear on the left, near the examples. Clicking on the link would start the forking process.
Moving the mouse over the example shows up a couple of icons that lets you move, rename or edit the names of the example categories or examples. The names of the categories also have additional icons to add more examples.
The following video shows the various ways to change the examples and save it.


Once the editing is complete,
  1. Download the TrialTool package to your local machine



    • Get the zip or the tarball, and extract it
    • Alternatively, fork the source from github
  2. Copy the example file that you downloaded as [TrialTool's location]/examples/default.html
  3. Use your web server to serve this folder as a web resource 
You can also take a look at the example files. It shows some more complex cases where dependencies between examples and linking to external libraries are defined.

TrialTool currently has two examples
I would be adding more examples, so watch out this space for updates.