diff --git a/src/server/feishu.ts b/src/server/feishu.ts index 1906b02..2f208de 100644 --- a/src/server/feishu.ts +++ b/src/server/feishu.ts @@ -190,6 +190,26 @@ export function buildDecisionCard(card: DecisionCardOptions): Record { const token = await getTenantToken(); const url = `https://open.feishu.cn/open-apis/im/v1/messages?receive_id_type=${receiveIdType}`; + + const cardContent = { + header: { + title: { tag: 'plain_text', content: card.title }, + template: 'blue', + }, + elements: [ + { tag: 'div', text: { tag: 'plain_text', content: card.description } }, + { + tag: 'action', + actions: card.options.map((opt) => ({ + tag: 'button', + text: { tag: 'plain_text', content: opt.label }, + type: opt.style === 'danger' ? 'danger' : opt.style === 'primary' ? 'primary' : 'default', + value: { action: opt.key }, + })), + }, + ], + }; + const res = await fetch(url, { method: 'POST', headers: { @@ -199,7 +219,7 @@ export async function sendDecisionCard(card: DecisionCardOptions, receiveId: str body: JSON.stringify({ receive_id: receiveId, msg_type: 'interactive', - card: buildDecisionCard(card), + content: JSON.stringify(cardContent), }), }); const data = await res.json();