This Web app demonstrates the usage of the Watson Assistant service in a simple interface with a subject selected.
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!
Click the magical button below to deploy the app.
Will be added soon
- Sign up for an IBM Cloud account.
- Download the IBM Cloud CLI.
- 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>
Download and install VSCode
- If you are having trouble look through the this setup guide
Install Git- this tracks changes so you can recall or recover your work.
-
After installation navigate to the command line.
-
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
-
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.
- Type
git --version
into the CLI to see that Git installed. - Type ..... replacing
your name
and[email protected]
with your github username and github emailgit 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:
- On the right top corner of this repo, click ```
- Above the list of files, click
Code
. - To clone the repository using HTTPS, under "Clone with HTTPS", click .
- Open Git Bash.
$ git config --global credential.helper wincred
- Type
cd documents
- Create a project folder by typing
mkdir Admason
- Navigate into the folder by typing
cd Adamson
- 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
- 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.
- On GitHub, navigate to the original repository.
- Above the list of files, click
Code
, and clone with HTTPS - Open Git Bash
- 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.
- 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)
- 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
- 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 VSCode and click on
Terminal
in the top navigation bar. - Type
cd documents
- Type
cd Adamson
- Type
code .
- 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 selectOpen in Default Browser
or use the keyboard shortcut Alt+B.
- Upon opening VSCode , a welcome page opens.
- 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 .
- type
- In VSCode, lets open
index.html
on the left hand side, typehtml: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 selectOpen in Default Browser
or use the keyboard shortcut Alt+B.
- Lets rename our title to
- 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;
}
- Save all work, right click on
index.html
and selectOpen In Default Browser
-
Strict reduces silent errors, improves performance, provides more warnings, and fewer unsafe features when beginning with JavaScript.
-
Type
'use strict'
-
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 selectOpen In Default Browser
-
Type
git add .
-
Type
git commit -m "Initial commit"
-
Type
git push
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.
Deployment tracking can be disabled by removing the require("cf-deployment-tracker-client").track();
line from the end of the server.js
file.
See CONTRIBUTING.
Find more open source projects on the IBM Github Page.