Skip navigation

Jive Developers

4 Posts authored by: aron.racho

In this post I am going to show you how to create a public cloud service, have it deployed on Heroku, and then have it pushing data into a Purposeful Place on a cloud Jiveon instance. This should be of interest for any one wanting to build middleware for cloud customers.

 

Install nodejs, npm, and git onto your system.

See Getting Started > Installing the Jive SDK for instructions on installing nodejs and npm onto your operating system.

See Set Up Git · GitHub Help on installing git for our operating system.

 

Sign up for a free Heroku account.

Heroku is where we'll host your cloud service. Its super easy to use, and free to try!

  1. Sign up for a free account: Heroku | Sign up
  2. Install the Heroku toolbelt: Heroku Toolbelt

 

Sign up for a free Mongo Labs account.

Mongo Labs hosts the database for your cloud service. It is also super easy to use, and free to try!

  1. Sign up for a free account: Create Account | MongoLab
  2. Create a development (single/node) instance, and take note of the database connection string.

 

Generate your cloud service.

In a local directory, generate your cloud service in preparation for deployment to Heroku.

 

Create a local service directory

mkdir myservice
cd myservice











 

Create a skeleton service from an example:

jive-sdk create list











 

Update the dependencies package.json file to include mongodb (add jive-persistence-mongo):

{
    "name": "myservice",
..
    "dependencies": {
..
        "jive-persistence-mongo": "*"
..

    }
}














Configure the service

Edit jiveclientconfiguration.json to configure your service.

Make sure to replace <<<DATABASE CONNECTION STRING>>> with the database url you got from mongolabs for your development database.

{
    "clientUrl": "http://localhost",
    "clientUrlExcludesPort" : "true",
    "port": "8090",
    "persistence" : "jive-persistence-mongo",
    "databaseUrl" : "<<<DATABASE CONNECTION STRING>>>",
    "extensionInfo" : {
        "name" : "My cloud service"
    }
}













 

Deploy your cloud service.

 

Login to heroku using the Heroku toolbelt

heroku login












Tell Heroku that you want to run the node app

Create a file called Procfile with these contents:

web: node app.js












Store your service in git so Heroku can read it

git init
git add . 
git commit -m "init"












Tell Heroku to create your service

heroku create












Heroku will create the app, and tell you what its public address is, for example:

http://sharp-rain-871.herokuapp.com


Edit jiveclientconfiguration.json again, and change the clientUrl parameter to be the public address of your app:

{
    "clientUrl": "http://sharp-rain-871.herokuapp.com",
    ...
}














Commit your change to jiveclientconfiguration.json:

git add jiveclientconfiguration.json
git commit -m'configured'












Tell Heroku to deploy your service

git push heroku master












Sanity test the service to see if its working

Navigate to http://<YOUR SERVICE ADDRESS>/samplelist/configure. If that comes up with a blue configuration screen, then its working!


Add your service to a Jive Cloud Instance.

Generate your addon extension.zip

Install the service dependencies:

npm install











 

Generate the addon extension.zip:

jive-sdk createExtension











 

This will produce an extension.zip file that will contain metadata about your addon, for upload into a jive cloud instance.


Upload your addon extension.zip to a cloud instance

  1. Log into your jiveon cloud instance as a community manager.
  2. Go to the addons page and upload your extension.zip


Create a social group and install the addon tile

  1. Create a social group
  2. Add the samplelist tile to your group, and configure it. You can type in any number in the counter field.
  3. Save the social group.

 

In a few seconds, the tile will start showing an incrementing counter. This means your service is up and running in the cloud on Heroku, and pushing data to Jive! I am super interested in knowing what hiccups you encounter when trying this, please drop me comments on your experience.

We've started to document the Jive SDK API level documentation here:

 

 

Jive SDK API Docs

 

This link serves the documentation straight of Git. Its not complete, but its getting there! Please leave feedback here, or in the github issues page (Issues · jivesoftware/jive-sdk · GitHub) so we can continue to tighten up this documentation.

 

Some cool facts about this documentation:

 

 

Enjoy!

OUTDATED

If you need to host a jive sdk service (jivesoftware/jive-sdk · GitHub) somewhere on the Internets, Heroku (https://www.heroku.com) is a pretty good choice, along with Nodejitsu. For the purposes of this blogpost, I'll be talking about Heroku.

 

I'm assuming that you've already:

 

  1. Generated a jive-sdk service
  2. Signed up for Heroku
  3. Uploaded your service to Heroku

 

After having done the above, you'll need to add mongodb to your app:

 

heroku addons:add mongolab

 

MongoDB is required on Heroku, because Heroku uses a virtual file system that makes it impossible to use the sdk's default filesystem persistence. Setting up mongoDB persistence for your service is pretty easy.

 

Your package.json should have this dependency:

"jive-persistence-mongo" : "*"

And your jiveclientconfiguration.json should have this:

"persistence" : "jive-persistence-mongo"

Finally, the app.js generated by the SDK won't play nicely with Heroku's requirement that it controls the HTTP port and mongoDB URL. You can get around this by using the following app.js:

 

var express = require('express'),
    http = require('http'),
    jive = require('jive-sdk');
var app = express();

var failServer = function(reason) {
    console.log('FATAL -', reason );
    process.exit(-1);
};

var startServer = function () {
    if ( !jive.service.role || jive.service.role.isHttp() ) {
        var server = http.createServer(app).listen( app.get('port') || process.env.PORT, function () {
            console.log("Express server listening on port " + server.address().port);
        });
    }
};

jive.util.fsreadJson('jiveclientconfiguration.json').then( function(options) {
    options['port'] = process.env.PORT || options['port'];
    options['databaseUrl'] = process.env.MONGOLAB_URI || process.env.MONGOHQ_URL || options['databaseUrl'];
    jive.service.init(app, options)
        .then( function() { return jive.service.autowire() } )
        .then( function() { return jive.service.start() } ).then( startServer, failServer );
});

 

What this is doing is reading in your jiveclientconfiguration.json file and then overriding the port and databaseUrl parameters from environment process variables set by Heroku. This app.js should work running locally, or in Heroku!

Purposeful Places - A Focus Lens for Work


With the latest cloud release, Jive introduced Purposeful Places, which are social groups that provide a structured context for user engagement around specific topic or problem. For example, a Salesforce Dealroom lets users keep abreast of the conversation surrounding a Salesforce opportunity, by pipping in relevant Chatter posts and comments into Jive in the form of activity stream entries. Additionally, the group may also present "Tiles" for displaying the latest facts for the opportunity such as monetary value, name of the primary contact, or percentage likelihood of close. Jive enables live updates of these facts by exposing endpoints for 3rd parties to push in data asynchronously.

 

Integration Services & the Jive NodeJS SDK


Jive makes it easy to create these backend services responsible for pushing stream and tile updates into a Purposeful Place! We created a NodeJS SDK for kickstarting your service. On top of Node being an amazing platform for rapid development, the Jive SDK even further accelerates development.  Literally within minutes you can have an service capable of serving the UI for configuring your tiles and activity stream integrations inside a Purposeful Place, as well as push data into these integration points.

 

  • Imitation is the finest form of flattery. In building the jive-sdk, we've tried to copy the patterns of popular frameworks, like Express. You can use the command line tool to autogenerate templates of all the supported flavors of Tiles, as well as full integration examples with popular systems such as Salesforce. Each example is ready out of the box for use, and deployable to the cloud with the minimum fuss. Here's the transcript of setting up a working Salesforce integration. The server was ready to go in minutes.

lt-a7-120000:sfdc aron.racho$ jive-sdk create sfdc_opportunity_activity

Preparing example  sfdc_opportunity_activity /private/tmp/sfdc

... Done!


Contents of tiles directory ( /private/tmp/sfdc/tiles ):

sfdc_opportunity_activity


Things you should do now, if you haven't done them already.

(1) Install dependent modules:  npm update

(2) Don't forget to edit /private/tmp/sfdc/jiveclientconfiguration.json to specify your clientID, clientSecret, clientUrl, and other important setup options!When done, run your service:

  node app.jslt-a7-120000:sfdc aron.racho$ npm install


npm WARN package.json sfdc_opportunity_activity@0.0.1 No README.md file found!...

...└── mongodb@1.2.14 (bson@0.1.8)

lt-a7-120000:sfdc aron.racho$ node app.js

[2013-05-14 23:32:22.497] [INFO] jive-sdk - Saving new definition 'sfdc_opportunity_activity'

[2013-05-14 23:32:22.568] [INFO] jive-sdk - Running bootstrap.

[2013-05-14 23:32:22.573] [INFO] jive-sdk - Bootstrap complete.

[2013-05-14 23:32:22.573] [INFO] jive-sdk - Service started in development mode

Express server listening on port 8090

  • Customize the template through "programming by convention" -- fill in the blanks with logic specific to your application, and as long as you've satisfied the contract, the framework automatically:
    • Wires up Express routes required for configuring your integration.
    • Notifies your listeners for integration life cycle events (integration created; destroyed; updated, etc.).
    • Executes any recurrent tasks.
    • Handles persistence of required objects (built-in support for 3 flavors of persistence out of the box -- in-memory, file, and MondoDB).
  • Easily integrate with OAuth2 providers such Salesforce, using easily customizable built-in support for OAuth2 on the backend and front end. (Initially, we wired up our own OAuth2 handlers. One thing we'll be doing in the near future is incorporating an existing framework for auth, likely Passport.)
  • Build your own custom integration from scratch, or wire in just the pieces you need into your pre-existing service, using the framework's underlying API directly.

 

jive_devslanding_transparent.png

So now you've got a service - go run it on Raspberry Pi!


Right now, Purposeful Places are available in Jive's cloud release, therefore, my service must also be cloud deployed. Though there are lots of great options for hosting NodeJS services on the web (Joyent's NodeJitsu or Heroku), I wanted to deploy my integration service to the cloud in a convenient, easily debuggable environment, over which I had complete control. Enter: The Raspberry Pi!

 

jive-rpi-awesome.jpg

 

Besides the epic geek factor of it all (no need to explain), it is amazing that with about a $60 investment (which includes shipping), we were able to create a pocket-sized integration server, capable of pushing meaningful value into multiple Jive cloud instances! Using the Pi I am able to host my service, easily modify it on the fly for rapid troubleshooting. This process is much more difficult on something like Nodejitsu, where the deploy process can take several minutes (as compared to seconds for making a change, then deploying it live to the cloud again by turning the process back on). Here is a good guide to get your own Raspberry Pi setup with NodeJS.


Easy as Pi

One of the reasons we chose NodeJS for the jive-sdk is because it is lightweight and extremely powerful. While we've still got more work to do in building out the SDK, we were able to be productive in days. I'll be talking about at this at NodePDX later this week. If you happen to be in Portland, come and check it out. Express enabled us to get a server up and running in minutes. From there, we just started filling in the pieces. Using NodeJS on the Raspberry Pi was incredibly easy--and fun. With a dash of SSH and FTP, deployment was a snap. No dealing with firewalls. No deployment hassels on Nodejitsu. It was, easy as Pi!


Filter Blog

By date: By tag: