Connecting Google Forms to Acquia Journey

October 30, 2017
2
journey orbiting

Acquia's new Journey offering is, put simply, an orchestration engine: providing a means of connecting disparate tools into complex flows driven not just by data but also the behavior of your users.

In building out these journeys, I've found the reference to an orchestra to be especially apt. Like an orchestra, when you can combine the outputs of diverse sections in a harmonious and coordinated way, you can create something awesome. But each section has to be ready to work together.

When one section isn't ready to join the orchestra, you either have to stop everything and wait for them or come up with a temporary solution -- so the rest of the orchestra can play while the woodwinds, for instance, get up to speed.

We encountered this situation recently when setting up an on-boarding Journey for the Acquia Ready team. The system which needed to trigger the Journey wasn't yet ready to be part of the orchestra, so we needed a way for a member of the Ready team to provide the necessary inputs to the Journey and trigger it manually.

The solution we came up with was to create a Google Form and wire it up to a Journey API listener using a custom trigger which responds on the form's submit event.

The trigger takes the submitted data and sends it via POST to the endpoint created by Journey when we set up the API listener. As you can see below, it is really simple. Most of the function is just reformatting the data into an object structure for ingestion by Journey.

function submitToJourney(e) {
  var journeyEndPoint = <your journey API endpoint goes here>;
  var itemResponses = e.response.getItemResponses();

  // Convert array of ItemReponse objects to POJsonO (Plain Old JSON Object)
  var formData = {};
  for (var j = 0; j < itemResponses.length; j++) {
var itemResponse = itemResponses[j];
formData[itemResponse.getItem().getTitle()] =  itemResponse.getResponse();
  }

  var options = {
'method' : 'post',
'contentType': 'application/json',
'payload' : JSON.stringify(formData)
  };

   var response = UrlFetchApp.fetch(journeyEndPoint, options);
}

Then within Journey itself, the first node just validates the data coming in from the listener and passes it through to kick off the next phase of the journey.

Our orchestra may not have woodwinds yet, but the kazoo section is sounding just fine and serves well enough to lead off and set the stage for the rest of the instruments.

Sign-up for our Developer Blog Newsletter

Thanks!

Add comment

By submitting this form, you accept the Mollom privacy policy.