現在は開発環境です。App がこのサーバーで登録して生成した Webhook を使ってください。
JavaScript
fetch でタスクやサービスの結果を送信。
BREEZE_SERVER に https://push.breezelabs.dev を設定し、キーを環境シークレット BREEZE_WEBHOOK_KEY に保存してください。
標準の fetch を備えた Node.js 環境で、サーバー側から実行する例です。key を公開 Web ページのコードに埋め込まないでください。
const server = process.env.BREEZE_SERVER
const key = process.env.BREEZE_WEBHOOK_KEY
if (!server || !key) throw new Error('Configure Breeze server and webhook secret')
const response = await fetch(new URL('/v1/send', server), {
method: 'POST',
headers: {
authorization: `Bearer ${key}`,
'content-type': 'application/json',
},
body: JSON.stringify({ title: 'タスク完了', message: '処理が完了しました', thread_id: 'jobs' }),
signal: AbortSignal.timeout(20000),
})
const result = await response.json()
console.log({ status: response.status, request_id: result.request_id, data: result.data })
if (response.status !== 200) throw new Error(`Breeze returned ${response.status}; inspect the result before retrying`)
HTTP 207 の部分成功を全件成功として扱わないよう、200 を明示的に確認しています。実際のプログラムではステータスごとに処理を分け、catch 内で無限に再送しないでください。