CtrlK
BlogDocsLog inGet started
Tessl Logo

tessl/npm-slack--types

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

94

1.11x
Overview
Eval results
Files

message-metadata.mddocs/

Message Metadata

Application-specific data that can be attached to Slack messages to enable rich interactive experiences and custom workflows.

Capabilities

Message Metadata

Attach custom application data to messages for enhanced functionality and context.

/**
 * Application-specific data to attach to Slack message.
 * @see https://docs.slack.dev/messaging/message-metadata
 */
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;
}

Usage Examples:

import { MessageMetadata } from "@slack/types";

// Task management metadata
const taskMetadata: MessageMetadata = {
  event_type: "task_created",
  event_payload: {
    task_id: "task_12345",
    priority: "high",
    assignee: "U123456789",
    due_date: "2024-01-15",
    completed: false,
    tags: ["urgent", "backend"]
  }
};

// Survey metadata
const surveyMetadata: MessageMetadata = {
  event_type: "survey_response",
  event_payload: {
    survey_id: "survey_67890",
    response_count: 5,
    average_rating: 4.2,
    questions: [
      { question_id: "q1", response: "Very satisfied" },
      { question_id: "q2", response: "Would recommend" }
    ]
  }
};

// Using with message posting
const message = {
  channel: "C1234567890",
  text: "New task has been created",
  metadata: taskMetadata
};

Integration with Events

Message metadata integrates with the Events API, allowing applications to react to metadata changes:

// Message events with metadata
interface MessageEvent {
  type: 'message';
  channel: string;
  user: string;
  text: string;
  ts: string;
  metadata?: MessageMetadata;
}

Best Practices

  • Event Type Naming: Use descriptive, consistent naming for event_type values
  • Payload Structure: Keep payloads flat when possible for better performance
  • Data Types: Use appropriate primitive types (string, number, boolean)
  • Size Limits: Be mindful of message size limits when attaching metadata
  • Privacy: Don't include sensitive information in metadata as it may be visible to developers

Install with Tessl CLI

npx tessl i tessl/npm-slack--types

docs

block-kit.md

calls.md

dialog.md

events.md

index.md

interactive-elements.md

message-attachments.md

message-metadata.md

views.md

tile.json