Files
windmill/workflows/u/akiracraftwork/hourly_chime__flow/a.ts
2026-03-03 05:00:01 +00:00

30 lines
792 B
TypeScript

export async function main(
device: string = "オフィスの右エコー",
prefix: string = "現在時刻は",
suffix: string = "です"
) {
const now = new Date();
const hhmm = new Intl.DateTimeFormat("ja-JP", {
timeZone: "Asia/Tokyo",
hour: "2-digit",
minute: "2-digit",
hour12: false,
}).format(now); // 例: 09:30
const [h, m] = hhmm.split(":");
const text = `${prefix}${Number(h)}${Number(m)}${suffix}`;
const res = await fetch("http://alexa_api:3500/speak", {
method: "POST",
headers: { "Content-Type": "application/json" },
body: JSON.stringify({ device, text }),
});
if (!res.ok) {
const body = await res.text();
throw new Error(`alexa-api error ${res.status}: ${body}`);
}
return { ok: true, device, text };
}