Skip to content

Running Locally

biosopher edited this page Nov 4, 2015 · 17 revisions

Running locally

  1. Configure the code to connect to your service:

i. Copy the credentials from your natural-language-classifier-service service in Bluemix. Run the following command:

$ cf env <application-name>

Example output:

System-Provided:
{
  "VCAP_SERVICES": {
    "natural_language_classifier": [
      {
        "credentials": {
          "password": "<password>",
          "url": "<url>",
          "username": "<username>"
        }
        "label": "natural-language-classifier",
        "name": "natural-language-classifier-service",
        "plan": "free",
        "tags": [
          ... 
        ]
      }
    ]
  }
}

ii. Copy username, password, and url from the credentials.

  1. Enter these credentials into app.js.
    The section below shows where you need to do this. Replace <username> and <password> for both NLC & Dialog services with appropriate username and password from each service that you obtained in the prior step.

    var dialogCredentials =  extend({
        url: "https://gateway.watsonplatform.net/dialog/api",
        username: "<username>",
        password: "<password>"
    }, bluemix.getServiceCreds('dialog')); // VCAP_SERVICES
    
    // if bluemix credentials exists, then override local
    var nlcCredentials =  extend({
        "url": "https://gateway.watsonplatform.net/natural-language-classifier/api",
        username: "<username>",
        password: "<password>"
    }, bluemix.getServiceCreds('nlc')); // VCAP_SERVICES
    
  2. Download and install Node.js and npm.

  3. Install all packages required by Node.JS

i. Change to the new directory that contains the project.

ii. Run the following command:node

$ npm install
  1. Run the following command to start the application:
node app.js
  1. Point your browser to http://localhost:3000.

Invalid Credentials?

If you see this error, you likely did not enter your service credentials properly.