Skill Level: Intermediate

Recommended to See Prior Tutorials

We will use Node to create a response server and access a cloud database that is set up through the Bluemix catalog. This response server will be hit and the result will be passed through HTML to BPM


  • ClearDB via Bluemix
  • SDK for NodeJS via Bluemix


  1. Set Up Server and DB


    1. Start Via Bluemix
    2. Create a table users
    3. Add a column emailaddress
    4. Populate with some data via the console


    1. Get Server running utilizing code similar to this
    var cfenv = require('cfenv'); // Our CloudFoundry Required code
    var appEnv = cfenv.getAppEnv(); // Part of our Server code required
    var pg = require('pg'); //PostgreSQL Client
    var pgp = require('pg-promise')(); //additional PostGreSQL Interfacing module
    var restify = require('restify');

    function responddatabaseemail(req, res, next) {
    //Response Printed to Browser
    //res.send('This is a database query');

    var cn = {
    host: '',
    port: 5432,
    database: 'bletrspr',
    user: 'bletrspr',
    password: 'bADZG73F28DFBs1si3roWaRz6ol'

    var db = pgp(cn);
    db.query('select emailaddress from users')
    .then(function (data) {
    // success;
    .catch(function (error) {
    // error;


    var server = restify.createServer();
    server.listen(appEnv, function() {
    console.log('%s listening at %s',, server.url);

         3. Push to Bluemix

  2. BPM

    1. Start up your instance of BPM
    2. Inside a process create an implementation service called Pull and Parse DB
    3. Add rawOutput as an output of Type String
    4. Click Implementation in the Systems Data Toolkit
    5. Select Read from HTTP and drop inside the Email Pull Implementation Service
    6. Inside the URL, map it to the BluemixURL given with emaildb as the subdirectory.
      1. Ex. ''
    7. Map the output of Read from HTTP to rawOutput
    8. Add all DataMapping and connect all services
    9. Create a Client Side HumanService called View Database Output
    10. In the HS add a private output called databaseOutput as type string
    11. Add your implementation service before the coach
    12. In the coach add a text box and bind it to databaseOutput
    13. map rawOutput to databaseOutput of the integration service at the clientSide.


  3. Test!

    1. Run your service and ensure that it pulls all the information you need!
    2. If you have any questions reach out to me at

    NOTE PART 2 concerning parsing is located here Parsing (Part 2)

Join The Discussion