Skip to content

Commit f2c4ef3

Browse files
author
Steve Green
authored
Merge pull request #8 from watson-developer-cloud/update-dependencies
Update README, Travis and dependencies
2 parents fb0f453 + 15db8fe commit f2c4ef3

12 files changed

Lines changed: 8910 additions & 10091 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: 32 additions & 45 deletions
Original file line numberDiff line numberDiff line change
@@ -1,48 +1,56 @@
1-
<h1 align="center" style="border-bottom: none;">🚀 Watson Assistant (formerly Conversation) Demo Sample Application</h1>
2-
<h3>This app demonstrates the Watson Assistant service via a complete, complex interface which engages in simulated banking tasks.<br><br>It utilises features such as:<ul><li>Cloud Functions</li><li>Actions and UI Actions</li><li>Slots</li><li>Multi-Conditional Responses</li><li>Multi-Modal Responses</li></h3>
1+
<h1 align="center" style="border-bottom: none;">🚀 Watson Assistant Duo Demo</h1>
32

4-
![Demo](readme_images/demo.gif)
3+
[![Build Status](https://travis-ci.org/watson-developer-cloud/assistant-demo.svg?branch=master)](https://travis-ci.org/watson-developer-cloud/assistant-demo)
54

6-
You can view a [demo][demo_url] of this app.
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+
This app demonstrates the Watson Assistant service via a complete, complex interface which engages in simulated banking tasks. It utilises features such as:
8+
* Cloud Functions
9+
* Actions and UI Actions
10+
* Slots
11+
* Multi-Conditional Responses
12+
* Multi-Modal Responses
13+
14+
15+
[![Demo](./readme_images/demo.gif)](https://watson-assistant-demo.ng.bluemix.net)
716

817

9-
Please note this app uses the [Watson Assistant V2 API](https://console.bluemix.net/apidocs/assistant-v2#introduction).
1018

1119
## Prerequisites
1220

13-
1. Sign up for an [IBM Cloud account](https://console.bluemix.net/registration/).
14-
1. Download the [IBM Cloud CLI](https://cloud.ibm.com/docs/cli?topic=cloud-cli-ibmcloud-cli#overview).
21+
1. Sign up for an [IBM Cloud account](https://cloud.ibm.com/registration).
22+
1. Download the [IBM Cloud CLI](https://cloud.ibm.com/docs/cli/index.html#overview).
1523
1. Create an instance of the Watson Assistant service and get your credentials:
16-
- Go to the [Watson Assistant](https://console.bluemix.net/catalog/services/conversation) page in the IBM Cloud Catalog.
24+
- Go to the [Watson Assistant][service_url] page in the IBM Cloud Catalog.
1725
- Log in to your IBM Cloud account.
1826
- Click **Create**.
1927
- Click **Show** to view the service credentials.
20-
- Copy the `apikey` value, or copy the `username` and `password` values if your service instance doesn't provide an `apikey`.
28+
- Copy the `apikey` value.
2129
- Copy the `url` value.
2230

2331
## Configuring the application
2432

2533
1. In your IBM Cloud console, open the Watson Assistant service instance
2634

27-
2. Click the **Import workspace** icon in the Watson Assistant service tool. Specify the location of the workspace JSON file in your local copy of the app project:
35+
1. Click the **Import workspace** icon in the Watson Assistant service tool. Specify the location of the workspace JSON file in your local copy of the app project:
2836

2937
`<project_root>/training/banking_workspace.json`
3038

31-
3. Select **Everything (Intents, Entities, and Dialog)** and then click **Import**. The car dashboard workspace is created.
39+
1. Select **Everything (Intents, Entities, and Dialog)** and then click **Import**. The car dashboard workspace is created.
3240

33-
4. Click the menu icon in the upper-right corner of the workspace tile, and then select **View details**.
41+
1. Click the menu icon in the upper-right corner of the workspace tile, and then select **View details**.
3442

35-
5. Click the ![Copy](readme_images/copy_icon.png) icon to copy the workspace ID to the clipboard.
43+
1. Click the ![Copy](readme_images/copy_icon.png) icon to copy the workspace ID to the clipboard.
3644

3745
![Steps to get credentials](readme_images/assistant-demo.gif)
3846

39-
6. In the application folder, copy the *.env.example* file and create a file called *.env*
47+
1. In the application folder, copy the *.env.example* file and create a file called *.env*
4048

4149
```
4250
cp .env.example .env
4351
```
4452
45-
7. Open the *.env* file and add the service credentials that you obtained in the previous step. The Watson SDK automaticaly locates the correct enviromental variables for either `username`, `password`, and `url` or the `apikey` and `url` credentials found in the *.env* file.
53+
1. Open the *.env* file and add the service credentials that you obtained in the previous step.
4654
4755
Example *.env* file that configures the `apikey` and `url` for a Watson Assistant service instance hosted in the US East region:
4856
@@ -51,32 +59,7 @@ Please note this app uses the [Watson Assistant V2 API](https://console.bluemix.
5159
ASSISTANT_URL=https://gateway-wdc.watsonplatform.net/assistant/api
5260
```
5361
54-
- If your service instance uses `username` and `password` credentials, add the `ASSISTANT_USERNAME` and `ASSISTANT_PASSWORD` variables to the *.env* file.
55-
56-
Example *.env* file that configures the `username`, `password`, and `url` for a Watson Assistant service instance hosted in the US South region:
57-
58-
```
59-
ASSISTANT_USERNAME=522be-7b41-ab44-dec3-g1eab2ha73c6
60-
ASSISTANT_PASSWORD=A4Z5BdGENrwu8
61-
ASSISTANT_URL=https://gateway.watsonplatform.net/assistant/api
62-
```
63-
However, if your credentials contain an IAM API key, copy the `apikey` and `url` to the relevant fields.
64-
```JSON
65-
{
66-
"apikey": "ca2905e6-7b5d-4408-9192-e4d54d83e604",
67-
"iam_apikey_description": "Auto generated apikey during resource-key ...",
68-
"iam_apikey_name": "auto-generated-apikey-62b71334-3ae3-4609-be26-846fa59ece42",
69-
"iam_role_crn": "crn:v1:bluemix:public:iam::::serviceRole:Manager",
70-
"iam_serviceid_crn": "crn:v1:bluemix:public:iam...",
71-
"url": "https://gateway-syd.watsonplatform.net/assistant/api"
72-
}
73-
```
74-
```
75-
ASSISTANT_IAM_APIKEY=ca2905e6-7b5d-4408-9192-e4d54d83e604
76-
ASSISTANT_IAM_URL=https://gateway-syd.watsonplatform.net/assistant/api
77-
```
78-
79-
8. Add the `ASSISTANT_ID` to the previous properties
62+
1. Add the `ASSISTANT_ID` to the previous properties
8063
8164
```
8265
ASSISTANT_ID=522be-7b41-ab44-dec3-g1eab2ha73c6
@@ -129,13 +112,17 @@ For example: https://my-app-name.mybluemix.net
129112
This sample code is licensed under Apache 2.0.
130113
Full license text is available in [LICENSE](LICENSE).
131114
115+
## Contributing
116+
117+
See [CONTRIBUTING](CONTRIBUTING.md).
132118
119+
## Open Source @ IBM
133120
121+
Find more open source projects on the
122+
[IBM Github Page](http://ibm.github.io/).
134123
124+
[service_url]: https://www.ibm.com/cloud/watson-assistant/
125+
[docs]: https://cloud.ibm.com/docs/services/assistant/index.html#about
135126
[demo_url]: http://assistant-demo.ng.bluemix.net/
136127
[doc_intents]: (https://cloud.ibm.com/docs/services/assistant?topic=assistant-intents#intents)
137-
[docs]: https://cloud.ibm.com/docs/services/assistant?topic=assistant-getting-started#getting-started
138128
[docs_landing]: (https://cloud.ibm.com/docs/services/assistant?topic=assistant-getting-started#getting-started)
139-
[node_link]: (http://nodejs.org/)
140-
[npm_link]: (https://www.npmjs.com/)
141-
[sign_up]: https://console.bluemix.net/registration

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',

config/webpack.config.prod.js

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,10 +1,14 @@
11
const webpack = require('webpack');
2+
const path = require('path');
23
const merge = require('webpack-merge');
34
const UglifyJSPlugin = require('uglifyjs-webpack-plugin');
45
const ExtractTextPlugin = require('extract-text-webpack-plugin');
56
const CompressionPlugin = require('compression-webpack-plugin');
7+
const CleanWebpackPlugin = require('clean-webpack-plugin');
68
const common = require('./webpack.config.common');
79

10+
const distDir = path.resolve(__dirname, '..', 'dist');
11+
812
const extractSass = new ExtractTextPlugin({
913
filename: '[name].[contenthash].css',
1014
disable: process.env.NODE_ENV === 'development',
@@ -33,6 +37,11 @@ module.exports = merge.smart(common, {
3337
},
3438

3539
plugins: [
40+
new CleanWebpackPlugin([distDir], {
41+
root: path.resolve(__dirname, '..'),
42+
verbose: true,
43+
dry: false,
44+
}),
3645
new UglifyJSPlugin({
3746
sourceMap: true,
3847
uglifyOptions: { ecma: 8 },

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)