or run

npx @tessl/cli init
Log in

Version

Tile

Overview

Evals

Files

docs

block-kit.mdcalls.mddialog.mdevents.mdindex.mdinteractive-elements.mdmessage-attachments.mdmessage-metadata.mdviews.md
tile.json

tessl/npm-slack--types

Comprehensive TypeScript type definitions for building Slack applications and integrations with the Node Slack SDK

Workspace
tessl
Visibility
Public
Created
Last updated
Describes
npmpkg:npm/@slack/types@2.16.x

To install, run

npx @tessl/cli install tessl/npm-slack--types@2.16.0

index.mddocs/

@slack/types

@slack/types provides comprehensive TypeScript type definitions for building Slack applications and integrations with the Node Slack SDK. This package serves as the foundational type system for the entire Slack development ecosystem, offering strongly-typed interfaces for Block Kit components, event handling, message formatting, and all Slack API interactions.

Package Information

  • Package Name: @slack/types
  • Package Type: npm
  • Language: TypeScript
  • Installation: npm install @slack/types

Core Imports

import {
  Button,
  SectionBlock,
  PlainTextElement,
  SlackEvent,
  ModalView,
  MessageAttachment,
  MessageMetadata,
  Dialog,
  BotProfile
} from "@slack/types";

For CommonJS:

const {
  Button,
  SectionBlock,
  PlainTextElement,
  SlackEvent,
  ModalView,
  MessageAttachment,
  MessageMetadata,
  Dialog,
  BotProfile
} = require("@slack/types");

Basic Usage

import { SectionBlock, PlainTextElement, Button } from "@slack/types";

// Define a section block with text and button
const section: SectionBlock = {
  type: "section",
  text: {
    type: "plain_text",
    text: "Hello from Slack!"
  },
  accessory: {
    type: "button",
    text: {
      type: "plain_text",
      text: "Click me"
    },
    value: "button_1",
    action_id: "button_action"
  }
};

// Use in a message or modal
const message = {
  blocks: [section]
};

Architecture

@slack/types is organized around several key architectural patterns:

  • Discriminated Unions: All blocks and elements use type field as the discriminator for type safety
  • Composition Mixins: Shared behaviors like Actionable, Confirmable are mixed into concrete interfaces
  • Hierarchical Structure: Views contain Blocks, Blocks contain Elements, Elements contain Composition Objects
  • Event System: Comprehensive event type system with discriminated unions for all 70+ Slack event types
  • Legacy Support: Deprecated types maintained for backward compatibility with clear deprecation markers

Capabilities

Block Kit Framework

Core building blocks for creating rich, interactive Slack interfaces including blocks, elements, and composition objects. Essential for building modern Slack apps with sophisticated UI components.

// Block types
type KnownBlock = ActionsBlock | ContextBlock | DividerBlock | FileBlock | HeaderBlock | ImageBlock | InputBlock | MarkdownBlock | RichTextBlock | SectionBlock | VideoBlock;

// Key block interfaces
interface SectionBlock extends Block {
  type: 'section';
  text?: TextObject;
  fields?: TextObject[];
  accessory?: SectionBlockAccessory;
  expand?: boolean;
}

interface ActionsBlock extends Block {
  type: 'actions';
  elements: ActionsBlockElement[];
}

Block Kit Framework

Interactive Elements

Complete set of interactive UI components for user input including buttons, select menus, date pickers, and text inputs. These elements enable rich user interactions within Slack interfaces.

interface Button extends Actionable, Confirmable {
  type: 'button';
  text: PlainTextElement;
  value?: string;
  url?: string;
  style?: ColorScheme;
  accessibility_label?: string;
}

interface PlainTextInput extends Actionable, Dispatchable, Focusable, Placeholdable {
  type: 'plain_text_input';
  initial_value?: string;
  multiline?: boolean;
  min_length?: number;
  max_length?: number;
}

Interactive Elements

Event System

Comprehensive event type definitions for all Slack Events API events including message events, user events, channel events, and app events. Essential for building reactive Slack applications.

type SlackEvent = AppDeletedEvent | AppHomeOpenedEvent | AppMentionEvent | ChannelCreatedEvent | MessageEvent | UserChangeEvent | /* ...70+ more event types */;

interface MessageEvent {
  type: 'message';
  channel: string;
  user: string;
  text: string;
  ts: string;
  thread_ts?: string;
  blocks?: AnyBlock[];
}

Event System

Views and Modals

Type definitions for Slack surfaces including modals, App Home tabs, and workflow step configuration views. Critical for building interactive Slack applications with sophisticated user interfaces.

type View = HomeView | ModalView | WorkflowStepView;

interface ModalView extends BaseView {
  type: 'modal';
  title: PlainTextElement;
  close?: PlainTextElement;
  submit?: PlainTextElement;
  clear_on_close?: boolean;
  notify_on_close?: boolean;
}

Views and Modals

Message Attachments

Legacy message attachment system for adding rich content to messages. While Block Kit is preferred for new development, attachments remain supported for backward compatibility.

interface MessageAttachment {
  blocks?: AnyBlock[];
  fallback?: string;
  color?: 'good' | 'warning' | 'danger' | string;
  title?: string;
  text?: string;
  fields?: MessageAttachmentField[];
  image_url?: string;
  footer?: string;
}

Message Attachments

Calls API

Type definitions for Slack Calls API enabling 3rd party call integrations within the Slack client. Used for displaying external call information and participants.

type CallUser = CallUserSlack | CallUserExternal;

interface CallUserSlack {
  slack_id: string;
}

interface CallUserExternal {
  external_id: string;
  display_name: string;
  avatar_url?: string;
}

Calls API

Message Metadata

Application-specific data that can be attached to Slack messages to enable rich interactive experiences and custom workflows. Essential for building contextual applications.

interface MessageMetadata {
  /** Human readable alphanumeric string representing your application's metadata event */
  event_type: string;
  /** Free-form object containing whatever data your application wishes to attach */
  event_payload: {
    [key: string]: string | number | boolean | MessageMetadataEventPayloadObject | MessageMetadataEventPayloadObject[];
  };
}

interface MessageMetadataEventPayloadObject {
  [key: string]: string | number | boolean;
}

Message Metadata

Dialog Interface

Legacy dialog interface for simple form collection. This interface is deprecated in favor of Block Kit modals but remains available for backward compatibility.

/**
 * @deprecated Dialogs are deprecated. Use Block Kit modals instead.
 */
interface Dialog {
  title: string;
  callback_id: string;
  elements: DialogElement[];
  submit_label?: string;
  notify_on_cancel?: boolean;
  state?: string;
}

Dialog Interface

Common Types

Core Composition Objects

type TextObject = PlainTextElement | MrkdwnElement;

interface PlainTextElement {
  type: 'plain_text';
  text: string;
  emoji?: boolean;
}

interface MrkdwnElement {
  type: 'mrkdwn';
  text: string;
  verbatim?: boolean;
}

Color and Styling

type ColorScheme = 'primary' | 'danger';
type ConversationType = 'im' | 'mpim' | 'private' | 'public';

Extension Mixins

interface Actionable {
  type: string;
  action_id?: string;
}

interface Confirmable {
  confirm?: ConfirmationDialog;
}

interface Placeholdable {
  placeholder?: PlainTextElement;
}

Shared Entity Types

interface BotProfile {
  id: string;
  name: string;
  app_id: string;
  team_id: string;
  icons: {
    [size: string]: string;
  };
  updated: number;
  deleted: boolean;
}

interface StatusEmojiDisplayInfo {
  emoji_name?: string;
  display_alias?: string;
  display_url?: string;
}