56 lines
1.3 KiB
JavaScript
56 lines
1.3 KiB
JavaScript
'use strict';
|
|
|
|
const { API_KEY } = require('./config.js');
|
|
|
|
const WEBHOOK_URL =
|
|
process.env.LINEWORKS_SURVEY_WEBHOOK_URL ||
|
|
'https://neo999.next-hd.net/lineworksSurvey/webhook';
|
|
|
|
// ここで固定値を指定
|
|
const surveyId = '335338';
|
|
const targetId = 'kenichiro.nogi@works-nextgroup2';
|
|
const botId = '11747661';
|
|
|
|
if (!surveyId || !targetId || !botId) {
|
|
console.error('surveyId, targetId, botId をソース内で設定してください。');
|
|
process.exit(1);
|
|
}
|
|
|
|
if (!API_KEY) {
|
|
console.error('API_KEY is empty. Check config.js / environment.');
|
|
process.exit(1);
|
|
}
|
|
|
|
async function main() {
|
|
const payload = { surveyId, targetId, botId };
|
|
|
|
const res = await fetch(WEBHOOK_URL, {
|
|
method: 'POST',
|
|
headers: {
|
|
'Content-Type': 'application/json',
|
|
'x-api-key': API_KEY
|
|
},
|
|
body: JSON.stringify(payload)
|
|
});
|
|
|
|
const text = await res.text();
|
|
let body;
|
|
try {
|
|
body = JSON.parse(text);
|
|
} catch {
|
|
body = { raw: text };
|
|
}
|
|
|
|
if (!res.ok) {
|
|
console.error('Start request failed:', res.status, body);
|
|
process.exit(1);
|
|
}
|
|
|
|
console.log('Start request success:', body);
|
|
}
|
|
|
|
main().catch((err) => {
|
|
console.error('Unexpected error:', err);
|
|
process.exit(1);
|
|
});
|