app.js
1.77 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
const express = require('express');
const app = express();
const bodyParser = require('body-parser');
app.use(bodyParser.urlencoded({extended: false}));
app.use(bodyParse.json());
app.post('/api/sayHello', (req, res) => {
const responseBody = { //skill response
version: "2.0", //version 필수
template: { // template 필수
outputs: [
{
simpleText: {
text: "hello I'm Ryan"
}
}
]
}
};
res.status(200).send(responseBody);
});
app.post('/api/showHello', (req, res) => {
console.log(req.body);
const responseBody = {
version: "2.0",
template: {
outputs: [
{
simpleImage: {
imageUrl: "https://t1.daumcdn.net/friends/prod/category/M001_friends_ryan2.jpg",
altText: "hello I'm Ryan"
}
}
]
}
};
res.status(200).send(responseBody);
});
app.post('/message', (req, res) => {
const question = req.body.userRequest.utterance;
if (question === 'test') {
const responseBody = {
version: "2.0",
template: {
outputs: [
{
simpleText: {
text: "text..."
}
}
],
quickReplies: [
{
label: 'go main',
action: 'message',
messageText: 'go main'
}
]
}
};
res.status(200).send(responseBody);
}
})
var server = app.listen(3000);