|
1 | | -<h1 align="center" style="border-bottom: none;">🚀 Watson Assistant Demo Sample Application</h1> |
| 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> |
| 3 | + |
| 4 | + |
| 5 | +You can view a [demo][demo_url] of this app. |
| 6 | + |
| 7 | + |
| 8 | +Please note this app uses the [Watson Assistant V2 API](https://console.bluemix.net/apidocs/assistant-v2#introduction). |
| 9 | + |
| 10 | +## Prerequisites |
| 11 | + |
| 12 | +1. Sign up for an [IBM Cloud account](https://console.bluemix.net/registration/). |
| 13 | +1. Download the [IBM Cloud CLI](https://cloud.ibm.com/docs/cli?topic=cloud-cli-ibmcloud-cli#overview). |
| 14 | +1. Create an instance of the Watson Assistant service and get your credentials: |
| 15 | + - Go to the [Watson Assistant](https://console.bluemix.net/catalog/services/conversation) page in the IBM Cloud Catalog. |
| 16 | + - Log in to your IBM Cloud account. |
| 17 | + - Click **Create**. |
| 18 | + - Click **Show** to view the service credentials. |
| 19 | + - Copy the `apikey` value, or copy the `username` and `password` values if your service instance doesn't provide an `apikey`. |
| 20 | + - Copy the `url` value. |
| 21 | + |
| 22 | +## Configuring the application |
| 23 | + |
| 24 | +1. In your IBM Cloud console, open the Watson Assistant service instance |
| 25 | + |
| 26 | +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: |
| 27 | + |
| 28 | + `<project_root>/training/banking_workspace.json` |
| 29 | + |
| 30 | +3. Select **Everything (Intents, Entities, and Dialog)** and then click **Import**. The car dashboard workspace is created. |
| 31 | + |
| 32 | +4. Click the menu icon in the upper-right corner of the workspace tile, and then select **View details**. |
| 33 | + |
| 34 | +5. Click the  icon to copy the workspace ID to the clipboard. |
| 35 | + |
| 36 | +  |
| 37 | + |
| 38 | +6. In the application folder, copy the *.env.example* file and create a file called *.env* |
| 39 | + |
| 40 | + ``` |
| 41 | + cp .env.example .env |
| 42 | + ``` |
| 43 | +
|
| 44 | +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. |
| 45 | +
|
| 46 | + Example *.env* file that configures the `apikey` and `url` for a Watson Assistant service instance hosted in the US East region: |
| 47 | +
|
| 48 | + ``` |
| 49 | + ASSISTANT_IAM_APIKEY=X4rbi8vwZmKpXfowaS3GAsA7vdy17Qh7km5D6EzKLHL2 |
| 50 | + ASSISTANT_URL=https://gateway-wdc.watsonplatform.net/assistant/api |
| 51 | + ``` |
| 52 | +
|
| 53 | + - If your service instance uses `username` and `password` credentials, add the `ASSISTANT_USERNAME` and `ASSISTANT_PASSWORD` variables to the *.env* file. |
| 54 | +
|
| 55 | + Example *.env* file that configures the `username`, `password`, and `url` for a Watson Assistant service instance hosted in the US South region: |
| 56 | +
|
| 57 | + ``` |
| 58 | + ASSISTANT_USERNAME=522be-7b41-ab44-dec3-g1eab2ha73c6 |
| 59 | + ASSISTANT_PASSWORD=A4Z5BdGENrwu8 |
| 60 | + ASSISTANT_URL=https://gateway.watsonplatform.net/assistant/api |
| 61 | + ``` |
| 62 | + However, if your credentials contain an IAM API key, copy the `apikey` and `url` to the relevant fields. |
| 63 | + ```JSON |
| 64 | + { |
| 65 | + "apikey": "ca2905e6-7b5d-4408-9192-e4d54d83e604", |
| 66 | + "iam_apikey_description": "Auto generated apikey during resource-key ...", |
| 67 | + "iam_apikey_name": "auto-generated-apikey-62b71334-3ae3-4609-be26-846fa59ece42", |
| 68 | + "iam_role_crn": "crn:v1:bluemix:public:iam::::serviceRole:Manager", |
| 69 | + "iam_serviceid_crn": "crn:v1:bluemix:public:iam...", |
| 70 | + "url": "https://gateway-syd.watsonplatform.net/assistant/api" |
| 71 | + } |
| 72 | + ``` |
| 73 | + ``` |
| 74 | + ASSISTANT_IAM_APIKEY=ca2905e6-7b5d-4408-9192-e4d54d83e604 |
| 75 | + ASSISTANT_IAM_URL=https://gateway-syd.watsonplatform.net/assistant/api |
| 76 | + ``` |
| 77 | +
|
| 78 | +8. Add the `ASSISTANT_ID` to the previous properties |
| 79 | +
|
| 80 | + ``` |
| 81 | + ASSISTANT_ID=522be-7b41-ab44-dec3-g1eab2ha73c6 |
| 82 | + ``` |
| 83 | +
|
| 84 | +## Running locally |
| 85 | +
|
| 86 | +1. Install the dependencies |
| 87 | +
|
| 88 | + ``` |
| 89 | + npm install |
| 90 | + ``` |
| 91 | +
|
| 92 | +1. Run the application |
| 93 | +
|
| 94 | + ``` |
| 95 | + npm start |
| 96 | + ``` |
| 97 | +
|
| 98 | +1. View the application in a browser at `localhost:3000` |
| 99 | +
|
| 100 | +## Deploying to IBM Cloud as a Cloud Foundry Application |
| 101 | +
|
| 102 | +1. Login to IBM Cloud with the [IBM Cloud CLI](https://cloud.ibm.com/docs/cli?topic=cloud-cli-ibmcloud-cli#overview) |
| 103 | +
|
| 104 | + ``` |
| 105 | + ibmcloud login |
| 106 | + ``` |
| 107 | +
|
| 108 | +1. Target a Cloud Foundry organization and space. |
| 109 | +
|
| 110 | + ``` |
| 111 | + ibmcloud target --cf |
| 112 | + ``` |
| 113 | +
|
| 114 | +1. Edit the *manifest.yml* file. Change the **name** field to something unique. |
| 115 | + For example, `- name: my-app-name`. |
| 116 | +1. Deploy the application |
| 117 | +
|
| 118 | + ``` |
| 119 | + ibmcloud app push |
| 120 | + ``` |
| 121 | +
|
| 122 | +1. View the application online at the app URL. |
| 123 | +For example: https://my-app-name.mybluemix.net |
| 124 | +
|
| 125 | +
|
| 126 | +## License |
| 127 | +
|
| 128 | +This sample code is licensed under Apache 2.0. |
| 129 | +Full license text is available in [LICENSE](LICENSE). |
| 130 | +
|
| 131 | +
|
| 132 | +
|
| 133 | +
|
| 134 | +[demo_url]: http://assistant-demo.ng.bluemix.net/ |
| 135 | +[doc_intents]: (https://cloud.ibm.com/docs/services/assistant?topic=assistant-intents#intents) |
| 136 | +[docs]: https://cloud.ibm.com/docs/services/assistant?topic=assistant-getting-started#getting-started |
| 137 | +[docs_landing]: (https://cloud.ibm.com/docs/services/assistant?topic=assistant-getting-started#getting-started) |
| 138 | +[node_link]: (http://nodejs.org/) |
| 139 | +[npm_link]: (https://www.npmjs.com/) |
| 140 | +[sign_up]: https://console.bluemix.net/registration |
0 commit comments