Skip to content

Commit

Permalink
Merge pull request #21 from watson-developer-cloud/up
Browse files Browse the repository at this point in the history
fix: Update dependencies and fix travis
  • Loading branch information
germanattanasio authored Nov 7, 2019
2 parents a939b98 + 061c9b0 commit 086cb0a
Show file tree
Hide file tree
Showing 9 changed files with 476 additions and 331 deletions.
7 changes: 2 additions & 5 deletions .env.example
Original file line number Diff line number Diff line change
@@ -1,6 +1,3 @@
# Environment variables
ASSISTANT_ID=
# You need to provide your IAM API key and URL
ASSISTANT_IAM_APIKEY=
ASSISTANT_IAM_URL=
ASSISTANT_URL=https://gateway.watsonplatform.net/assistant/api
ASSISTANT_URL=
ASSISTANT_IAM_APIKEY=
38 changes: 19 additions & 19 deletions .travis.yml
Original file line number Diff line number Diff line change
@@ -1,29 +1,29 @@
language: node_js
dist: xenial
node_js: "10"
node_js: '12'
cache:
directories:
- node_modules
- node_modules
env:
global:
- BX_APP=watson-conversation-duo-dev
- BX_API=https://api.ng.bluemix.net
- BX_ORGANIZATION=WatsonPlatformServices
- BX_SPACE=demos
- B_DOMAIN=ng.bluemix.net
- BX_APP=watson-conversation-duo-dev
- BX_API=https://api.ng.bluemix.net
- BX_ORGANIZATION=WatsonPlatformServices
- BX_SPACE=demos
- B_DOMAIN=ng.bluemix.net
script:
- npm run build
- npm test
- npm run build
- npm test

before_deploy:
- npm install -g bx-blue-green
- npm install -g bx-blue-green
deploy:
- provider: script
script: bx-blue-green-travis
on:
branch: master
repo: watson-developer-cloud/assistant-demo
skip_cleanup: true
- provider: script
skip_cleanup: true
script: npx semantic-release
- provider: script
script: bx-blue-green-travis
on:
branch: master
repo: watson-developer-cloud/assistant-demo
skip_cleanup: true
- provider: script
skip_cleanup: true
script: npx semantic-release
1 change: 0 additions & 1 deletion CONTRIBUTING.md
Original file line number Diff line number Diff line change
@@ -1,4 +1,3 @@

## Reporting a bug

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.
91 changes: 44 additions & 47 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -4,15 +4,13 @@

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


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

* Cloud Functions
* Actions and UI Actions
* Slots
* Multi-Conditional Responses
* Multi-Modal Responses

- Cloud Functions
- Actions and UI Actions
- Slots
- Multi-Conditional Responses
- Multi-Modal Responses

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

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

## Configuring the application

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

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:

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

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

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

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

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

1. In the application folder, copy the *.env.example* file and create a file called *.env*
1. In the application folder, copy the _.env.example_ file and create a file called _.env_

```
cp .env.example .env
```
```
cp .env.example .env
```

1. Open the *.env* file and add the service credentials that you obtained in the previous step.
1. Open the _.env_ file and add the service credentials that you obtained in the previous step.

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

```
ASSISTANT_IAM_APIKEY=X4rbi8vwZmKpXfowaS3GAsA7vdy17Qh7km5D6EzKLHL2
ASSISTANT_URL=https://gateway-wdc.watsonplatform.net/assistant/api
```
```
ASSISTANT_IAM_APIKEY=X4rbi8vwZmKpXfowaS3GAsA7vdy17Qh7km5D6EzKLHL2
ASSISTANT_URL=https://gateway-wdc.watsonplatform.net/assistant/api
```

1. Add the `ASSISTANT_ID` to the previous properties

```
ASSISTANT_ID=522be-7b41-ab44-dec3-g1eab2ha73c6
```
```
ASSISTANT_ID=522be-7b41-ab44-dec3-g1eab2ha73c6
```

## Running locally

1. Install the dependencies

```
npm install
```
```
npm install
```

1. Run the application

```
npm start
```
```
npm start
```

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

## Deploying to IBM Cloud as a Cloud Foundry Application

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

```
ibmcloud login
```
```
ibmcloud login
```

1. Target a Cloud Foundry organization and space.

```
ibmcloud target --cf
```
```
ibmcloud target --cf
```

1. Edit the *manifest.yml* file. Change the **name** field to something unique.
For example, `- name: my-app-name`.
1. Edit the _manifest.yml_ file. Change the **name** field to something unique.
For example, `- name: my-app-name`.
1. Deploy the application

```
ibmcloud app push
```
```
ibmcloud app push
```

1. View the application online at the app URL.
For example: https://my-app-name.mybluemix.net
For example: https://my-app-name.mybluemix.net

## License

Expand Down
37 changes: 20 additions & 17 deletions index.js
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,7 @@ const assistant = new AssistantV2({
authenticator: new IamAuthenticator({
apikey: process.env.ASSISTANT_IAM_APIKEY,
}),
url: process.env.ASSISTANT_IAM_URL,
url: process.env.ASSISTANT_URL,
});

const date = new Date();
Expand All @@ -44,11 +44,7 @@ const initContext = {
acc_minamt: 50,
acc_currbal: 430,
acc_paydue: `${date.getFullYear()}-${date.getMonth() + 1}-26 12:00:00`,
accnames: [
5624,
5893,
9225,
],
accnames: [5624, 5893, 9225],
},
},
},
Expand Down Expand Up @@ -151,25 +147,32 @@ app.get('/bank/statement', (req, res) => {
const startingDateString = startingDate.toLocaleDateString();
const endingDateString = endingDate.toLocaleDateString();

res.send({ result: 'statement', dates: { startingDate: startingDateString, endingDate: endingDateString } });
res.send({
result: 'statement',
dates: { startingDate: startingDateString, endingDate: endingDateString },
});
});

app.get('/api/session', (req, res) => {
assistant.createSession({
assistantId: process.env.ASSISTANT_ID || '{assistant_id}',
}, (error, response) => {
if (error) {
console.log(error);
return res.status(error.code || 500).send(error);
}
return res.send(response);
});
assistant.createSession(
{
assistantId: process.env.ASSISTANT_ID || '{assistant_id}',
},
(error, response) => {
if (error) {
console.log(error);
return res.status(error.code || 500).send(error);
}
return res.send(response);
},
);
});

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

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

const doc = '<html><head><meta charset="UTF-8" /><title>Document</title></head>'
Expand Down
10 changes: 5 additions & 5 deletions manifest.yml
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
---
applications:
- name: watson-assistant-duo
command: npm start
buildpack: sdk-for-nodejs
env:
NODE_ENV: production
- name: watson-assistant-duo
command: npm start
buildpack: sdk-for-nodejs
env:
NODE_ENV: production
Loading

0 comments on commit 086cb0a

Please sign in to comment.