app - notify.js
1.52 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
const request = require('request');
// 요청을 위한 상수를 선언합니다: TOKEN은 자신의 것을 입력해주세요.
const TARGET_URL = 'https://notify-api.line.me/api/notify';
const TOKEN = 'Kyu6Mp5GjB1afXWjKPqFdhdBxDicsxGBPrWp9s6JuxS';
/// 아래는 replytoken이 필요해 사용할수 없었습니다
//const CHANNEL_TOKEN
//const line = require('@line/bot-sdk');
//const client = new line.Client({
// channelAccessToken: CHANNEL_TOKEN
// });
//const message = {
// type: 'text',
// text: 'Hello World!'
// };
// client.replyMessage('<replyToken>', message);
//replytoken webhook
///
var result;
var AWS = require("aws-sdk");
AWS.config.update({region:'us-east-1'});
var params={LanguageCode:'en',TextList:['this is english']};
var comprehend = new AWS.Comprehend();
comprehend.batchDetectSentiment(params, function (err, data) {
if (err) console.log(err, err.stack); // an error occurred
else {console.log(data.ResultList[0]);
result=data.ResultList[0];
send(result['Sentiment']);
} // successful response
});
function send(result){
request.post(
{
url: TARGET_URL,
headers: {
'Authorization': `Bearer ${TOKEN}`
},
form: {
message: result,
stickerPackageId: 1,
stickerId: 1
}
},(error, response, body) => {
console.log(body)
});
}