Commit c3ccd617 authored by Yuhong's avatar Yuhong
Browse files

good to go

parent f8464e2c
/* eslint-disable no-unused-vars,no-shadow */
/* @flow */
import { Router } from 'express';
import logger from './logger';
// import ConversationV1 from 'watson-developer-cloud';
const Watson = require('watson-developer-cloud');
const conversationSDK = new Watson.ConversationV1({
username: 'MISSING VALUE',
password: 'MISSING VALUE',
workspace: 'MISSING VALUE',
version_date: '2017-05-26',
username: 'apikey',
password: 'PXfrcd6MbcMuQJ-xo8_NeZLfPbq6TpIahFe5n4H4A6M_',
workspace: 'af76927c-be93-4c9d-bc8e-b93241818ffa',
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);
const router = new Router();
router.post('/conversation', (req, res) => {
/*
==========================^^^=========================
ROUTING CODE GOES HERE
==========================vvv=========================
*/
logger.info(req);
logger.info(res);
});
module.exports = (app, conversationSDK) => {
router.post('/conversation', (req, res) => {
const { text, context = {} } = req.body;
const params = {
input: { text },
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(res);
});
};
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