Toggle navigation
Toggle navigation
This project
Loading...
Sign in
김시환
/
emergency_room_ChatBot
Go to a project
Toggle navigation
Toggle navigation pinning
Projects
Groups
Snippets
Help
Project
Activity
Repository
Pipelines
Graphs
Issues
0
Merge Requests
1
Snippets
Network
Create a new issue
Builds
Commits
Issue Boards
Authored by
김시환
2022-11-28 14:38:15 +0900
Browse Files
Options
Browse Files
Download
Plain Diff
Commit
80e6bf885b3a1281eaf07519596e004b5ddd23c1
80e6bf88
2 parents
ca89e628
e8e6d8e9
Merge branch 'sihwan' of
http://khuhub.khu.ac.kr/2019102158/emergency_room_ChatBot
into sihwan
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
73 additions
and
29 deletions
app.js
app.js
View file @
80e6bf8
...
...
@@ -11,41 +11,85 @@ const sslport = 23023;
const
bodyParser
=
require
(
'body-parser'
);
const
app
=
express
();
function
main
(
eventObj
,
res
){
request
.
post
(
{
url
:
TARGET_URL
,
headers
:
{
'Authorization'
:
`Bearer
${
TOKEN
}
`
},
json
:
{
"replyToken"
:
eventObj
.
replyToken
,
//eventObj.replyToken
"messages"
:[
{
"type"
:
"text"
,
// ①
"text"
:
"응급 상황인가요?"
,
"quickReply"
:
{
// ②
"items"
:
[
{
"type"
:
"action"
,
// ③
"action"
:
{
"type"
:
"postback"
,
"label"
:
"네"
,
"data"
:
"action=two"
,
"displayText"
:
"네"
,
"inputOption"
:
"openKeyboard"
,
}
},
]
}
}
],
}
},(
error
,
response
,
body
)
=>
{
});
res
.
sendStatus
(
200
);
}
function
find_current
(
eventObj
,
res
){
//Two
request
.
post
(
{
url
:
TARGET_URL
,
headers
:
{
'Authorization'
:
`Bearer
${
TOKEN
}
`
},
json
:
{
"replyToken"
:
eventObj
.
replyToken
,
//eventObj.replyToken
"messages"
:[
{
"type"
:
"text"
,
// ①
"text"
:
"응급 상황인가요?"
,
"type"
:
"text"
,
// ①
"text"
:
"현재있는 위치의 주소나 보이는 곳을 입력하세요."
,
}
],
}
},(
error
,
response
,
body
)
=>
{
});
res
.
sendStatus
(
200
);
}
app
.
use
(
bodyParser
.
json
());
app
.
post
(
'/hook'
,
function
(
req
,
res
)
{
var
eventObj
=
req
.
body
.
events
[
0
];
//var source = eventObj.source;
//var message = eventObj.message;
// request log
console
.
log
(
'======================'
,
new
Date
()
,
'======================'
);
console
.
log
((
Address
.
getAddress
(
'석수동길'
)).
road_address
.
address_name
)
request
.
post
(
{
url
:
TARGET_URL
,
headers
:
{
'Authorization'
:
`Bearer
${
TOKEN
}
`
},
json
:
{
"replyToken"
:
eventObj
.
replyToken
,
//eventObj.replyToken
"messages"
:[
{
"type"
:
"text"
,
"text"
:
address
},
{
"type"
:
"text"
,
"text"
:
"맞나요?"
}
],
"status"
:
1
}
},(
error
,
response
,
body
)
=>
{
console
.
log
(
body
)
});
res
.
sendStatus
(
200
);
console
.
log
(
eventObj
)
if
(
eventObj
.
postback
){
find_current
(
eventObj
,
res
)
}
else
{
find_current
(
eventObj
,
res
)
}
});
...
...
Please
register
or
login
to post a comment