Be Good & Do Good!

Post navigation

We have this amazing thing of collaboration inside Salesforce, the Chatter – an amalgamation of best features of Facebook and Twitter. And to add, it’s for enterprise, so its Enterprise Collaboration Isn’t that awesome!!! Chatter supports lot of things post, comments, likes, follows etc and best part is its not just user posts, comments etc .. its data posts, comments etc i.e., even the data is part of the collaboration . That adds to awesomeness!

However, there’s been one feature which I been waiting for and always wanted to see which is auto refresh of posts (for techies – ajax refresh) without need to refresh the entire page. Without this feature collaboration doesn’t seems to be complete and web2.0 type. An alternative to auto refresh can be a stream or ticker (like we have Feed Ticker on facebook) which keeps scrolling and shows posts / comments happening around without need to refresh page.

So I thought of building the same, and first thing I needed was a poller which can poll and see if there are any chatter posts, but that would have been too resource intensive, and would have died after few hours because of governor limits and bla … bla … And to save me, there came a really great feature The Streaming API. I’m loving it!

Two lines about API - Use Streaming API to receive notifications for changes to Salesforce data that match a SOQL query you define in a secure and scalable way. Streaming API is useful when you want notifications to be pushed from the server to the client based on criteria that you define.

So what’s next, I was super excited to get all started to use Streaming API and poll Chatter objects. I was able to get basic streaming API program working (after few discussions around streaming api with Pat Patterson, as the API had few issues in terms of documentation).

In basic example, I created a PushTopic (a SOQL query that you want notifications about) of Account. Now as the objective is chatter stream, so I tried to create a PushTopic around chatter object, and here was entry of the Villain – PushTopic aren’t supported yet for Chatter objects (SF please enable the same @ earliest)

So what next, trigger the rescue man came to help. Developed few triggers which will do realtime snapshot of chatter objects, and then created push topic against these snapshot objects. This way (though indirect way) I will be able to get push notifications (using streaming API) of chatter posts…wow, finally I made it. I got the CHATTER STREAM or CHATTER TICKER ..

The use case of this is endless, sky is not the limit..

Road map:

The notifications are lost the moment page is reloaded, so will try to add something which makes them persist until user has seen them.

Apply Sharing Settings, as currently all messages of all users are shown

Trust me this idea struck me in morning and by evening the tool/app was ready. Thanks to Rajesh Shah for helping me out in testing this app.