Giter Club home page Giter Club logo

adamsonwatson's Introduction

πŸš€ Web UI w/ Watson Assistant API Sample Application

This Web app demonstrates the usage of the Watson Assistant service in a simple interface with a subject selected.

Travis Github contributors Documentation Maintenance


Key Features β€’ Prerequisites β€’ Installation β€’ How To Use β€’ Contributing


This is an OpenSource starter application on IBM Cloud that is full stack ready with a node.js back end. It uses Github to host the code as well as Kubernetes/Docker to containerize and deploy to the IBM Cloud. Below you will find a UI design that was created to go along with this project. This project needs **YOU** to finish where it leaves off. This document should provide almost everything you need to hit the ground running!

Sulu Slideshow Sulu Slideshow


Click the magical button below to deploy the app.

Deploy to IBM Cloud

Key Features

Will be added soon

Prerequisites

  1. Sign up for an IBM Cloud account.
  2. Download the IBM Cloud CLI.
  3. Create an instance of the Watson Assistant service and get API script:
<script>
window.watsonAssistantChatOptions = {
    integrationID: "485509de-1bc0-4812-a3db-0338aeff81e2", // The ID of this integration.
    region: "us-south", // The region your integration is hosted in.
    serviceInstanceID: "ddba29a8-ea6f-4dc4-9edd-d73ebf17e48f", // The ID of your service instance.
    onLoad: function(instance) { instance.render(); }
  };
setTimeout(function(){
  const t=document.createElement('script');
  t.src="https://web-chat.global.assistant.watson.appdomain.cloud/loadWatsonAssistantChat.js";
  document.head.appendChild(t);
});
</script>

Installation

Downloading and installing steps: Install and setup your environment

Download and install VSCode

  1. If you are having trouble look through the this setup guide

Install Git- this tracks changes so you can recall or recover your work.

  1. After installation navigate to the command line.

  2. In windows 10 , navigate to the CLI using one of the following methods.

    • Start menu > Windows System > Command Prompt
    • Start menu > Windows PowerShell > Windows PowerShell
    • Windows Logo Key+X
  3. For macOS, you can find the CLI using one of the following methods.

    • In Finder menu bar, navigate to Go > Utilities > Terminal
    • Or in Finder, navigate to Applications > Utilities > Terminal
    • Or use the shortcut Command+Shift+U and select Terminal to open.

Setup your Git identity

  1. Type git --version into the CLI to see that Git installed.
  2. Type ..... replacing your name and [email protected] with your github username and github email
    git config --global user.name "Your Name"
    git config --global user.email [email protected]
    

This repo contains a complete sample of a node.js program that you can deploy on IBM's Bluemix PaaS, which is based on the Cloud Foundry open source project.

Before jumping into the code, make sure you have an IBM ID, by registering at the IBM ID registration page. You will need the IBM ID to login to Bluemix from the command line.

You will also need to install the cf command-line tool, available here:

Instructions on how to use this repository as a basis to start your project

Create a local clone of this fork

  1. On the right top corner of this repo, click ```
  2. Above the list of files, click Code.
  3. To clone the repository using HTTPS, under "Clone with HTTPS", click .
  4. Open Git Bash.
  5. $ git config --global credential.helper wincred
  6. Type cd documents
  7. Create a project folder by typing mkdir Admason
  8. Navigate into the folder by typing cd Adamson
  9. Type git clone, and then paste the URL you copied earlier. It will look like this, with your GitHub username instead of YOUR-USERNAME:
$ git clone https://github.com/YOUR-USERNAME/Spoon-Knife
  1. Press Enter. Your local clone will be created.
$ git clone https://github.com/YOUR-USERNAME/Spoon-Knife
> Cloning into `Spoon-Knife`...
> remote: Counting objects: 10, done.
> remote: Compressing objects: 100% (8/8), done.
> remove: Total 10 (delta 1), reused 10 (delta 1)
> Unpacking objects: 100% (10/10), done.

Configure git to sync with original repository

  1. On GitHub, navigate to the original repository.
  2. Above the list of files, click Code, and clone with HTTPS
  3. Open Git Bash
  4. Change directories to the location of the fork you cloned in above.
    • To go to your home directory, type just cd with no other text.
    • To go into one of your listed directories, type cd your_listed_directory.
  5. Type git remote -v and press Enter. You'll see the current configured remote repository for your fork.
$ git remote -v
> origin  https://github.com/YOUR_USERNAME/YOUR_FORK.git (fetch)
> origin  https://github.com/YOUR_USERNAME/YOUR_FORK.git (push)
  1. Type git remote add upstream, and then paste the URL you copied earlier and press Enter. It will look like this:
$ git remote add upstream https://github.com/octocat/Spoon-Knife.git
  1. To verify the new upstream repository you've specified for your fork, type git remote -v again. You should see the URL for your fork as origin, and the URL for the original repository as upstream.
$ git remote -v
> origin    https://github.com/YOUR_USERNAME/YOUR_FORK.git (fetch)
> origin    https://github.com/YOUR_USERNAME/YOUR_FORK.git (push)
> upstream  https://github.com/ORIGINAL_OWNER/ORIGINAL_REPOSITORY.git (fetch)
> upstream  https://github.com/ORIGINAL_OWNER/ORIGINAL_REPOSITORY.git (push)

Open up this repository with VSCode

  1. Open VSCode and click on Terminal in the top navigation bar.
  2. Type cd documents
  3. Type cd Adamson
  4. Type code .
  5. Navigate to the icons on the left, click the boxes icon, type in open in broswer. This is an extension that will allow you to view your code in the broswer. Install the one by TechER.
  6. Navigate back to the index.html file. Hover over the file, right click and select Open in Default Browser or use the keyboard shortcut Alt+B.

Instructions on how to create your own project

Set up the structure of your web app

Opening with Visual Studio Code

  1. Upon opening VSCode , a welcome page opens.
  2. At the top, click terminal, new terminal.
    • type cd documents
    • Create a project folder by typing mkdir Admason
    • Navigate into the folder by typing cd Adamson
    • We must then initialize our project as a git repo, type git init
    • Lets create some files to get us started, type...
    code index.html main.css app.js
    
    • Lets see what we made, this next command will open a new window into the prject directory
    code .
    

Lets add some text to our web app

  1. In VSCode, lets open index.html on the left hand side, type html:5, and hit enter.
    • Lets rename our title to Adamson
    • Lets add some body
    <body>
      <h1>Task Timeline</h1>
      <p id="date"></p>
      <ul>
        <li class="list">Edit the head</li>
        <li class="list">Edit the body</li>
        <li>Link to JavaScript</li>
      </ul>
    </body>
    
    • Lets link to the JavaScript file, type script: src right before the last body tag. Your code should look like this.
    <!DOCTYPE html>
    <html lang="en" dir="ltr">
      <head>
        <meta charset="utf-8">
        <title>Task Timeline</title>
        <link rel="stylesheet" href="main.css">
      </head>
      <body>
        <h1>Task Timeline</h1>
        <p id="date"></p>
        <ul>
          <li class="list">Edit the head</li>
          <li class="list">Edit the body</li>
          <li>Link to JavaScript</li>
        </ul>
        <script src="app.js"></script>
      </body>
    </html>
    
    • Navigate to the icons on the left, click the boxes icon, type in open in broswer. This is an extension that will allow you to view your code in the broswer. Install the one by TechER.
    • Navigate back to the index.html file. Hover over the file, right click and select Open in Default Browser or use the keyboard shortcut Alt+B.

Lets add some styling to our web app

  1. Open the main.css file and type...
body {
font-family: helvetica;
}

ul {
font-family: monospace;
}

li {
list-style: circle;
}

.list {
list-style: square;
}

#date {
font-size: 12px;
font-style: italic;
font-weight: bold;
}
  1. Save all work, right click on index.html and select Open In Default Browser

Lets add some JavaScript

Implementing strict mode

  1. Strict reduces silent errors, improves performance, provides more warnings, and fewer unsafe features when beginning with JavaScript.

  2. Type 'use strict'

  3. Add todays date

    • First, you'll retrieve a new date from the built-in JavaScript object. It looks like this new Date().
    • Next, you can transform the date format by using toDateString().
    • The HTML needs to know where you want to add this information on the page or document, so retrieve an element using getElementById('date').
    • The final step is to insert the date string inside the selected element with innerHTML.
    let today = new Date();
    let formatDate = today.toDateString();
    let selectElement = document.getElementById('date');
    selectElement.innerHTML = formatDate;
    
    • Here we're using the word let to create a variable named today, which holds the date and time. It's a convention to use camel case for variable names with more than one wordβ€”for example, the variable formatDate.

    • When you declare a variable, it holds a reference to the value you assign. Variables are a useful way of storing information temporarily so you can reuse the values. In the selectElement variable, you're saving the result of reformatting the date. In that step, you remove the time and timezone from using toDateString().

    • Save all work, right click on index.html and select Open In Default Browser

Lets Track our changes with Git

Open Terminal on VSCode

  1. Type git add .

  2. Type git commit -m "Initial commit"

  3. Type git push

privacy notice

This web application includes code to track deployments to IBM Bluemix and other Cloud Foundry platforms. The following information is sent to a Deployment Tracker service on each deployment:

  • Application Name (application_name)
  • Space ID (space_id)
  • Application Version (application_version)
  • Application URIs (application_uris)

This data is collected from the VCAP_APPLICATION environment variable in IBM Bluemix and other Cloud Foundry platforms. This data is used by IBM to track metrics around deployments of sample applications to IBM Bluemix to measure the usefulness of our examples, so that we can continuously improve the content we offer to you. Only deployments of sample applications that include code to ping the Deployment Tracker service will be tracked.

disabling deployment tracking

Deployment tracking can be disabled by removing the require("cf-deployment-tracker-client").track(); line from the end of the server.js file.

Contributing

See CONTRIBUTING.

Open Source @ IBM

Find more open source projects on the IBM Github Page.

adamsonwatson's People

Contributors

engineeredcurlz avatar pmuellr avatar jsloyer avatar rvennam avatar stevemar avatar rvennam987 avatar bradley-holt avatar rophy avatar

Watchers

James Cloos avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    πŸ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. πŸ“ŠπŸ“ˆπŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❀️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.