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.