Skip to content

Commit 936bfbf

Browse files
fix: update README and dependencies
1 parent 96e33c4 commit 936bfbf

11 files changed

Lines changed: 8991 additions & 10046 deletions

.env.example

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,4 @@
1+
# Environment variables
2+
ASSISTANT_URL=https://gateway.watsonplatform.net/assistant/api
3+
ASSISTANT_IAM_APIKEY=
4+
ASSISTANT_ID=

.travis.yml

Lines changed: 8 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -1,10 +1,6 @@
11
language: node_js
2-
dist: trusty
3-
sudo: required
4-
node_js: "8"
5-
script:
6-
- npm run build
7-
- npm test
2+
dist: xenial
3+
node_js: "10"
84
cache:
95
directories:
106
- node_modules
@@ -15,18 +11,19 @@ env:
1511
- BX_ORGANIZATION=WatsonPlatformServices
1612
- BX_SPACE=demos
1713
- B_DOMAIN=ng.bluemix.net
14+
script:
15+
- npm run build
16+
- npm test
17+
1818
before_deploy:
1919
- npm install -g bx-blue-green
2020
deploy:
2121
- provider: script
2222
script: bx-blue-green-travis
2323
on:
2424
branch: master
25-
repo: Watson/watson-conversation-demo-redesign
25+
repo: watson-developer-cloud/assistant-demo
2626
skip_cleanup: true
2727
- provider: script
28-
script: BX_APP=watson-conversation-duo-test bx-blue-green-travis
29-
on:
30-
branch: dev
31-
repo: Watson/watson-conversation-demo-redesign
3228
skip_cleanup: true
29+
script: npx semantic-release

ISSUE_TEMPLATE.md

Lines changed: 0 additions & 17 deletions
This file was deleted.

README.md

Lines changed: 124 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1 +1,124 @@
1-
<h1 align="center" style="border-bottom: none;">🚀 Watson Assistant Demo Sample Application</h1>
1+
<h1 align="center" style="border-bottom: none;">🚀 Watson Assistant Duo Demo</h1>
2+
3+
[![Build Status](https://travis-ci.org/watson-developer-cloud/assistant-demo.svg?branch=master)](https://travis-ci.org/watson-developer-cloud/assistant-demo)
4+
5+
In this sample application, you're engaging with a banking virtual assistant. The assistant simulates a few scenarios, such as making a credit card payment, booking an appointment with a banker and choosing a credit card. Watson can understand your entries and respond accordingly.
6+
7+
8+
[![Demo](./demo.gif)](https://watson-assistant-demo.ng.bluemix.net)
9+
10+
11+
12+
## Prerequisites
13+
14+
1. Sign up for an [IBM Cloud account](https://cloud.ibm.com/registration).
15+
1. Download the [IBM Cloud CLI](https://cloud.ibm.com/docs/cli/index.html#overview).
16+
1. Create an instance of the Watson Assistant service and get your credentials:
17+
- Go to the [Watson Assistant][service_url] page in the IBM Cloud Catalog.
18+
- Log in to your IBM Cloud account.
19+
- Click **Create**.
20+
- Click **Show** to view the service credentials.
21+
- Copy the `apikey` value.
22+
- Copy the `url` value.
23+
24+
## Configuring the application
25+
26+
1. In the application folder, copy the *.env.example* file and create a file called *.env*
27+
28+
```
29+
cp .env.example .env
30+
```
31+
32+
2. Open the *.env* file and add the service credentials that you obtained in the previous step.
33+
34+
Example *.env* file that configures the `apikey` and `url` for a Watson Assistant service instance hosted in the US East region:
35+
36+
```
37+
ASSISTANT_IAM_APIKEY=X4rbi8vwZmKpXfowaS3GAsA7vdy17Qh7km5D6EzKLHL2
38+
ASSISTANT_URL=https://gateway-wdc.watsonplatform.net/assistant/api
39+
```
40+
41+
## Running locally
42+
43+
1. Install the dependencies
44+
45+
```
46+
npm install
47+
```
48+
49+
1. Run the application
50+
51+
```
52+
npm start
53+
```
54+
55+
1. View the application in a browser at `localhost:3000`
56+
57+
## Deploying to IBM Cloud as a Cloud Foundry Application
58+
59+
1. Login to IBM Cloud with the [IBM Cloud CLI](https://cloud.ibm.com/docs/cli/index.html#overview)
60+
61+
```
62+
ibmcloud login
63+
```
64+
65+
1. Target a Cloud Foundry organization and space.
66+
67+
```
68+
ibmcloud target --cf
69+
```
70+
71+
1. Edit the *manifest.yml* file. Change the **name** field to something unique.
72+
For example, `- name: my-app-name`.
73+
1. Deploy the application
74+
75+
```
76+
ibmcloud app push
77+
```
78+
79+
1. View the application online at the app URL.
80+
For example: https://my-app-name.mybluemix.net
81+
82+
83+
## Codebase Structure
84+
85+
```s
86+
Root
87+
/src
88+
index.js (React frontend index)
89+
/components
90+
/ExampleComponentDirectory
91+
ExampleComponent.js
92+
ExampleComponent.test.js
93+
/public
94+
index.html (served at the root route)
95+
/styles
96+
duo-grid.min.css (Duo grid styles)
97+
/js
98+
bundle.js (imports the root react component)
99+
/config
100+
Configuration files for Express backend
101+
/test
102+
Backend unit and integration tests
103+
index.js (express backend)
104+
server.js (main backend entry point)
105+
.config files
106+
package.json
107+
```
108+
109+
## License
110+
111+
This sample code is licensed under Apache 2.0.
112+
Full license text is available in [LICENSE](LICENSE).
113+
114+
## Contributing
115+
116+
See [CONTRIBUTING](CONTRIBUTING.md).
117+
118+
## Open Source @ IBM
119+
120+
Find more open source projects on the
121+
[IBM Github Page](http://ibm.github.io/).
122+
123+
[service_url]: https://www.ibm.com/cloud/watson-assistant/
124+
[docs]: https://cloud.ibm.com/docs/services/assistant/index.html#about

config/webpack.config.common.js

Lines changed: 0 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,5 @@
11
const path = require('path');
22
const HtmlWebpackPlugin = require('html-webpack-plugin');
3-
const CleanWebpackPlugin = require('clean-webpack-plugin');
43
const StyleLintPlugin = require('stylelint-webpack-plugin');
54

65
const distDir = path.resolve(__dirname, '..', 'dist');
@@ -60,11 +59,6 @@ module.exports = {
6059
],
6160
},
6261
plugins: [
63-
new CleanWebpackPlugin([distDir], {
64-
root: path.resolve(__dirname, '..'),
65-
verbose: true,
66-
dry: false,
67-
}),
6862
new HtmlWebpackPlugin({
6963
title: 'Production',
7064
template: 'public/index.html',

demo.gif

449 KB
Loading

index.js

Lines changed: 7 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -23,9 +23,7 @@ const bank = require('./lib/bankFunctions');
2323

2424
// declare Watson Assistant service
2525
const assistant = new AssistantV2({
26-
version: '2018-11-08',
27-
username: process.env.ASSISTANT_USERNAME || '<username>',
28-
password: process.env.ASSISTANT_PASSWORD || '<password>',
26+
version: '2019-01-01',
2927
});
3028

3129
const date = new Date();
@@ -57,9 +55,9 @@ app.get('/', (req, res) => {
5755
});
5856

5957
app.post('/api/message', (req, res) => {
60-
// check for workspace id and handle null workspace env variable
61-
const assistantId = process.env.ASSISTANT_ID || '<workspace-id>';
62-
if (!assistantId || assistantId === '<workspace-id>') {
58+
// check for assistant id and handle null assistant env variable
59+
const assistantId = process.env.ASSISTANT_ID || '<assistant-id>';
60+
if (!assistantId || assistantId === '<assistant-id>') {
6361
return res.json({
6462
output: {
6563
text: 'The app has not been configured with a ASSISTANT_ID environment variable.',
@@ -96,9 +94,10 @@ app.post('/api/message', (req, res) => {
9694
// send payload to Conversation and return result
9795
assistant.message(payload, (err, data) => {
9896
if (err) {
97+
console.log(err);
9998
// TODO: return error from service, currently service returns non-legal
10099
// status code
101-
return res.status(500).jsonp(err);
100+
return res.status(err.code || 500).json(err);
102101
}
103102

104103
return res.json(data);
@@ -135,7 +134,7 @@ app.get('/api/session', (req, res) => {
135134
assistant_id: process.env.ASSISTANT_ID || '{assistant_id}',
136135
}, (error, response) => {
137136
if (error) {
138-
return res.send(error);
137+
return res.status(error.code || 500).send(error);
139138
}
140139
return res.send(response);
141140
});

manifest.yml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
---
22
applications:
33
- name: watson-assistant-duo
4-
- path: .
54
command: npm start
5+
buildpack: sdk-for-nodejs
66
env:
77
NODE_ENV: production

0 commit comments

Comments
 (0)