ken_nogi/oldCode/express/startLineworksSurvey.js
Kenichiro NOGI 06c28e8b5a oldCode: 旧LINEWORKS/Pleasanter連携コード一式を追加
express/LINEWORKS_Pleasanter/LINEWORKS_sendMessage、いずれも過去の
Express実装。Gitea移行に伴い保管。

Co-Authored-By: Claude Sonnet 5 <noreply@anthropic.com>
2026-09-05 10:42:21 +09:00

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);
});