├── public ├── images │ ├── watson.png │ └── favicon.ico ├── js │ └── bundle.js └── css │ └── application.css ├── data └── ecobee3_UserGuide.pdf ├── doc └── source │ └── images │ ├── open-disco.png │ ├── architecture.png │ ├── preview-link.png │ ├── assistant-list.png │ ├── cloud-api-creds.png │ ├── disco-activity.png │ ├── disco-sdu-panel.png │ ├── sample-output.png │ ├── services_icon.png │ ├── disco-build-query.png │ ├── disco-launch-sdu.png │ ├── disco-new-fields.png │ ├── disco-upload-data.png │ ├── disco-upload-file.png │ ├── assistant-add-node.png │ ├── disco-create-project.png │ ├── disco-launch-service.png │ ├── disco-manage-fields.png │ ├── disco-sdu-main-panel.png │ ├── disco-view-details.png │ ├── assistant-define-node.png │ ├── assistant-preview-link.png │ ├── disco-collection-panel.png │ ├── assistant-skills-list-1.png │ ├── create-assistant-intent.png │ ├── disco-build-query-after.png │ ├── disco-create-collection.png │ ├── disco-project-collections.png │ ├── disco-query-results-pre.png │ ├── ecobee-search-skill-setup.png │ ├── search-skill-assign-disco.png │ ├── upload-disco-file-for-sdu.gif │ ├── disco-collection-panel-pre.png │ ├── ecobee-assistant-skills-panel.png │ └── ecobee-assistant-with-skills.png ├── .travis.yml ├── .gitignore ├── ACKNOWLEDGEMENTS.md ├── .eslintrc.yml ├── CONTRIBUTING.md ├── app.js ├── server ├── message-builder.js ├── watson-assistant-service.js ├── express.js └── index.js ├── src ├── index.js ├── Messages │ └── index.js ├── Matches │ └── index.js ├── layouts │ └── default.js └── main.js ├── package.json ├── env.sample ├── lib └── utils.js ├── MAINTAINERS.md ├── LICENSE └── README.md /public/images/watson.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/IBM/watson-assistant-with-search-skill/HEAD/public/images/watson.png -------------------------------------------------------------------------------- /data/ecobee3_UserGuide.pdf: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/IBM/watson-assistant-with-search-skill/HEAD/data/ecobee3_UserGuide.pdf -------------------------------------------------------------------------------- /public/images/favicon.ico: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/IBM/watson-assistant-with-search-skill/HEAD/public/images/favicon.ico -------------------------------------------------------------------------------- /doc/source/images/open-disco.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/IBM/watson-assistant-with-search-skill/HEAD/doc/source/images/open-disco.png -------------------------------------------------------------------------------- /doc/source/images/architecture.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/IBM/watson-assistant-with-search-skill/HEAD/doc/source/images/architecture.png -------------------------------------------------------------------------------- /doc/source/images/preview-link.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/IBM/watson-assistant-with-search-skill/HEAD/doc/source/images/preview-link.png -------------------------------------------------------------------------------- /doc/source/images/assistant-list.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/IBM/watson-assistant-with-search-skill/HEAD/doc/source/images/assistant-list.png -------------------------------------------------------------------------------- /doc/source/images/cloud-api-creds.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/IBM/watson-assistant-with-search-skill/HEAD/doc/source/images/cloud-api-creds.png -------------------------------------------------------------------------------- /doc/source/images/disco-activity.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/IBM/watson-assistant-with-search-skill/HEAD/doc/source/images/disco-activity.png -------------------------------------------------------------------------------- /doc/source/images/disco-sdu-panel.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/IBM/watson-assistant-with-search-skill/HEAD/doc/source/images/disco-sdu-panel.png -------------------------------------------------------------------------------- /doc/source/images/sample-output.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/IBM/watson-assistant-with-search-skill/HEAD/doc/source/images/sample-output.png -------------------------------------------------------------------------------- /doc/source/images/services_icon.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/IBM/watson-assistant-with-search-skill/HEAD/doc/source/images/services_icon.png -------------------------------------------------------------------------------- /doc/source/images/disco-build-query.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/IBM/watson-assistant-with-search-skill/HEAD/doc/source/images/disco-build-query.png -------------------------------------------------------------------------------- /doc/source/images/disco-launch-sdu.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/IBM/watson-assistant-with-search-skill/HEAD/doc/source/images/disco-launch-sdu.png -------------------------------------------------------------------------------- /doc/source/images/disco-new-fields.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/IBM/watson-assistant-with-search-skill/HEAD/doc/source/images/disco-new-fields.png -------------------------------------------------------------------------------- /doc/source/images/disco-upload-data.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/IBM/watson-assistant-with-search-skill/HEAD/doc/source/images/disco-upload-data.png -------------------------------------------------------------------------------- /doc/source/images/disco-upload-file.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/IBM/watson-assistant-with-search-skill/HEAD/doc/source/images/disco-upload-file.png -------------------------------------------------------------------------------- /doc/source/images/assistant-add-node.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/IBM/watson-assistant-with-search-skill/HEAD/doc/source/images/assistant-add-node.png -------------------------------------------------------------------------------- /doc/source/images/disco-create-project.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/IBM/watson-assistant-with-search-skill/HEAD/doc/source/images/disco-create-project.png -------------------------------------------------------------------------------- /doc/source/images/disco-launch-service.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/IBM/watson-assistant-with-search-skill/HEAD/doc/source/images/disco-launch-service.png -------------------------------------------------------------------------------- /doc/source/images/disco-manage-fields.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/IBM/watson-assistant-with-search-skill/HEAD/doc/source/images/disco-manage-fields.png -------------------------------------------------------------------------------- /doc/source/images/disco-sdu-main-panel.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/IBM/watson-assistant-with-search-skill/HEAD/doc/source/images/disco-sdu-main-panel.png -------------------------------------------------------------------------------- /doc/source/images/disco-view-details.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/IBM/watson-assistant-with-search-skill/HEAD/doc/source/images/disco-view-details.png -------------------------------------------------------------------------------- /doc/source/images/assistant-define-node.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/IBM/watson-assistant-with-search-skill/HEAD/doc/source/images/assistant-define-node.png -------------------------------------------------------------------------------- /doc/source/images/assistant-preview-link.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/IBM/watson-assistant-with-search-skill/HEAD/doc/source/images/assistant-preview-link.png -------------------------------------------------------------------------------- /doc/source/images/disco-collection-panel.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/IBM/watson-assistant-with-search-skill/HEAD/doc/source/images/disco-collection-panel.png -------------------------------------------------------------------------------- /doc/source/images/assistant-skills-list-1.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/IBM/watson-assistant-with-search-skill/HEAD/doc/source/images/assistant-skills-list-1.png -------------------------------------------------------------------------------- /doc/source/images/create-assistant-intent.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/IBM/watson-assistant-with-search-skill/HEAD/doc/source/images/create-assistant-intent.png -------------------------------------------------------------------------------- /doc/source/images/disco-build-query-after.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/IBM/watson-assistant-with-search-skill/HEAD/doc/source/images/disco-build-query-after.png -------------------------------------------------------------------------------- /doc/source/images/disco-create-collection.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/IBM/watson-assistant-with-search-skill/HEAD/doc/source/images/disco-create-collection.png -------------------------------------------------------------------------------- /doc/source/images/disco-project-collections.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/IBM/watson-assistant-with-search-skill/HEAD/doc/source/images/disco-project-collections.png -------------------------------------------------------------------------------- /doc/source/images/disco-query-results-pre.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/IBM/watson-assistant-with-search-skill/HEAD/doc/source/images/disco-query-results-pre.png -------------------------------------------------------------------------------- /doc/source/images/ecobee-search-skill-setup.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/IBM/watson-assistant-with-search-skill/HEAD/doc/source/images/ecobee-search-skill-setup.png -------------------------------------------------------------------------------- /doc/source/images/search-skill-assign-disco.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/IBM/watson-assistant-with-search-skill/HEAD/doc/source/images/search-skill-assign-disco.png -------------------------------------------------------------------------------- /doc/source/images/upload-disco-file-for-sdu.gif: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/IBM/watson-assistant-with-search-skill/HEAD/doc/source/images/upload-disco-file-for-sdu.gif -------------------------------------------------------------------------------- /doc/source/images/disco-collection-panel-pre.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/IBM/watson-assistant-with-search-skill/HEAD/doc/source/images/disco-collection-panel-pre.png -------------------------------------------------------------------------------- /doc/source/images/ecobee-assistant-skills-panel.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/IBM/watson-assistant-with-search-skill/HEAD/doc/source/images/ecobee-assistant-skills-panel.png -------------------------------------------------------------------------------- /doc/source/images/ecobee-assistant-with-skills.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/IBM/watson-assistant-with-search-skill/HEAD/doc/source/images/ecobee-assistant-with-skills.png -------------------------------------------------------------------------------- /.travis.yml: -------------------------------------------------------------------------------- 1 | language: node_js 2 | dist: trusty 3 | node_js: 4 | - "10" 5 | - "node" 6 | - "lts/*" 7 | script: 8 | - npm run lint 9 | cache: 10 | directories: 11 | - node_modules 12 | notifications: 13 | email: 14 | - rich.hagarty@ibm.com -------------------------------------------------------------------------------- /.gitignore: -------------------------------------------------------------------------------- 1 | # Dependency directories 2 | node_modules/ 3 | 4 | # Optional npm cache directory 5 | .npm 6 | 7 | # Optional eslint cache 8 | .eslintcache 9 | 10 | # Virtual Studio code 11 | .vscode/ 12 | 13 | # dotenv environment variables file 14 | .env 15 | 16 | # Mac files 17 | .DS_Store 18 | -------------------------------------------------------------------------------- /ACKNOWLEDGEMENTS.md: -------------------------------------------------------------------------------- 1 | ## Acknowledgements 2 | 3 | * Credit goes to [Rich Hagarty](https://developer.ibm.com/code/community/advocates/rich.hagarty) for his implementation. 4 | * Credit to [Steve Martinelli](https://developer.ibm.com/code/community/advocates/stevemar) and [Mark Sturdevant](https://developer.ibm.com/code/community/advocates/mark.sturdevant) for their reviews and testing help. -------------------------------------------------------------------------------- /.eslintrc.yml: -------------------------------------------------------------------------------- 1 | env: 2 | browser: true 3 | node: true 4 | es6: true 5 | extends: 6 | - 'eslint:recommended' 7 | - 'plugin:react/recommended' 8 | parserOptions: 9 | ecmaVersion: 10 10 | ecmaFeatures: 11 | experimentalObjectRestSpread: true 12 | jsx: true 13 | sourceType: module 14 | plugins: 15 | - react 16 | rules: 17 | indent: 18 | - error 19 | - 2 20 | linebreak-style: 21 | - error 22 | - unix 23 | quotes: 24 | - error 25 | - single 26 | semi: 27 | - error 28 | - always 29 | no-console: 30 | - warn 31 | react/no-deprecated: 32 | - warn 33 | -------------------------------------------------------------------------------- /CONTRIBUTING.md: -------------------------------------------------------------------------------- 1 | # Contributing 2 | 3 | This is an open source project, and we appreciate your help! 4 | 5 | We use the GitHub issue tracker to discuss new features and non-trivial bugs. 6 | 7 | In addition to the issue tracker, [#journeys on 8 | Slack](https://dwopen.slack.com) is the best way to get into contact with the 9 | project's maintainers. 10 | 11 | To contribute code, documentation, or tests, please submit a pull request to 12 | the GitHub repository. Generally, we expect two maintainers to review your pull 13 | request before it is approved for merging. For more details, see the 14 | [MAINTAINERS](MAINTAINERS.md) page. 15 | 16 | Contributions are subject to the [Developer Certificate of Origin, Version 1.1](https://developercertificate.org/) and the [Apache License, Version 2](https://www.apache.org/licenses/LICENSE-2.0.txt). -------------------------------------------------------------------------------- /public/js/bundle.js: -------------------------------------------------------------------------------- 1 | /** 2 | * Copyright 2019 IBM Corp. All Rights Reserved. 3 | * 4 | * Licensed under the Apache License, Version 2.0 (the 'License'); you may not 5 | * use this file except in compliance with the License. You may obtain a copy of 6 | * the License at 7 | * 8 | * http://www.apache.org/licenses/LICENSE-2.0 9 | * 10 | * Unless required by applicable law or agreed to in writing, software 11 | * distributed under the License is distributed on an 'AS IS' BASIS, WITHOUT 12 | * WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the 13 | * License for the specific language governing permissions and limitations under 14 | * the License. 15 | */ 16 | 17 | import React from 'react'; 18 | import ReactDOM from 'react-dom'; 19 | import Main from '../../src/main'; 20 | 21 | // ReactDOM is responsible for updating the DOM to match React elements 22 | ReactDOM.render(
, document.querySelector('main')); 23 | -------------------------------------------------------------------------------- /app.js: -------------------------------------------------------------------------------- 1 | /** 2 | * Copyright 2019 IBM Corp. All Rights Reserved. 3 | * 4 | * Licensed under the Apache License, Version 2.0 (the 'License'); you may not 5 | * use this file except in compliance with the License. You may obtain a copy of 6 | * the License at 7 | * 8 | * http://www.apache.org/licenses/LICENSE-2.0 9 | * 10 | * Unless required by applicable law or agreed to in writing, software 11 | * distributed under the License is distributed on an 'AS IS' BASIS, WITHOUT 12 | * WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the 13 | * License for the specific language governing permissions and limitations under 14 | * the License. 15 | */ 16 | 17 | require('dotenv').config({ silent: true }); 18 | 19 | const server = require('./server'); 20 | const port = process.env.PORT || process.env.VCAP_APP_PORT || 3000; 21 | 22 | /** 23 | * Start up the Express server and listen on port for events 24 | */ 25 | server.then(app => { 26 | app.listen(port, () => { 27 | // eslint-disable-next-line no-console 28 | console.log('Watson Assistant with Search Skill Server running on port: %d', port); 29 | }); 30 | }); 31 | -------------------------------------------------------------------------------- /server/message-builder.js: -------------------------------------------------------------------------------- 1 | /** 2 | * Copyright 2019 IBM Corp. All Rights Reserved. 3 | * 4 | * Licensed under the Apache License, Version 2.0 (the 'License'); you may not 5 | * use this file except in compliance with the License. You may obtain a copy of 6 | * the License at 7 | * 8 | * http://www.apache.org/licenses/LICENSE-2.0 9 | * 10 | * Unless required by applicable law or agreed to in writing, software 11 | * distributed under the License is distributed on an 'AS IS' BASIS, WITHOUT 12 | * WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the 13 | * License for the specific language governing permissions and limitations under 14 | * the License. 15 | */ 16 | 17 | module.exports = { 18 | setAssistantId(assistantId) { 19 | this.assistant_id = assistantId; 20 | }, 21 | setSessionId(sessionId) { 22 | this.session_id = sessionId; 23 | }, 24 | message(messageOpts) { 25 | const params = Object.assign({ 26 | assistantId: this.assistant_id, 27 | sessionId: this.session_id 28 | }, messageOpts); 29 | 30 | console.log('Assistant Message Params: ' + JSON.stringify(params, null, 2)); 31 | return params; 32 | } 33 | }; 34 | -------------------------------------------------------------------------------- /src/index.js: -------------------------------------------------------------------------------- 1 | /** 2 | * Copyright 2019 IBM Corp. All Rights Reserved. 3 | * 4 | * Licensed under the Apache License, Version 2.0 (the 'License'); you may not 5 | * use this file except in compliance with the License. You may obtain a copy of 6 | * the License at 7 | * 8 | * http://www.apache.org/licenses/LICENSE-2.0 9 | * 10 | * Unless required by applicable law or agreed to in writing, software 11 | * distributed under the License is distributed on an 'AS IS' BASIS, WITHOUT 12 | * WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the 13 | * License for the specific language governing permissions and limitations under 14 | * the License. 15 | */ 16 | 17 | const React = require('react'); 18 | const PropTypes = require('prop-types'); 19 | const DefaultLayout = require('./layouts/default'); 20 | const Main = require('./main'); 21 | const objectWithoutProperties = require('../lib/utils').objectWithoutProperties; 22 | 23 | class Application extends React.Component { 24 | render() { 25 | const props = objectWithoutProperties(this.props, ['settings', '_locals', 'cache']); 26 | 27 | return ( 28 | 33 |
34 | 35 | ); 36 | } 37 | } 38 | 39 | Application.propTypes = { 40 | searchQuery: PropTypes.string, 41 | }; 42 | 43 | module.exports = Application; 44 | -------------------------------------------------------------------------------- /server/watson-assistant-service.js: -------------------------------------------------------------------------------- 1 | /** 2 | * Copyright 2019 IBM Corp. All Rights Reserved. 3 | * 4 | * Licensed under the Apache License, Version 2.0 (the 'License'); you may not 5 | * use this file except in compliance with the License. You may obtain a copy of 6 | * the License at 7 | * 8 | * http://www.apache.org/licenses/LICENSE-2.0 9 | * 10 | * Unless required by applicable law or agreed to in writing, software 11 | * distributed under the License is distributed on an 'AS IS' BASIS, WITHOUT 12 | * WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the 13 | * License for the specific language governing permissions and limitations under 14 | * the License. 15 | */ 16 | 17 | const AssistantV2 = require('ibm-watson/assistant/v2'); 18 | const { getAuthenticatorFromEnvironment } = require('ibm-watson/auth'); 19 | 20 | // need to manually set url and disableSslVerification to get around 21 | // current Cloud Pak for Data SDK issue IF user uses 22 | // `CONVERSATION_` prefix in run-time environment. 23 | let auth; 24 | let url; 25 | let disableSSL = false; 26 | 27 | try { 28 | // ASSISTANT should be used 29 | auth = getAuthenticatorFromEnvironment('ASSISTANT'); 30 | url = process.env.ASSISTANT_URL; 31 | if (process.env.ASSISTANT_DISABLE_SSL == 'true') { 32 | disableSSL = true; 33 | } 34 | } catch (e) { 35 | // but handle if alternate CONVERSATION is used 36 | auth = getAuthenticatorFromEnvironment('CONVERSATION'); 37 | url = process.env.CONVERSATION_URL; 38 | if (process.env.CONVERSATION_DISABLE_SSL == 'true') { 39 | disableSSL = true; 40 | } 41 | } 42 | console.log('Assistant auth:', JSON.stringify(auth, null, 2)); 43 | 44 | const assistant = new AssistantV2({ 45 | version: '2019-02-28', 46 | authenticator: auth, 47 | url: url, 48 | disableSslVerification: disableSSL 49 | }); 50 | 51 | assistant.assistantId = process.env.ASSISTANT_ID; 52 | assistant.workspaceId = process.env.WORKSPACE_ID; 53 | 54 | module.exports = assistant; 55 | -------------------------------------------------------------------------------- /server/express.js: -------------------------------------------------------------------------------- 1 | /** 2 | * Copyright 2019 IBM Corp. All Rights Reserved. 3 | * 4 | * Licensed under the Apache License, Version 2.0 (the 'License'); you may not 5 | * use this file except in compliance with the License. You may obtain a copy of 6 | * the License at 7 | * 8 | * http://www.apache.org/licenses/LICENSE-2.0 9 | * 10 | * Unless required by applicable law or agreed to in writing, software 11 | * distributed under the License is distributed on an 'AS IS' BASIS, WITHOUT 12 | * WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the 13 | * License for the specific language governing permissions and limitations under 14 | * the License. 15 | */ 16 | 17 | const path = require('path'); 18 | const express = require('express'); 19 | const expressBrowserify = require('express-browserify'); 20 | 21 | // Express app 22 | const app = express(); 23 | 24 | // What directory do the js Views exist 25 | app.set('views', path.join(__dirname, '..', 'src')); 26 | app.set('view engine', 'js'); 27 | app.engine('js', require('express-react-views').createEngine()); 28 | 29 | // Middlewares - use semantic-ui react components 30 | app.use('/css', express.static(path.resolve(__dirname, '..', 'public/css'))); 31 | app.use('/images', express.static(path.resolve(__dirname, '..', 'public/images'))); 32 | app.use(express.static(path.join(__dirname, '..', 'node_modules/semantic-ui/dist'))); 33 | 34 | // this allows us to retrieve POST body params 35 | app.use(require('body-parser').json()); 36 | 37 | const isDev = (app.get('env') === 'development'); 38 | console.log('isDev: ' + isDev); 39 | const browserifier = expressBrowserify(path.resolve(__dirname, '..', 'public/js/bundle.js'), { 40 | watch: isDev, 41 | debug: isDev, 42 | extension: ['js'], 43 | transform: ['babelify'], 44 | }); 45 | 46 | if (!isDev) { 47 | browserifier.browserify.transform('uglifyify', { global: true }); 48 | } 49 | 50 | // Client Side Bundle route 51 | app.get('/js/bundle.js', browserifier); 52 | 53 | module.exports = app; 54 | -------------------------------------------------------------------------------- /package.json: -------------------------------------------------------------------------------- 1 | { 2 | "name": "composite-disco-sdu-assistant-chatbot.gi", 3 | "version": "1.0.0", 4 | "private": true, 5 | "main": "app.js", 6 | "license": "Apache-2.0", 7 | "repository": { 8 | "type": "git", 9 | "url": "https://github.com/rhagarty/composite-disco-sdu-assistant-chatbot.git" 10 | }, 11 | "scripts": { 12 | "start": "node app.js", 13 | "bootstrap": "cp env.sample .env", 14 | "lint": "eslint ." 15 | }, 16 | "dependencies": { 17 | "@babel/cli": "^7.12.1", 18 | "@babel/core": "^7.12.1", 19 | "@babel/preset-env": "^7.12.1", 20 | "@babel/preset-react": "^7.12.1", 21 | "@babel/register": "^7.12.1", 22 | "@livechat/ui-kit": "^0.4.0-10", 23 | "@material-ui/core": "^4.11.0", 24 | "@material-ui/icons": "^4.9.1", 25 | "babel-core": "^7.0.0-bridge.0", 26 | "babel-jest": "^26.5.2", 27 | "babel-loader": "^8.1.0", 28 | "babelify": "^10.0.0", 29 | "body-parser": "^1.19.0", 30 | "chart.js": "^2.9.4", 31 | "dotenv": "^6.2.0", 32 | "express": "^4.17.1", 33 | "express-browserify": "^1.0.3", 34 | "express-react-views": "^0.11.0", 35 | "extend": ">=2.0.2", 36 | "ibm-watson": "5.7.1", 37 | "isomorphic-fetch": "^3.0.0", 38 | "prop-types": "^15.6.2", 39 | "query-string": "^6.10.1", 40 | "react": "^16.12.0", 41 | "react-bootstrap": "^1.0.0-beta.16", 42 | "react-dom": "^16.12.0", 43 | "react-livechat": "^1.1.1", 44 | "react-simple-chatbot": "^0.5.3", 45 | "semantic-ui-react": "^0.86.0", 46 | "sort-by": "^1.2.0", 47 | "styled-components": "^4.4.1", 48 | "uglifyify": "5.0.1" 49 | }, 50 | "babel": { 51 | "presets": [ 52 | "@babel/env", 53 | "@babel/react" 54 | ], 55 | "ignore": [ 56 | "node_modules" 57 | ] 58 | }, 59 | "engines": { 60 | "node": ">=10.0.0" 61 | }, 62 | "devDependencies": { 63 | "eslint": "^6.8.0", 64 | "eslint-config-standard": "^14.1.0", 65 | "eslint-plugin-import": "^2.20.1", 66 | "eslint-plugin-node": "^11.0.0", 67 | "eslint-plugin-promise": "^4.2.1", 68 | "eslint-plugin-react": "^7.18.3", 69 | "eslint-plugin-standard": "^4.0.1", 70 | "react-test-renderer": "^16.12.0" 71 | } 72 | } 73 | -------------------------------------------------------------------------------- /src/Messages/index.js: -------------------------------------------------------------------------------- 1 | /** 2 | * Copyright 2019 IBM Corp. All Rights Reserved. 3 | * 4 | * Licensed under the Apache License, Version 2.0 (the 'License'); you may not 5 | * use this file except in compliance with the License. You may obtain a copy of 6 | * the License at 7 | * 8 | * http://www.apache.org/licenses/LICENSE-2.0 9 | * 10 | * Unless required by applicable law or agreed to in writing, software 11 | * distributed under the License is distributed on an 'AS IS' BASIS, WITHOUT 12 | * WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the 13 | * License for the specific language governing permissions and limitations under 14 | * the License. 15 | */ 16 | 17 | import React from 'react'; 18 | import PropTypes from 'prop-types'; 19 | import { List, Image } from 'semantic-ui-react'; 20 | 21 | /** 22 | * This object renders the results of the search query on the web page. 23 | * Each result item, or 'match', will display a title, description, and 24 | * sentiment value. 25 | */ 26 | const Message = props => ( 27 | 28 | 29 | 30 | { props.text } 31 | 32 | 33 | ); 34 | 35 | // type check to ensure we are called correctly 36 | Message.propTypes = { 37 | text: PropTypes.string.isRequired, 38 | className: PropTypes.string.isRequired, 39 | image: PropTypes.string.isRequired 40 | }; 41 | 42 | const Messages = props => ( 43 |
44 | 45 | {props.messages.map(item => 46 | ) 52 | } 53 | 54 |
55 | ); 56 | 57 | const getClassName = item => { 58 | if (item.owner === 'user') { 59 | return 'right-item-list'; 60 | } else { 61 | return 'left-item-list'; 62 | } 63 | }; 64 | 65 | const getImage = item => { 66 | if (item.owner === 'user') { 67 | return 'https://semantic-ui.com/images/avatar/small/stevie.jpg'; 68 | } else { 69 | return '/images/watson.png'; 70 | } 71 | }; 72 | 73 | // type check to ensure we are called correctly 74 | Messages.propTypes = { 75 | messages: PropTypes.arrayOf(PropTypes.object).isRequired 76 | }; 77 | 78 | // export so we are visible to parent 79 | module.exports = Messages; 80 | -------------------------------------------------------------------------------- /env.sample: -------------------------------------------------------------------------------- 1 | # Copy this file to .env and replace the credentials with 2 | # your own before starting the app. 3 | 4 | #---------------------------------------------------------- 5 | # IBM Cloud 6 | # 7 | # If your services are running on IBM Cloud, 8 | # uncomment and configure these. 9 | # Remove or comment out the IBM Cloud Pak for Data sections. 10 | #---------------------------------------------------------- 11 | 12 | # Watson Assistant 13 | # ASSISTANT_AUTH_TYPE=iam 14 | # ASSISTANT_APIKEY= 15 | # ASSISTANT_URL= 16 | # ASSISTANT_ID= 17 | 18 | #---------------------------------------------------------- 19 | # IBM Cloud Pak for Data (username and password) 20 | # 21 | # If your services are running on IBM Cloud Pak for Data, 22 | # uncomment and configure these. 23 | # Remove or comment out the IBM Cloud section. 24 | #---------------------------------------------------------- 25 | 26 | ## CPD Cluster URL should be in the form: 27 | ## https://{cpd_cluster_host}{:port} 28 | ## Service URLs should be in the form: 29 | ## https://{cpd_cluster_host}{:port}/{service}/{release}/instances/{instance_id}/api 30 | 31 | # Watson Assistant 32 | # ASSISTANT_AUTH_TYPE=cp4d 33 | # ASSISTANT_AUTH_URL= 34 | # ASSISTANT_USERNAME= 35 | # ASSISTANT_PASSWORD= 36 | # ASSISTANT_URL= 37 | # # If you use a self-signed certificate, you need to disable SSL verification. 38 | # # This is not secure and not recommended. 39 | ## ASSISTANT_AUTH_DISABLE_SSL=true 40 | ## ASSISTANT_DISABLE_SSL=true 41 | # ASSISTANT_ID= 42 | 43 | ## 44 | # # Optional: Instead of the above IBM Cloud Pak for Data credentials... 45 | # # For testing and development, you can use the bearer token that's displayed 46 | # # in the IBM Cloud Pak for Data web client. To find this token, view the 47 | # # details for the provisioned service instance. The details also include the 48 | # # service endpoint URL. Only disable SSL if necessary (insecure). 49 | # # Don't use this token in production because it does not expire. 50 | # # 51 | 52 | # Watson Assistant 53 | # ASSISTANT_AUTH_TYPE=bearertoken 54 | # ASSISTANT_BEARER_TOKEN= 55 | # ASSISTANT_AUTH_URL= 56 | # ASSISTANT_URL= 57 | ## ASSISTANT_DISABLE_SSL=true 58 | # ASSISTANT_ID= 59 | 60 | # Run locally on a non-default port (default is 3000) 61 | # PORT=3000 62 | -------------------------------------------------------------------------------- /src/Matches/index.js: -------------------------------------------------------------------------------- 1 | /** 2 | * Copyright 2019 IBM Corp. All Rights Reserved. 3 | * 4 | * Licensed under the Apache License, Version 2.0 (the 'License'); you may not 5 | * use this file except in compliance with the License. You may obtain a copy of 6 | * the License at 7 | * 8 | * http://www.apache.org/licenses/LICENSE-2.0 9 | * 10 | * Unless required by applicable law or agreed to in writing, software 11 | * distributed under the License is distributed on an 'AS IS' BASIS, WITHOUT 12 | * WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the 13 | * License for the specific language governing permissions and limitations under 14 | * the License. 15 | */ 16 | 17 | import React from 'react'; 18 | import PropTypes from 'prop-types'; 19 | import { Container, Card } from 'semantic-ui-react'; 20 | 21 | /** 22 | * This object renders the results of the search query on the web page. 23 | * Each result item, or 'match', will display a title, description, and 24 | * sentiment value. 25 | */ 26 | const Match = props => ( 27 | 28 | 29 | 30 | Score: { props.score } 31 | 32 | 33 | ); 34 | 35 | // type check to ensure we are called correctly 36 | Match.propTypes = { 37 | text: PropTypes.string.isRequired, 38 | score: PropTypes.string.isRequired 39 | }; 40 | 41 | const Matches = props => ( 42 |
43 | 44 |
45 | 46 | {props.matches.map(item => 47 | ) 52 | } 53 | 54 |
55 |
56 |
57 | ); 58 | 59 | // type check to ensure we are called correctly 60 | Matches.propTypes = { 61 | matches: PropTypes.arrayOf(PropTypes.object).isRequired 62 | }; 63 | 64 | // format text, setting background color for all highlighted words 65 | const getText = (item) => { 66 | return item.text ? item.text : 'No Description'; 67 | }; 68 | 69 | /** 70 | * getScore - round up to 4 decimal places. 71 | */ 72 | const getScore = item => { 73 | var score = 0.0; 74 | 75 | if (item.score) { 76 | score = (item.score).toFixed(4); 77 | } 78 | return score; 79 | }; 80 | 81 | // export so we are visible to parent 82 | module.exports = Matches; 83 | -------------------------------------------------------------------------------- /src/layouts/default.js: -------------------------------------------------------------------------------- 1 | /** 2 | * Copyright 2019 IBM Corp. All Rights Reserved. 3 | * 4 | * Licensed under the Apache License, Version 2.0 (the 'License'); you may not 5 | * use this file except in compliance with the License. You may obtain a copy of 6 | * the License at 7 | * 8 | * http://www.apache.org/licenses/LICENSE-2.0 9 | * 10 | * Unless required by applicable law or agreed to in writing, software 11 | * distributed under the License is distributed on an 'AS IS' BASIS, WITHOUT 12 | * WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the 13 | * License for the specific language governing permissions and limitations under 14 | * the License. 15 | */ 16 | 17 | import React from 'react'; 18 | import PropTypes from 'prop-types'; 19 | 20 | class DefaultLayout extends React.Component { 21 | getDescription() { 22 | return ( 23 |
24 |
25 | This is a web app to demonstrates how to query your own Watson Discovery Collection and display it in a variety of ways. 26 |
27 |
28 | ); 29 | } 30 | 31 | render() { 32 | return ( 33 | 34 | 35 | Watson Discovery UI 36 | 37 | 38 | 39 | 40 | 41 | 42 | 43 | 44 | 45 | 46 | 47 |
{this.props.children}
48 | 53 |