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-29 01:14:55 +0900
Browse Files
Options
Browse Files
Download
Plain Diff
Commit
d46f9e7e1197b928ab4f04ceae154f0cab5e6e8b
d46f9e7e
2 parents
31e9a5d1
d1b55b95
Merge branch 'sihwan' of
http://khuhub.khu.ac.kr/2019102158/emergency_room_ChatBot
into sihwan
Show whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
18 additions
and
30 deletions
app.js
app.js
View file @
d46f9e7
...
...
@@ -10,35 +10,24 @@ const domain = "2019102158.oss2022chatbot.tk"
const
sslport
=
23023
;
const
bodyParser
=
require
(
'body-parser'
);
const
app
=
express
();
var
event_time
=
1
function
main
(
eventObj
,
res
){
request
.
post
(
{
url
:
TARGET_URL
,
headers
:
{
'Authorization'
:
`Bearer
${
TOKEN
}
`
'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"
,
}
},
]
}
}
"text"
:
"응급 상황인가요?"
},
{
"type"
:
"text"
,
"text"
:
"현재있는 위치의 주소나 보이는 곳을 입력하세요."
},
],
}
},(
error
,
response
,
body
)
=>
{
...
...
@@ -49,22 +38,23 @@ res.sendStatus(200);
}
function
find_current
(
eventObj
,
res
){
//Two
console
.
log
(
Address
.
getAddress
(
eventObj
.
message
.
text
))
request
.
post
(
{
url
:
TARGET_URL
,
headers
:
{
'Authorization'
:
`Bearer
${
TOKEN
}
`
'Authorization'
:
`Bearer
${
TOKEN
}
`
,
},
json
:
{
"replyToken"
:
eventObj
.
replyToken
,
//eventObj.replyToken
"messages"
:[
{
"type"
:
"text"
,
// ①
"text"
:
"응급 상황인가요?"
,
"type"
:
"text"
,
// ①
"text"
:
"현재있는 위치의 주소나 보이는 곳을 입력하세요."
,
"text"
:
"응급 상황인가요?"
},
{
"type"
:
"text"
,
"text"
:
"현재있는 위치의 주소나 보이는 곳을 입력하세요."
},
}
],
}
},(
error
,
response
,
body
)
=>
{
...
...
@@ -78,15 +68,13 @@ res.sendStatus(200);
app
.
use
(
bodyParser
.
json
());
app
.
post
(
'/hook'
,
function
(
req
,
res
)
{
var
eventObj
=
req
.
body
.
events
[
0
];
var
headers
=
req
.
headers
;
console
.
log
(
'======================'
,
new
Date
()
,
'======================'
);
console
.
log
(
eventObj
)
if
(
eventObj
.
postback
){
find_current
(
eventObj
,
res
)
if
(
event_time
==
1
){
main
(
eventObj
,
res
)
event_time
=
2
}
else
{
else
if
(
event_time
==
2
)
{
find_current
(
eventObj
,
res
)
}
...
...
Please
register
or
login
to post a comment