Inteygrate

Instant Messaging app using Salesforce

Introduction

Muralidhar

Muralidhar

At inteygrate.com, I am trying out ways to integrate Salesforce to various other technologies.


salesforce streaming api instant messaging chat app

Instant Messaging app using Salesforce

Posted by Muralidhar on .
Featured

salesforce streaming api instant messaging chat app

Instant Messaging app using Salesforce

Posted by Muralidhar on .

Well, this isn't actually an integration stuff but the idea came up while working on Salesforce Nodejs integration. The PushTopic feature of Salesforce where one can subscribe to a topic associated with a SOQL query and then receive the notifications in real-time when the topic is updated; could be used to realize and implement the channel based IM (Instant Messaging).


What are Channel based IMs?

Instant messaging (IM) is nothing but a type of chat app. Channel based IMs on the other hand can be related to the #hashtag concept in twitter and for that matter of any other social networking site viz facebook, instagram, google+ etc. Similar to how hashtags are used to label messages on social network and microblogging services, which makes it easier for users to find messages with a specific theme or content; Channels in IM are used as a metadata tag for the messages which are related to a particular topic or area of interest.

How are channel based IMs used?

Channel based IM tools are generally used by corporate users to optimize work efficiency where they create topics (called channels) for a project, a topic, a team, or anything where everyone has a transparent view of all that’s going on. In other words these open channels are used to organize team conversations helping them collaborate by asking queries, providing feedback's, sharing work related stuffs like documents, presentations, data sheets, brochures, images etc.

For e.g. the HR executive at a technology company can create a channel "engineering-recruit" and invite other team members. The team can then discuss the strategy and schedule for recruiting fresher/lateral engineers, help each other solve the problems faced in deciding the eligibility of a particular candidate and also update each other of the latest happenings. All these in real-time!!!

Some of the popular IMs currently being used are Gitter.im, Slack, HipChat etc.

Demo Video

My attempt so far has resulted in a very simple IM where any user having access to the app can create a channel, browse other channels and message in any of these channels. Further enhancements can include the ability to share documents, images, smileys :), Profile and Role based Channels etc. I have used just one custom object to save all the messages and CometD for pushing messages in real-time. The UI is designed by using simple CSS and HTML with no frameworks. Watch the below video and a snapshot to take a glimpse of the app.


Snapshot

Instant Messaging using Salesforce snapshot


Mini Challenges

There were few mini challenges I would like to point out especially because these contributed a very basic but mandatory features of a chat app.

Features that were challenging

  1. Delivering the messages in real-time without refreshing the browser - Solved using PushTopic and CometD
  2. Displaying initials of Channel name as display pic - Created a Map and stored the Channel name as Key and the initials as Value. Used this map in the <apex:repeat> block of VF page.
  3. Different styles for the messages that were sent by the logged in user vs. other messages - Used {!$User.Id} to determine if the message was sent by the currently logged in user by comparing the user id saved on the message object while composing
  4. Avoid displaying same messages twice for the user who is sending the message
    1. The actual message sent and
    2. Message received by push notifications

Here the message id was used to decide if the received message is same as the one sent or different.


Why IM when we have Chatter?

IMs are no different than Chatter in Salesforce. In fact chatter has all those features that we discussed about earlier. The attempt was to explore the potential of PushTopic and CometD library where we realized how we can build a completely customized messaging application that can be seamlessly integrated to other IM applications as well.

The app if made public via Salesforce sites could then become a platform for open communications by any user without the need for logging in. An anonymous chat application!!!

Unfortunately the guest user profile associated with sites in Salesforce cannot be granted read/write access on PushTopic object, without which the app won't work as public site.

Muralidhar

Muralidhar

https://inteygrate.com

At inteygrate.com, I am trying out ways to integrate Salesforce to various other technologies.

View Comments...