-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathblocks.ts
More file actions
99 lines (93 loc) · 2.12 KB
/
blocks.ts
File metadata and controls
99 lines (93 loc) · 2.12 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
import type {
ActionsBlock,
ContextActionsBlock,
KnownBlock,
SectionBlock,
} from "@slack/web-api";
export const feedbackBlock = ({
thread_ts,
}: {
thread_ts: string;
}): ContextActionsBlock => {
return {
type: "context_actions",
elements: [
{
type: "feedback_buttons",
action_id: "feedback",
positive_button: {
text: {
type: "plain_text",
text: "👍",
},
value: `${thread_ts}:positive_feedback`,
},
negative_button: {
text: {
type: "plain_text",
text: "👎",
},
value: `${thread_ts}:negative_feedback`,
},
},
],
};
};
export const CHANNEL_JOIN_APPROVAL_ACTION = "channel_join_approval";
export const channelJoinApprovalBlocks = ({
toolCallId,
channelId,
channelName,
}: {
toolCallId: string;
channelId: string;
channelName?: string;
}): KnownBlock[] => {
// Use Slack's channel link format to make it clickable
const channelLink = `<#${channelId}>`;
const sectionBlock: SectionBlock = {
type: "section",
text: {
type: "mrkdwn",
text: `🔐 *Permission Request*\n\nI'd like to join the channel ${channelLink} to help with your request. Do you approve?`,
},
};
const actionsBlock: ActionsBlock = {
type: "actions",
elements: [
{
type: "button",
text: {
type: "plain_text",
text: "Approve",
emoji: true,
},
style: "primary",
action_id: CHANNEL_JOIN_APPROVAL_ACTION,
value: JSON.stringify({
toolCallId,
channelId,
channelName,
approved: true,
}),
},
{
type: "button",
text: {
type: "plain_text",
text: "Reject",
emoji: true,
},
style: "danger",
action_id: `${CHANNEL_JOIN_APPROVAL_ACTION}_reject`,
value: JSON.stringify({
toolCallId,
channelId,
channelName,
approved: false,
}),
},
],
};
return [sectionBlock, actionsBlock];
};