Toggle navigation
Toggle navigation
This project
Loading...
Sign in
윤동주
/
LINEBOT
Go to a project
Toggle navigation
Toggle navigation pinning
Projects
Groups
Snippets
Help
Project
Activity
Repository
Pipelines
Graphs
Issues
0
Merge Requests
0
Wiki
Snippets
Network
Create a new issue
Builds
Commits
Issue Boards
Authored by
최한솔
2019-12-04 23:39:12 +0900
Browse Files
Options
Browse Files
Download
Email Patches
Plain Diff
Commit
a613dd035a72e324035108161f37586d18f88110
a613dd03
1 parent
bff59378
time value test
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
32 additions
and
10 deletions
dialogflowFulfillment/firebase/functions/index.js
dialogflowFulfillment/firebase/functions/index.js
View file @
a613dd0
// See https://github.com/dialogflow/dialogflow-fulfillment-nodejs
// for Dialogflow fulfillment library docs, samples, and to report issues
'use strict'
;
const
functions
=
require
(
'firebase-functions'
);
const
{
WebhookClient
}
=
require
(
'dialogflow-fulfillment'
);
const
{
Card
,
Suggestion
}
=
require
(
'dialogflow-fulfillment'
);
process
.
env
.
DEBUG
=
'dialogflow:debug'
;
// enables lib debugging statements
exports
.
dialogflowFirebaseFulfillment
=
functions
.
https
.
onRequest
((
request
,
response
)
=>
{
const
agent
=
new
WebhookClient
({
request
,
response
});
console
.
log
(
'Dialogflow Request headers: '
+
JSON
.
stringify
(
request
.
headers
));
console
.
log
(
'Dialogflow Request body: '
+
JSON
.
stringify
(
request
.
body
));
function
welcome
(
agent
)
{
agent
.
add
(
`안녕하세요 효율적인 수면패턴을 도와드릴 꿀잠봇 입니다!`
);
}
function
fallback
(
agent
)
{
agent
.
add
(
`잘못된 입력값 입니다`
);
}
var
mytime
;
function
test1
(
agent
){
const
mytime
=
agent
.
parameters
.
hours
;
agent
.
setContext
();
agent
.
add
(
'수면 시간이 등록되었습니다'
);
const
mytime
=
agent
.
parameters
.
hours
;
const
myresult
=
mytime
+
12
;
if
(
mytime
>
0
){
agent
.
add
(
`Good. your sleep time is
${
myresult
}
`
);
}
}
function
test2
(
agent
)
{
const
hour
=
agent
.
parameters
.
hours
;
const
min
=
agent
.
parameters
.
minutes
;
const
gothour
=
hour
.
length
>
0
;
const
gotmin
=
min
.
length
>
0
;
const
rehour
=
(
hour
)
+
3
;
const
remin
=
min
+
10
;
if
(
gothour
&&
gotmin
)
{
agent
.
add
(
`좋습니다. 당신의 취침시간은
${
hour
}
시
${
min
}
분 입니다.`
);
agent
.
add
(
`
${
rehour
}
시
${
remin
}
분에 주무십시오`
);
}
else
if
(
gothour
&&
!
gotmin
)
{
agent
.
add
(
'시간이 잘못 입력되었습니다.'
);
}
else
if
(
gothour
&&
!
gothour
)
{
agent
.
add
(
'시간이 잘못 입력되었습니다.'
);
}
else
{
agent
.
add
(
'취침시간을 00:00 또는 00시00분 으로 입력해 주세요'
);
}
}
// // Uncomment and edit to make your own intent handler
// // uncomment `intentMap.set('your intent name here', yourFunctionHandler);`
// // below to get this function to be run when a Dialogflow intent is matched
...
...
@@ -60,7 +83,6 @@ exports.dialogflowFirebaseFulfillment = functions.https.onRequest((request, resp
let
intentMap
=
new
Map
();
intentMap
.
set
(
'Default Welcome Intent'
,
welcome
);
intentMap
.
set
(
'Default Fallback Intent'
,
fallback
);
intentMap
.
set
(
'test'
,
test1
);
// intentMap.set('your intent name here', googleAssistantHandler);
intentMap
.
set
(
'test'
,
test2
);
agent
.
handleRequest
(
intentMap
);
});
...
...
Please
register
or
login
to post a comment