-
Notifications
You must be signed in to change notification settings - Fork 429
Expand file tree
/
Copy pathinteractive-message.ts
More file actions
75 lines (70 loc) · 1.95 KB
/
interactive-message.ts
File metadata and controls
75 lines (70 loc) · 1.95 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
/**
* All actions which Slack delivers from legacy interactive messages. The full body of these actions are represented
* as [[InteractiveMessage]].
*/
export type InteractiveAction = ButtonClick | MenuSelect;
/**
* A button click action from a legacy interactive message.
*/
export interface ButtonClick {
type: 'button';
name: string;
value: string;
}
/**
* A menu selection action from a legacy interactive message.
*/
export interface MenuSelect {
type: 'select';
name: string;
selected_options: {
value: string;
}[];
}
/**
* A Slack legacy interactive message action wrapped in the standard metadata.
*
* This describes the entire JSON-encoded body of a request from Slack's legacy interactive messages.
*/
export interface InteractiveMessage<Action extends InteractiveAction = InteractiveAction> {
type: 'interactive_message';
callback_id: string;
actions: Action[];
team: {
id: string;
domain: string;
enterprise_id?: string; // undocumented
enterprise_name?: string; // undocumented
} | null;
user: {
id: string;
name: string;
team_id?: string; // undocumented
};
channel: {
id: string;
name: string;
};
action_ts: string;
attachment_id?: string;
token: string;
response_url: string;
trigger_id: string;
is_app_unfurl?: boolean; // undocumented
// TODO: confirm optionality of message_ts, if these are always either both available or neither, how can the type
// system express that?
message_ts?: string;
// NOTE: the original_message is not available from ephemeral messages
original_message?: { [key: string]: string };
// exists for enterprise installs
is_enterprise_install?: boolean;
enterprise?: {
id: string;
name: string;
};
}
/*
* Aliases - these types help make common usages shorter and less intimidating.
*/
export type InteractiveButtonClick = InteractiveMessage<ButtonClick>;
export type InteractiveMenuSelect = InteractiveMessage<MenuSelect>;