Skip navigation

We kicked off the year with a progression in our Developer Days event to move forward and explore a Middleware use-case — specifically WebHook Bi-Directional Sync with an Activity Stream — and work through two built-in examples with the Jive Node SDK (example-webhook and activity-stream) and put the two examples together to post activities into Jive, retrieve a content webhook back and log the response that can be retrieved in a pre-defined endpoint.

 

By attempting to work through this use-case, we discovered a some challenges along the way that needed to be addressed with both the platform and some potential changes to the SDK that needs to be made.

 

The main one being that a content webhook can be narrowed to listen to just one piece of content with a /content endpoint reference URL. However, an ext stream doesn't include that, so we needed to have a noiser webhook (event type: "extStreamActivity") and filter out the specific Activity in our middleware for future syncing.

 

 

For those who attended, below are snippets of changes we made to the activity-stream example:

• Update /services/services.js (add below BootStrap) 

/**** HANDLES CALLBACK FROM ACTIVITY PUSH ****/

exports.eventHandlers = [



  'event' : jive.constants.globalEventNames.ACTIVITY_PUSHED,

  'handler' : function (context) {

    console.log('****','ACTIVITY PUSHED',context);



  'description' : 'Check for Activity Pushed'

}

]; // end 

• Update /services/DevDaysWebhooks/backend/routes/explicit_routes.js  line #41 

   /**** LOOKS UP THE CONTENT OBJECT TO GET FULL DETAILS ***/

              //NOTE:  YOU CAN ALSO LOOKUP VIA THE WEBHOOK DEFINITION
              jive.community.findByTenantID(req.headers["x-tenant-id"]).then(
                function(community) {
                    if (community) {
                      jive.community.doRequest(community,{
                         /*** NOTE: THE SILENT DIRECTIVE THIS WILL PREVENT THIS REQUEST FROM COUNTING AS A READ ***/
                         "url" : activity["activity"]["object"]["id"]+"?directive=silent",
                         "method" : "GET",
                         "headers" :  {
                             "content-type" : "application/json"
                         }
                       }).then(
                        function(success) {
                          var content = success["entity"];
                          console.log('Your External ID is:',content["externalID"]);
                        }, function(error) {
                          jive.logger.error("UNABLE TO GET OBJECT DETAILS",error)
                        }
                      );
                    } // end if
                } // end function
              );



• jive-sdk build … re-install.  Re-configure your webhook Tile. 

• Talk about /services/DevDaysWebhooks/backend/routes/oauth/sampleOAuth.js

• Start/Stop Service


○ HACK:  Copy /db/tokens.json {  "accessToken" : {} } to /db/community.json {  "oauth" : {} } 

Install Activity Tile … configure to "on" and Save

Filter Blog