Comprehensive TypeScript type definitions for building Slack applications and integrations with the Node Slack SDK
94
Application-specific data that can be attached to Slack messages to enable rich interactive experiences and custom workflows.
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
};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;
}event_type valuesInstall 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