CtrlK
BlogDocsLog inGet started
Tessl Logo

tessl/npm-slack--web-api

Official library for using the Slack Platform's Web API

Pending
Overview
Eval results
Files

reactions.mddocs/

Reactions

Add, remove, and retrieve emoji reactions on messages, files, and file comments. Reactions provide a lightweight way for users to express sentiment or acknowledgment without sending full messages.

Capabilities

Add Reaction

Add an emoji reaction to a message, file, or file comment.

/**
 * Add a reaction to an item
 * @param options - Reaction parameters with target item and emoji
 * @returns Promise resolving to success confirmation
 */
reactions.add(options: ReactionsAddArguments): Promise<ReactionsAddResponse>;

interface ReactionsAddArguments extends MessageArgument, TokenOverridable, ReactionName {}

interface ReactionName {
  /** Reaction (emoji) name without colons (e.g., 'thumbsup', 'heart') */
  name: string;
}

interface MessageArgument {
  /** Channel containing the message */
  channel: string;
  /** Timestamp of the message to add reaction to */
  timestamp: string;
}

interface ReactionsAddResponse extends WebAPICallResult {
  /** Whether the reaction was successfully added */
  ok: boolean;
}

Usage Examples:

import { WebClient } from "@slack/web-api";

const web = new WebClient(process.env.SLACK_BOT_TOKEN);

// Add thumbs up reaction to a message
await web.reactions.add({
  channel: "C1234567890",
  timestamp: "1234567890.123456",
  name: "thumbsup"
});

// Add custom emoji reaction
await web.reactions.add({
  channel: "C1234567890", 
  timestamp: "1234567890.123456",
  name: "custom_emoji"
});

Get Reactions

Retrieve reactions for a specific message, file, or file comment.

/**
 * Get reactions for an item
 * @param options - Target item parameters
 * @returns Promise resolving to reaction details
 */
reactions.get(options: ReactionsGetArguments): Promise<ReactionsGetResponse>;

type ReactionsGetArguments = ReactionsFull & TokenOverridable & (MessageArgument | FileArgument | FileCommentArgument);

interface ReactionsFull {
  /** If true, return the complete reaction list */
  full?: boolean;
}

interface FileArgument {
  /** File ID to get reactions for */
  file: string;
}

interface FileCommentArgument {
  /** File comment ID to get reactions for */
  file_comment: string;
}

interface ReactionsGetResponse extends WebAPICallResult {
  /** The item that has reactions */
  message?: Message;
  file?: File;
  comment?: FileComment;
  /** Type of item ('message', 'file', or 'file_comment') */
  type?: string;
}

List Reactions

List reactions made by a user across the workspace.

/**
 * List reactions made by a user
 * @param options - Optional filtering and pagination parameters
 * @returns Promise resolving to list of user's reactions
 */
reactions.list(options?: ReactionsListArguments): Promise<ReactionsListResponse>;

type ReactionsListArguments = OptionalArgument<
  ReactionsFull &
  TokenOverridable &
  TraditionalPagingEnabled &
  CursorPaginationEnabled &
  OptionalTeamAssignable & {
    /** Show reactions made by this user (defaults to authed user) */
    user?: string;
  }
>;

interface ReactionsListResponse extends WebAPICallResult {
  /** Array of items with reactions */
  items?: ReactionItem[];
  /** Pagination information */
  paging?: {
    count: number;
    total: number;
    page: number;
    pages: number;
  };
  /** Response metadata with cursor for pagination */
  response_metadata?: {
    next_cursor?: string;
  };
}

interface ReactionItem {
  /** Type of item reacted to */
  type: string;
  /** Channel containing the item */
  channel?: string;
  /** Message object (if type is 'message') */
  message?: Message;
  /** File object (if type is 'file') */
  file?: File;
  /** File comment object (if type is 'file_comment') */
  comment?: FileComment;
}

Remove Reaction

Remove an emoji reaction from a message, file, or file comment.

/**
 * Remove a reaction from an item
 * @param options - Reaction parameters with target item and emoji
 * @returns Promise resolving to success confirmation
 */
reactions.remove(options: ReactionsRemoveArguments): Promise<ReactionsRemoveResponse>;

type ReactionsRemoveArguments = TokenOverridable & ReactionName & (MessageArgument | FileArgument | FileCommentArgument);

interface ReactionsRemoveResponse extends WebAPICallResult {
  /** Whether the reaction was successfully removed */
  ok: boolean;
}

Usage Examples:

// Remove thumbs up reaction from a message
await web.reactions.remove({
  channel: "C1234567890",
  timestamp: "1234567890.123456", 
  name: "thumbsup"
});

// Remove reaction from a file
await web.reactions.remove({
  file: "F1234567890",
  name: "heart"
});

// Remove reaction from a file comment
await web.reactions.remove({
  file_comment: "Fc1234567890",
  name: "thinking_face"
});

Pagination

The reactions.list method supports both traditional and cursor-based pagination:

// Traditional pagination
const page1 = await web.reactions.list({
  count: 50,
  page: 1
});

// Cursor-based pagination  
const page1 = await web.reactions.list({
  limit: 50
});

const page2 = await web.reactions.list({
  limit: 50,
  cursor: page1.response_metadata?.next_cursor
});

Core Types

interface TokenOverridable {
  /** Override the default token for this request */
  token?: string;
}

interface OptionalTeamAssignable {
  /** Team ID for Enterprise Grid workspaces */
  team_id?: string;
}

interface TraditionalPagingEnabled {
  /** Number of items to return per page */
  count?: number;
  /** Page number for traditional pagination */
  page?: number;
}

interface CursorPaginationEnabled {
  /** Cursor token for pagination */
  cursor?: string;
  /** Maximum number of items to return */
  limit?: number;
}

Install with Tessl CLI

npx tessl i tessl/npm-slack--web-api

docs

admin-operations.md

authentication-oauth.md

chat-operations.md

client-configuration.md

conversation-management.md

core-api-methods.md

error-handling.md

file-operations.md

index.md

pins.md

reactions.md

search.md

user-groups.md

user-operations.md

views-modals.md

tile.json