Developing Google Wave Robot To Monitor Latest Stock Price

Download Sample Robot Project

In my last post Goole Wave Robot Sample, I walked through basic building blocks of development of a Google Wave robot using .Net. I think its time now that we see how this cool framework can be put to some useful lifting for us. In this post I will discuss conversion of Google provided java sample Stocky. This robot parses stock ticker provided in your wave or blip and then it contacts another third party app engine application to get latest stock price corresponding to that ticker. Following image shows how the output of Stocky will look like. This is from .Net port of the sample. I called my sample byteblocks-stocks. So in case you want to give it a spin, add byteblocks-stocks@appspot.com to your contacts.

stocky google wave robot

Events handled by byteblocks-stocks

I discussed some important events and life cycle of wave in my post Life cycle and events in Google Wave Robots. This prototype robot handles two events only (for now). As you develop more and more Google wave robots, you will realize that 80% of the tasks can be accomplished by handling the events I discussed in my earlier posts. Following is the list of events handled by byteblocks-stocks.

  • self_added - As i explained in my earlier post that this event is fired when a robot gets added to a wave. Our stocks robot takes this opportunity to tell the participants how to use its features. For now it announces Get stock price by prefixing your stock symbol with $. You can use this event to do any initialization that needs to be done in the robot as well.
  • blip_submitted - This event is fired when participant has submitted a blip. In layman's terms when participant has clicked on Done button in a blip. The robot parses the contents of the blip document to extract all ticker symbols. Then it contacts a third party service to get latest stock price for that ticker and then modifies the content of the blip with stock price for that ticker.

Sample Project

This is mostly port of java sample to .Net. For now I have repalced java PersistenceManager with ASP.Net cache to save previous tickers mentioned in blips. Other than this changes, the code is very straight forward. You can download the project and play with it to figure out insides of Google wave robot development.

How it works

Here are steps you will follow to see how this robot works

  • Add byteblocks-stocks@appspot.com into your google wave contact list.
  • As soon as you add this robot as participant, it will add a blip with instructions on how to use it.
  • Create a new blip in your wave and type name of any stock ticker. For example to check price of Google stock, you will enter $goog. Depending on how fast event responds and wave synchronizes the information, you will see that blip's content has been replaced with something like goog (550.34).
  • If you want to track price of multiple tickers in same blip, simple enter multiple ticker symbols prefixed with "$". For example $goog$msft$boa

If you have any questions, feel free to drop me a line.

Search

Social

Weather

15.8 °C / 60.4 °F

weather conditions Clear

Monthly Posts

Blog Tags