Skip to content

Commit 086cb0a

Browse files
Merge pull request #21 from watson-developer-cloud/up
fix: Update dependencies and fix travis
2 parents a939b98 + 061c9b0 commit 086cb0a

File tree

9 files changed

+476
-331
lines changed

9 files changed

+476
-331
lines changed

.env.example

Lines changed: 2 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,3 @@
1-
# Environment variables
21
ASSISTANT_ID=
3-
# You need to provide your IAM API key and URL
4-
ASSISTANT_IAM_APIKEY=
5-
ASSISTANT_IAM_URL=
6-
ASSISTANT_URL=https://gateway.watsonplatform.net/assistant/api
2+
ASSISTANT_URL=
3+
ASSISTANT_IAM_APIKEY=

.travis.yml

Lines changed: 19 additions & 19 deletions
Original file line numberDiff line numberDiff line change
@@ -1,29 +1,29 @@
11
language: node_js
22
dist: xenial
3-
node_js: "10"
3+
node_js: '12'
44
cache:
55
directories:
6-
- node_modules
6+
- node_modules
77
env:
88
global:
9-
- BX_APP=watson-conversation-duo-dev
10-
- BX_API=https://api.ng.bluemix.net
11-
- BX_ORGANIZATION=WatsonPlatformServices
12-
- BX_SPACE=demos
13-
- B_DOMAIN=ng.bluemix.net
9+
- BX_APP=watson-conversation-duo-dev
10+
- BX_API=https://api.ng.bluemix.net
11+
- BX_ORGANIZATION=WatsonPlatformServices
12+
- BX_SPACE=demos
13+
- B_DOMAIN=ng.bluemix.net
1414
script:
15-
- npm run build
16-
- npm test
15+
- npm run build
16+
- npm test
1717

1818
before_deploy:
19-
- npm install -g bx-blue-green
19+
- npm install -g bx-blue-green
2020
deploy:
21-
- provider: script
22-
script: bx-blue-green-travis
23-
on:
24-
branch: master
25-
repo: watson-developer-cloud/assistant-demo
26-
skip_cleanup: true
27-
- provider: script
28-
skip_cleanup: true
29-
script: npx semantic-release
21+
- provider: script
22+
script: bx-blue-green-travis
23+
on:
24+
branch: master
25+
repo: watson-developer-cloud/assistant-demo
26+
skip_cleanup: true
27+
- provider: script
28+
skip_cleanup: true
29+
script: npx semantic-release

CONTRIBUTING.md

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,3 @@
1-
21
## Reporting a bug
32

43
If you encounter an issue with the Node.js library, you are welcome to submit a [bug report](https://github.com/watson-developer-cloud/assistant-demo/issues). Before that, please search for similar issues. It's possible somebody has already encountered this issue.

README.md

Lines changed: 44 additions & 47 deletions
Original file line numberDiff line numberDiff line change
@@ -4,15 +4,13 @@
44

55
### 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.
66

7-
87
This app demonstrates the Watson Assistant service via a complete, complex interface which engages in simulated banking tasks. It utilises features such as:
98

10-
* Cloud Functions
11-
* Actions and UI Actions
12-
* Slots
13-
* Multi-Conditional Responses
14-
* Multi-Modal Responses
15-
9+
- Cloud Functions
10+
- Actions and UI Actions
11+
- Slots
12+
- Multi-Conditional Responses
13+
- Multi-Modal Responses
1614

1715
[![Demo](./readme_images/demo.gif)](https://watson-assistant-demo.ng.bluemix.net)
1816

@@ -21,91 +19,90 @@ This app demonstrates the Watson Assistant service via a complete, complex inter
2119
1. Sign up for an [IBM Cloud account](https://cloud.ibm.com/registration).
2220
1. Download the [IBM Cloud CLI](https://cloud.ibm.com/docs/cli/index.html#overview).
2321
1. Create an instance of the Watson Assistant service and get your credentials:
24-
- Go to the [Watson Assistant][service_url] page in the IBM Cloud Catalog.
25-
- Log in to your IBM Cloud account.
26-
- Click **Create**.
27-
- Click **Show** to view the service credentials.
28-
- Copy the `apikey` value.
29-
- Copy the `url` value.
22+
- Go to the [Watson Assistant][service_url] page in the IBM Cloud Catalog.
23+
- Log in to your IBM Cloud account.
24+
- Click **Create**.
25+
- Click **Show** to view the service credentials.
26+
- Copy the `apikey` value.
27+
- Copy the `url` value.
3028

3129
## Configuring the application
3230

3331
1. In your IBM Cloud console, open the Watson Assistant service instance
3432

3533
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:
3634

37-
`<project_root>/training/banking_workspace.json`
35+
`<project_root>/training/banking_workspace.json`
3836

3937
1. Select **Everything (Intents, Entities, and Dialog)** and then click **Import**. The car dashboard workspace is created.
4038

4139
1. Click the menu icon in the upper-right corner of the workspace tile, and then select **View details**.
4240

4341
1. Click the ![Copy](readme_images/copy_icon.png) icon to copy the workspace ID to the clipboard.
4442

45-
![Steps to get credentials](readme_images/assistant-demo.gif)
43+
![Steps to get credentials](readme_images/assistant-demo.gif)
4644

47-
1. In the application folder, copy the *.env.example* file and create a file called *.env*
45+
1. In the application folder, copy the _.env.example_ file and create a file called _.env_
4846

49-
```
50-
cp .env.example .env
51-
```
47+
```
48+
cp .env.example .env
49+
```
5250

53-
1. Open the *.env* file and add the service credentials that you obtained in the previous step.
51+
1. Open the _.env_ file and add the service credentials that you obtained in the previous step.
5452

55-
Example *.env* file that configures the `apikey` and `url` for a Watson Assistant service instance hosted in the US East region:
53+
Example _.env_ file that configures the `apikey` and `url` for a Watson Assistant service instance hosted in the US East region:
5654

57-
```
58-
ASSISTANT_IAM_APIKEY=X4rbi8vwZmKpXfowaS3GAsA7vdy17Qh7km5D6EzKLHL2
59-
ASSISTANT_URL=https://gateway-wdc.watsonplatform.net/assistant/api
60-
```
55+
```
56+
ASSISTANT_IAM_APIKEY=X4rbi8vwZmKpXfowaS3GAsA7vdy17Qh7km5D6EzKLHL2
57+
ASSISTANT_URL=https://gateway-wdc.watsonplatform.net/assistant/api
58+
```
6159

6260
1. Add the `ASSISTANT_ID` to the previous properties
6361

64-
```
65-
ASSISTANT_ID=522be-7b41-ab44-dec3-g1eab2ha73c6
66-
```
62+
```
63+
ASSISTANT_ID=522be-7b41-ab44-dec3-g1eab2ha73c6
64+
```
6765

6866
## Running locally
6967

7068
1. Install the dependencies
7169

72-
```
73-
npm install
74-
```
70+
```
71+
npm install
72+
```
7573

7674
1. Run the application
7775

78-
```
79-
npm start
80-
```
76+
```
77+
npm start
78+
```
8179

8280
1. View the application in a browser at `localhost:3000`
8381

8482
## Deploying to IBM Cloud as a Cloud Foundry Application
8583

8684
1. Login to IBM Cloud with the [IBM Cloud CLI](https://cloud.ibm.com/docs/cli?topic=cloud-cli-ibmcloud-cli#overview)
8785

88-
```
89-
ibmcloud login
90-
```
86+
```
87+
ibmcloud login
88+
```
9189

9290
1. Target a Cloud Foundry organization and space.
9391

94-
```
95-
ibmcloud target --cf
96-
```
92+
```
93+
ibmcloud target --cf
94+
```
9795

98-
1. Edit the *manifest.yml* file. Change the **name** field to something unique.
99-
For example, `- name: my-app-name`.
96+
1. Edit the _manifest.yml_ file. Change the **name** field to something unique.
97+
For example, `- name: my-app-name`.
10098
1. Deploy the application
10199

102-
```
103-
ibmcloud app push
104-
```
100+
```
101+
ibmcloud app push
102+
```
105103

106104
1. View the application online at the app URL.
107-
For example: https://my-app-name.mybluemix.net
108-
105+
For example: https://my-app-name.mybluemix.net
109106

110107
## License
111108

index.js

Lines changed: 20 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -32,7 +32,7 @@ const assistant = new AssistantV2({
3232
authenticator: new IamAuthenticator({
3333
apikey: process.env.ASSISTANT_IAM_APIKEY,
3434
}),
35-
url: process.env.ASSISTANT_IAM_URL,
35+
url: process.env.ASSISTANT_URL,
3636
});
3737

3838
const date = new Date();
@@ -44,11 +44,7 @@ const initContext = {
4444
acc_minamt: 50,
4545
acc_currbal: 430,
4646
acc_paydue: `${date.getFullYear()}-${date.getMonth() + 1}-26 12:00:00`,
47-
accnames: [
48-
5624,
49-
5893,
50-
9225,
51-
],
47+
accnames: [5624, 5893, 9225],
5248
},
5349
},
5450
},
@@ -151,25 +147,32 @@ app.get('/bank/statement', (req, res) => {
151147
const startingDateString = startingDate.toLocaleDateString();
152148
const endingDateString = endingDate.toLocaleDateString();
153149

154-
res.send({ result: 'statement', dates: { startingDate: startingDateString, endingDate: endingDateString } });
150+
res.send({
151+
result: 'statement',
152+
dates: { startingDate: startingDateString, endingDate: endingDateString },
153+
});
155154
});
156155

157156
app.get('/api/session', (req, res) => {
158-
assistant.createSession({
159-
assistantId: process.env.ASSISTANT_ID || '{assistant_id}',
160-
}, (error, response) => {
161-
if (error) {
162-
console.log(error);
163-
return res.status(error.code || 500).send(error);
164-
}
165-
return res.send(response);
166-
});
157+
assistant.createSession(
158+
{
159+
assistantId: process.env.ASSISTANT_ID || '{assistant_id}',
160+
},
161+
(error, response) => {
162+
if (error) {
163+
console.log(error);
164+
return res.status(error.code || 500).send(error);
165+
}
166+
return res.send(response);
167+
},
168+
);
167169
});
168170

169171
app.get('/search', (req, res) => {
170172
const { id } = req.query;
171173

172-
const header = searchCache.get(`header_${id}`) || 'The search result session has expired. Please restart the conversation in the main window.';
174+
const header = searchCache.get(`header_${id}`)
175+
|| 'The search result session has expired. Please restart the conversation in the main window.';
173176
const body = searchCache.get(`body_${id}`) || '';
174177

175178
const doc = '<html><head><meta charset="UTF-8" /><title>Document</title></head>'

manifest.yml

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
---
22
applications:
3-
- name: watson-assistant-duo
4-
command: npm start
5-
buildpack: sdk-for-nodejs
6-
env:
7-
NODE_ENV: production
3+
- name: watson-assistant-duo
4+
command: npm start
5+
buildpack: sdk-for-nodejs
6+
env:
7+
NODE_ENV: production

0 commit comments

Comments
 (0)