김시환

Merge branch 'sihwan' of http://khuhub.khu.ac.kr/2019102158/emergency_room_ChatBot into sihwan

Showing 1 changed file with 15 additions and 11 deletions
......@@ -6,24 +6,21 @@ const TOKEN = 'YK56BfHFgpILrxRk1FZrdcouFguf5CBA5qxM3zfDH6N9jR/cfPxVdK1P9vZHAk69m
const fs = require('fs');
const path = require('path');
const HTTPS = require('https');
const domain = "ec2-18-215-162-16.compute-1.amazonaws.com"
const domain = "2019102158.oss2022chatbot.tk"
const sslport = 23023;
const bodyParser = require('body-parser');
const app = express();
console.log(Address.getAddress('석수동길'));
app.use(bodyParser.json());
app.post('/hook', function (req, res) {
var eventObj = req.body.events[0];
var source = eventObj.source;
var message = eventObj.message;
//var source = eventObj.source;
//var message = eventObj.message;
// request log
console.log('======================', new Date() ,'======================');
console.log('[request]', req.body);
console.log('[request source] ', eventObj.source);
console.log('[request message]', eventObj.message);
console.log((Address.getAddress('석수동길')).road_address.address_name)
request.post(
{
url: TARGET_URL,
......@@ -31,17 +28,18 @@ app.post('/hook', function (req, res) {
'Authorization': `Bearer ${TOKEN}`
},
json: {
"replyToken":eventObj.replyToken,
"replyToken":eventObj.replyToken, //eventObj.replyToken
"messages":[
{
"type":"text",
"text":"Hello, user"
"text":address
},
{
"type":"text",
"text":"May I help you?"
"text":"맞나요?"
}
]
],
"status" : 1
}
},(error, response, body) => {
console.log(body)
......@@ -49,6 +47,12 @@ app.post('/hook', function (req, res) {
res.sendStatus(200);
});
try {
const option = {
ca: fs.readFileSync('/etc/letsencrypt/live/' + domain +'/fullchain.pem'),
......