Comprehensive TypeScript type definitions for building Slack applications and integrations with the Node Slack SDK
94
Views define the structure of Slack's interactive surfaces including modals, App Home tabs, and workflow step configurations. They provide the foundation for building rich user interfaces within Slack.
Union type covering all supported view types.
type View = HomeView | ModalView | WorkflowStepView;Common properties shared by all view types.
interface BaseView {
blocks: AnyBlock[];
private_metadata?: string;
callback_id?: string;
external_id?: string;
}Interactive modal dialogs with titles, submit/close buttons, and content blocks.
interface ModalView extends BaseView {
type: 'modal';
title: PlainTextElement;
close?: PlainTextElement;
submit?: PlainTextElement;
clear_on_close?: boolean;
notify_on_close?: boolean;
}Usage Example:
import { ModalView, InputBlock, PlainTextInput } from "@slack/types";
const modal: ModalView = {
type: "modal",
title: {
type: "plain_text",
text: "User Registration"
},
submit: {
type: "plain_text",
text: "Submit"
},
close: {
type: "plain_text",
text: "Cancel"
},
blocks: [
{
type: "input",
block_id: "name_input",
label: {
type: "plain_text",
text: "Full Name"
},
element: {
type: "plain_text_input",
action_id: "name_value",
placeholder: {
type: "plain_text",
text: "Enter your full name"
}
}
},
{
type: "input",
block_id: "email_input",
label: {
type: "plain_text",
text: "Email Address"
},
element: {
type: "email_text_input",
action_id: "email_value",
placeholder: {
type: "plain_text",
text: "your.email@example.com"
}
}
}
],
callback_id: "user_registration_modal",
private_metadata: "registration_flow_v1"
};App Home tab interface for displaying custom content in the user's App Home.
interface HomeView extends BaseView {
type: 'home';
}Usage Example:
import { HomeView, SectionBlock, HeaderBlock } from "@slack/types";
const homeView: HomeView = {
type: "home",
blocks: [
{
type: "header",
text: {
type: "plain_text",
text: "Welcome to Your Dashboard"
}
},
{
type: "section",
text: {
type: "mrkdwn",
text: "Here's a summary of your recent activity:"
}
},
{
type: "section",
fields: [
{
type: "mrkdwn",
text: "*Tasks Completed:*\n25"
},
{
type: "mrkdwn",
text: "*Messages Sent:*\n142"
}
]
},
{
type: "actions",
elements: [
{
type: "button",
text: {
type: "plain_text",
text: "View Reports"
},
action_id: "view_reports",
style: "primary"
},
{
type: "button",
text: {
type: "plain_text",
text: "Settings"
},
action_id: "open_settings"
}
]
}
]
};Configuration modal for legacy Workflow Steps from Apps.
interface WorkflowStepView extends BaseView {
type: 'workflow_step';
submit_disabled?: boolean;
}Note: Workflow Steps from Apps are deprecated and will no longer be executed starting September 12, 2024.
All views contain an array of blocks that define their content structure.
blocks: AnyBlock[];The blocks array can contain any valid Block Kit blocks:
ActionsBlock - Interactive elementsContextBlock - Contextual informationDividerBlock - Visual separatorsHeaderBlock - Section headersImageBlock - Image displaysInputBlock - Form inputs (modals only)SectionBlock - Text content with optional accessoriesRichTextBlock - Formatted rich textVideoBlock - Embedded videosString data passed to interaction payloads for maintaining state.
private_metadata?: string;Usage Example:
const modal: ModalView = {
// ... other properties
private_metadata: JSON.stringify({
user_id: "U123456",
flow_step: "confirmation",
original_message_ts: "1609459200.000300"
})
};Identifier for recognizing view interactions and submissions.
callback_id?: string;Custom identifier unique per team for external reference.
external_id?: string;Required title displayed in modal header.
title: PlainTextElement;Optional submit button text (required when input blocks are present).
submit?: PlainTextElement;Optional close button text.
close?: PlainTextElement;When true, clicking close clears all modal views and closes the modal.
clear_on_close?: boolean;When true, sends view_closed event when user clicks close button.
notify_on_close?: boolean;Modals support several interaction patterns:
Use input blocks to collect structured data from users:
const formModal: ModalView = {
type: "modal",
title: { type: "plain_text", text: "Project Details" },
submit: { type: "plain_text", text: "Create Project" },
blocks: [
{
type: "input",
label: { type: "plain_text", text: "Project Name" },
element: {
type: "plain_text_input",
action_id: "project_name"
}
},
{
type: "input",
label: { type: "plain_text", text: "Team Members" },
element: {
type: "multi_users_select",
action_id: "team_members",
placeholder: { type: "plain_text", text: "Select team members" }
}
},
{
type: "input",
label: { type: "plain_text", text: "Due Date" },
element: {
type: "datepicker",
action_id: "due_date"
}
}
]
};Use private_metadata to track workflow state across multiple modal views:
const step1Modal: ModalView = {
type: "modal",
title: { type: "plain_text", text: "Setup - Step 1 of 3" },
submit: { type: "plain_text", text: "Next" },
blocks: [/* step 1 content */],
private_metadata: JSON.stringify({ step: 1, data: {} }),
callback_id: "setup_workflow"
};Modal content can be updated using the views.update API method with the same view structure.
App Home views provide a persistent interface for users:
const dashboardHome: HomeView = {
type: "home",
blocks: [
{ type: "header", text: { type: "plain_text", text: "Dashboard" } },
{ type: "divider" },
{
type: "section",
text: { type: "mrkdwn", text: "*Recent Activity*" },
accessory: {
type: "button",
text: { type: "plain_text", text: "Refresh" },
action_id: "refresh_dashboard"
}
}
]
};const navigationHome: HomeView = {
type: "home",
blocks: [
{
type: "actions",
elements: [
{
type: "button",
text: { type: "plain_text", text: "📊 Reports" },
action_id: "show_reports"
},
{
type: "button",
text: { type: "plain_text", text: "⚙️ Settings" },
action_id: "show_settings"
},
{
type: "button",
text: { type: "plain_text", text: "❓ Help" },
action_id: "show_help"
}
]
}
]
};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