Commit c3ccd617 authored by Yuhong's avatar Yuhong
Browse files

good to go

parent f8464e2c
/* eslint-disable no-unused-vars,no-shadow */
/* @flow */ /* @flow */
import { Router } from 'express'; import { Router } from 'express';
import logger from './logger'; import logger from './logger';
// import ConversationV1 from 'watson-developer-cloud';
const Watson = require('watson-developer-cloud'); const Watson = require('watson-developer-cloud');
const conversationSDK = new Watson.ConversationV1({ const conversationSDK = new Watson.ConversationV1({
username: 'MISSING VALUE', username: 'apikey',
password: 'MISSING VALUE', password: 'PXfrcd6MbcMuQJ-xo8_NeZLfPbq6TpIahFe5n4H4A6M_',
workspace: 'MISSING VALUE', workspace: 'af76927c-be93-4c9d-bc8e-b93241818ffa',
version_date: '2017-05-26', version_date: '2019-04-16',
url:
'https://gateway-lon.watsonplatform.net/assistant/api/v1/workspaces/af76927c-be93-4c9d-bc8e-b93241818ffa/message',
}); });
module.exports = Watson;
const express = require('express');
const bodyParser = require('body-parser');
const cors = require('cors');
const app = express();
app.use(express.static('/public'));
app.use(bodyParser.json());
app.use(bodyParser.urlencoded({ extended: false }));
logger.info(conversationSDK); logger.info(conversationSDK);
const router = new Router(); const router = new Router();
module.exports = (app, conversationSDK) => {
router.post('/conversation', (req, res) => { router.post('/conversation', (req, res) => {
/* const { text, context = {} } = req.body;
==========================^^^========================= const params = {
ROUTING CODE GOES HERE input: { text },
==========================vvv========================= workspace_id: 'af76927c-be93-4c9d-bc8e-b93241818ffa',
*/ context,
};
Watson.message(params, (err, response) => {
if (err) res.status(500).json(err);
res.json(response);
});
logger.info(req); logger.info(req);
logger.info(res); logger.info(res);
}); });
};
export default router; export default router;
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment