Comprehensive TypeScript type definitions for building Slack applications and integrations with the Node Slack SDK
94
Slack's Events API provides real-time notifications about activities in a workspace. This module defines TypeScript interfaces for all event types, enabling type-safe event handling in Slack applications.
The main discriminated union containing all Slack event types.
type SlackEvent = AppDeletedEvent | AppHomeOpenedEvent | AppInstalledEvent | AppMentionEvent | AppRateLimitedEvent | AppRequestedEvent | AppUninstalledEvent | AppUninstalledTeamEvent | AssistantThreadContextChangedEvent | AssistantThreadStartedEvent | CallRejectedEvent | ChannelArchiveEvent | ChannelCreatedEvent | ChannelDeletedEvent | ChannelHistoryChangedEvent | ChannelIDChangedEvent | ChannelLeftEvent | ChannelRenameEvent | ChannelSharedEvent | ChannelUnarchiveEvent | ChannelUnsharedEvent | DNDUpdatedEvent | DNDUpdatedUserEvent | EmailDomainChangedEvent | EmojiChangedEvent | FileChangeEvent | FileCommentDeletedEvent | FileCreatedEvent | FileDeletedEvent | FilePublicEvent | FileSharedEvent | FileUnsharedEvent | FunctionExecutedEvent | GridMigrationFinishedEvent | GridMigrationStartedEvent | GroupArchiveEvent | GroupCloseEvent | GroupDeletedEvent | GroupHistoryChangedEvent | GroupLeftEvent | GroupOpenEvent | GroupRenameEvent | GroupUnarchiveEvent | IMCloseEvent | IMCreatedEvent | IMHistoryChangedEvent | IMOpenEvent | InviteRequestedEvent | LinkSharedEvent | MemberJoinedChannelEvent | MemberLeftChannelEvent | AllMessageEvents | AllMessageMetadataEvents | PinAddedEvent | PinRemovedEvent | ReactionAddedEvent | ReactionRemovedEvent | SharedChannelInviteAcceptedEvent | SharedChannelInviteApprovedEvent | SharedChannelInviteDeclinedEvent | SharedChannelInviteReceivedEvent | SharedChannelInviteRequestedEvent | StarAddedEvent | StarRemovedEvent | SubteamCreatedEvent | SubteamMembersChangedEvent | SubteamSelfAddedEvent | SubteamSelfRemovedEvent | SubteamUpdatedEvent | TeamAccessGrantedEvent | TeamAccessRevokedEvent | TeamDomainChangeEvent | TeamJoinEvent | TeamRenameEvent | TokensRevokedEvent | UserChangeEvent | UserHuddleChangedEvent | UserProfileChangedEvent | UserStatusChangedEvent | WorkflowDeletedEvent | WorkflowPublishedEvent | WorkflowStepDeletedEvent | WorkflowStepExecuteEvent | WorkflowUnpublishedEvent;Events related to app lifecycle and installation.
interface AppDeletedEvent {
type: 'app_deleted';
app_id: string;
}
interface AppHomeOpenedEvent {
type: 'app_home_opened';
user: string;
channel: string;
tab: 'home' | 'messages';
event_ts: string;
}
interface AppInstalledEvent {
type: 'app_installed';
app_id: string;
app_name: string;
app_owner_id: string;
user_id: string;
team_id: string;
}
interface AppMentionEvent {
type: 'app_mention';
user: string;
text: string;
ts: string;
channel: string;
event_ts: string;
thread_ts?: string;
blocks?: AnyBlock[];
}
interface AppRateLimitedEvent {
type: 'app_rate_limited';
token: string;
team_id: string;
minute_rate_limited: number;
api_app_id: string;
}
interface AppRequestedEvent {
type: 'app_requested';
app_request: {
id: string;
app: {
id: string;
name: string;
description: string;
help_url: string;
privacy_policy_url: string;
app_homepage_url: string;
};
previous_resolution: {
status: 'approved' | 'restricted';
scopes: {
name: string;
description: string;
is_sensitive: boolean;
token_type: string;
}[];
} | null;
user: {
id: string;
name: string;
email: string;
};
team: {
id: string;
name: string;
domain: string;
};
scopes: {
name: string;
description: string;
is_sensitive: boolean;
token_type: string;
}[];
message: string;
date_created: number;
};
}
interface AppUninstalledEvent {
type: 'app_uninstalled';
}
interface AppUninstalledTeamEvent {
type: 'app_uninstalled_team';
team_ids: string[];
}Events for channel lifecycle and membership changes.
interface ChannelArchiveEvent {
type: 'channel_archive';
channel: string;
user: string;
}
interface ChannelCreatedEvent {
type: 'channel_created';
channel: {
id: string;
name: string;
created: number;
creator: string;
};
}
interface ChannelDeletedEvent {
type: 'channel_deleted';
channel: string;
}
interface ChannelHistoryChangedEvent {
type: 'channel_history_changed';
latest: string;
ts: string;
event_ts: string;
}
interface ChannelIDChangedEvent {
type: 'channel_id_changed';
old_channel_id: string;
new_channel_id: string;
event_ts: string;
}
interface ChannelLeftEvent {
type: 'channel_left';
channel: string;
user: string;
}
interface ChannelRenameEvent {
type: 'channel_rename';
channel: {
id: string;
name: string;
created: number;
};
}
interface ChannelSharedEvent {
type: 'channel_shared';
connected_team_id: string;
channel: string;
event_ts: string;
}
interface ChannelUnarchiveEvent {
type: 'channel_unarchive';
channel: string;
user: string;
}
interface ChannelUnsharedEvent {
type: 'channel_unshared';
previously_connected_team_id: string;
channel: string;
is_ext_shared: boolean;
event_ts: string;
}The most commonly used events for message handling.
type AllMessageEvents = MessageEvent | MessageBotEvent | MessageChannelArchiveEvent | MessageChannelJoinEvent | MessageChannelLeaveEvent | MessageChannelNameEvent | MessageChannelPurposeEvent | MessageChannelTopicEvent | MessageChannelUnarchiveEvent | MessageEkmAccessDeniedEvent | MessageFileShareEvent | MessageHuddleEvent | MessageMeEvent | MessageMessageChangedEvent | MessageMessageDeletedEvent | MessageMessageRepliedEvent | MessageReminderAddEvent | MessageSlackbotResponseEvent | MessageThreadBroadcastEvent;
interface MessageEvent {
type: 'message';
channel: string;
user: string;
text: string;
ts: string;
thread_ts?: string;
blocks?: AnyBlock[];
attachments?: MessageAttachment[];
files?: any[];
upload?: boolean;
user_team?: string;
source_team?: string;
edited?: {
user: string;
ts: string;
};
client_msg_id?: string;
app_id?: string;
bot_id?: string;
username?: string;
team?: string;
parent_user_id?: string;
reply_count?: number;
reply_users_count?: number;
latest_reply?: string;
reply_users?: string[];
is_locked?: boolean;
subscribed?: boolean;
last_read?: string;
unread_count?: number;
root?: MessageEvent;
}
interface MessageBotEvent {
type: 'message';
subtype: 'bot_message';
channel: string;
bot_id: string;
username?: string;
text: string;
ts: string;
thread_ts?: string;
blocks?: AnyBlock[];
attachments?: MessageAttachment[];
icons?: {
[key: string]: string;
};
app_id?: string;
}
interface MessageMessageChangedEvent {
type: 'message';
subtype: 'message_changed';
hidden: boolean;
channel: string;
ts: string;
message: MessageEvent;
previous_message: MessageEvent;
event_ts: string;
}
interface MessageMessageDeletedEvent {
type: 'message';
subtype: 'message_deleted';
hidden: boolean;
channel: string;
ts: string;
deleted_ts: string;
event_ts: string;
previous_message: MessageEvent;
}Events related to user profile and status changes.
interface UserChangeEvent {
type: 'user_change';
user: {
id: string;
team_id: string;
name: string;
deleted: boolean;
color: string;
real_name: string;
tz: string;
tz_label: string;
tz_offset: number;
profile: {
title: string;
phone: string;
skype: string;
real_name: string;
real_name_normalized: string;
display_name: string;
display_name_normalized: string;
fields: any;
status_text: string;
status_emoji: string;
status_emoji_display_info: StatusEmojiDisplayInfo[];
status_expiration: number;
avatar_hash: string;
image_original?: string;
is_custom_image?: boolean;
email?: string;
first_name: string;
last_name: string;
image_24: string;
image_32: string;
image_48: string;
image_72: string;
image_192: string;
image_512: string;
image_1024?: string;
status_text_canonical?: string;
team: string;
};
is_admin: boolean;
is_owner: boolean;
is_primary_owner: boolean;
is_restricted: boolean;
is_ultra_restricted: boolean;
is_bot: boolean;
is_app_user: boolean;
updated: number;
is_email_confirmed: boolean;
who_can_share_contact_card: string;
locale?: string;
};
cache_ts: number;
event_ts: string;
}
interface UserProfileChangedEvent {
type: 'user_profile_changed';
user: {
id: string;
team_id: string;
name: string;
deleted: boolean;
color: string;
real_name: string;
tz: string;
tz_label: string;
tz_offset: number;
profile: {
title: string;
phone: string;
skype: string;
real_name: string;
real_name_normalized: string;
display_name: string;
display_name_normalized: string;
fields: any;
status_text: string;
status_emoji: string;
status_emoji_display_info: StatusEmojiDisplayInfo[];
status_expiration: number;
avatar_hash: string;
email?: string;
first_name: string;
last_name: string;
image_24: string;
image_32: string;
image_48: string;
image_72: string;
image_192: string;
image_512: string;
status_text_canonical?: string;
team: string;
};
is_admin: boolean;
is_owner: boolean;
is_primary_owner: boolean;
is_restricted: boolean;
is_ultra_restricted: boolean;
is_bot: boolean;
is_app_user: boolean;
updated: number;
is_email_confirmed: boolean;
who_can_share_contact_card: string;
};
cache_ts: number;
event_ts: string;
}
interface UserStatusChangedEvent {
type: 'user_status_changed';
user: {
id: string;
team_id: string;
name: string;
deleted: boolean;
color: string;
real_name: string;
tz: string;
tz_label: string;
tz_offset: number;
profile: {
status_text: string;
status_emoji: string;
status_emoji_display_info: StatusEmojiDisplayInfo[];
status_expiration: number;
avatar_hash: string;
display_name: string;
real_name: string;
real_name_normalized: string;
email?: string;
image_24: string;
image_32: string;
image_48: string;
image_72: string;
image_192: string;
image_512: string;
first_name: string;
last_name: string;
title: string;
phone: string;
skype: string;
fields: any;
status_text_canonical?: string;
team: string;
};
is_admin: boolean;
is_owner: boolean;
is_primary_owner: boolean;
is_restricted: boolean;
is_ultra_restricted: boolean;
is_bot: boolean;
is_app_user: boolean;
updated: number;
is_email_confirmed: boolean;
};
cache_ts: number;
event_ts: string;
}
interface UserHuddleChangedEvent {
type: 'user_huddle_changed';
user: {
id: string;
team_id: string;
name: string;
deleted: boolean;
color: string;
real_name: string;
tz: string;
tz_label: string;
tz_offset: number;
profile: {
avatar_hash: string;
status_text: string;
status_emoji: string;
real_name: string;
display_name: string;
real_name_normalized: string;
display_name_normalized: string;
email?: string;
image_original?: string;
image_24: string;
image_32: string;
image_48: string;
image_72: string;
image_192: string;
image_512: string;
team: string;
first_name: string;
last_name: string;
title: string;
phone: string;
skype: string;
huddle_state: string;
huddle_state_expiration_ts: number;
};
is_admin: boolean;
is_owner: boolean;
is_primary_owner: boolean;
is_restricted: boolean;
is_ultra_restricted: boolean;
is_bot: boolean;
is_app_user: boolean;
updated: number;
is_email_confirmed: boolean;
};
cache_ts: number;
event_ts: string;
}Events for file sharing and management.
interface FileCreatedEvent {
type: 'file_created';
file_id: string;
user_id: string;
}
interface FileDeletedEvent {
type: 'file_deleted';
file_id: string;
event_ts: string;
}
interface FilePublicEvent {
type: 'file_public';
file_id: string;
user_id: string;
}
interface FileSharedEvent {
type: 'file_shared';
file_id: string;
user_id: string;
}
interface FileUnsharedEvent {
type: 'file_unshared';
file_id: string;
user_id: string;
}
interface FileChangeEvent {
type: 'file_change';
file_id: string;
file: {
id: string;
};
}
interface FileCommentDeletedEvent {
type: 'file_comment_deleted';
comment: string;
file_id: string;
}Events for emoji reactions on messages.
interface ReactionAddedEvent {
type: 'reaction_added';
user: string;
reaction: string;
item_user: string;
item: {
type: string;
channel: string;
ts: string;
};
event_ts: string;
}
interface ReactionRemovedEvent {
type: 'reaction_removed';
user: string;
reaction: string;
item_user: string;
item: {
type: string;
channel: string;
ts: string;
};
event_ts: string;
}Workspace-level events.
interface TeamJoinEvent {
type: 'team_join';
user: {
id: string;
team_id: string;
name: string;
deleted: boolean;
color: string;
real_name: string;
tz: string;
tz_label: string;
tz_offset: number;
profile: any;
is_admin: boolean;
is_owner: boolean;
is_primary_owner: boolean;
is_restricted: boolean;
is_ultra_restricted: boolean;
is_bot: boolean;
is_app_user: boolean;
updated: number;
is_email_confirmed: boolean;
};
}
interface TeamRenameEvent {
type: 'team_rename';
name: string;
}
interface TeamDomainChangeEvent {
type: 'team_domain_change';
url: string;
domain: string;
}
interface TeamAccessGrantedEvent {
type: 'team_access_granted';
team_ids: string[];
}
interface TeamAccessRevokedEvent {
type: 'team_access_revoked';
team_ids: string[];
}The events system also includes:
AssistantThreadStartedEvent, AssistantThreadContextChangedEvent)CallRejectedEvent)DNDUpdatedEvent, DNDUpdatedUserEvent)EmailDomainChangedEvent)EmojiChangedEvent)FunctionExecutedEvent)GridMigrationStartedEvent, GridMigrationFinishedEvent)InviteRequestedEvent)LinkSharedEvent)MemberJoinedChannelEvent, MemberLeftChannelEvent)PinAddedEvent, PinRemovedEvent)StarAddedEvent, StarRemovedEvent)TokensRevokedEvent)All events follow consistent patterns:
Events are delivered in an envelope structure with additional metadata like API app ID, team ID, and event subscription info.
Install with Tessl CLI
npx tessl i tessl/npm-slack--typesdocs
evals
scenario-1
scenario-2
scenario-3
scenario-4
scenario-5
scenario-6
scenario-7
scenario-8
scenario-9
scenario-10