From f64838c37ecbbbc6b252ea3e66909f932d2cd10a Mon Sep 17 00:00:00 2001 From: John Smith Date: Mon, 30 Dec 2024 21:41:13 +1030 Subject: [PATCH] fix: Include block and fallback text for approval (#426) --- .../src/modules/integrations/slack/index.ts | 41 +++++++++++-------- 1 file changed, 24 insertions(+), 17 deletions(-) diff --git a/control-plane/src/modules/integrations/slack/index.ts b/control-plane/src/modules/integrations/slack/index.ts index c1bd5c1b..01e181bf 100644 --- a/control-plane/src/modules/integrations/slack/index.ts +++ b/control-plane/src/modules/integrations/slack/index.ts @@ -163,34 +163,41 @@ export const handleApprovalRequest = async ({ const client = new webApi.WebClient(token) + const text = `I need your approval to call \`${service}.${targetFn}\` on run <${env.APP_ORIGIN}/clusters/${clusterId}/runs/${runId}|${runId}>` + client?.chat.postMessage({ thread_ts: metadata[THREAD_META_KEY], channel: metadata[CHANNEL_META_KEY], mrkdwn: true, - text: `I need your approval to call \`${service}.${targetFn}\` on run <${env.APP_ORIGIN}/clusters/${clusterId}/runs/${runId}|${runId}>`, + text, blocks: [ { - "type": "actions", - "elements": [ + type: "section", + text: { + type: "mrkdwn", + text + } + }, + { + type: "actions", + elements: [ { - "type": "button", - "text": { - "type": "plain_text", - "text": "Approve", - "emoji": true + type: "button", + text: { + type: "plain_text", + text: "Approve", }, - "value": callId, - "action_id": CALL_APPROVE_ACTION_ID + value: callId, + action_id: CALL_APPROVE_ACTION_ID }, { - "type": "button", - "text": { - "type": "plain_text", - "text": "Deny", - "emoji": true + type: "button", + text: { + type: "plain_text", + text: "Deny", }, - "value": callId, - "action_id": CALL_DENY_ACTION_ID + value: callId, + action_id: CALL_DENY_ACTION_ID } ] }