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
root
2022-11-28 05:37:36 +0000
Browse Files
Options
Browse Files
Download
Email Patches
Plain Diff
Commit
e8e6d8e9ed5f8002f474385ebeae67dbeae11ebf
e8e6d8e9
1 parent
d5e6365a
update app.js
Show whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
61 additions
and
17 deletions
app.js
app.js
View file @
e8e6d8e
...
...
@@ -11,16 +11,7 @@ const sslport = 23023;
const
bodyParser
=
require
(
'body-parser'
);
const
app
=
express
();
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
)
function
main
(
eventObj
,
res
){
request
.
post
(
{
url
:
TARGET_URL
,
...
...
@@ -31,21 +22,74 @@ app.post('/hook', function (req, res) {
"replyToken"
:
eventObj
.
replyToken
,
//eventObj.replyToken
"messages"
:[
{
"type"
:
"text"
,
"text"
:
address
"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"
:
"응급 상황인가요?"
,
"type"
:
"text"
,
// ①
"text"
:
"현재있는 위치의 주소나 보이는 곳을 입력하세요."
,
}
],
"status"
:
1
}
},(
error
,
response
,
body
)
=>
{
console
.
log
(
body
)
});
res
.
sendStatus
(
200
);
res
.
sendStatus
(
200
);
}
app
.
use
(
bodyParser
.
json
());
app
.
post
(
'/hook'
,
function
(
req
,
res
)
{
var
eventObj
=
req
.
body
.
events
[
0
];
console
.
log
(
'======================'
,
new
Date
()
,
'======================'
);
console
.
log
(
eventObj
)
if
(
eventObj
.
postback
){
find_current
(
eventObj
,
res
)
}
else
{
find_current
(
eventObj
,
res
)
}
});
...
...
Please
register
or
login
to post a comment