Comprehensive TypeScript type definitions for building Slack applications and integrations with the Node Slack SDK
94
The Slack Calls API enables third-party applications to display call information and participants within the Slack client. This module provides TypeScript definitions for representing users in Slack Calls.
Union type representing all possible user types in Slack Calls.
type CallUser = CallUserSlack | CallUserExternal;Represents users from the same Slack workspace participating in a call.
interface CallUserSlack {
slack_id: string;
}Usage Example:
import { CallUserSlack } from "@slack/types";
const slackUser: CallUserSlack = {
slack_id: "U1234567890"
};Represents users from outside the Slack workspace participating in a call.
interface CallUserExternal {
external_id: string;
display_name: string;
avatar_url?: string;
}Usage Example:
import { CallUserExternal } from "@slack/types";
const externalUser: CallUserExternal = {
external_id: "ext_user_12345",
display_name: "Jane Smith",
avatar_url: "https://example.com/avatars/jane-smith.png"
};Calls often include both Slack users and external participants:
import { CallUser } from "@slack/types";
const callParticipants: CallUser[] = [
// Slack workspace user
{
slack_id: "U1234567890"
},
// External user with avatar
{
external_id: "client_001",
display_name: "John Client",
avatar_url: "https://client-portal.com/avatars/john.jpg"
},
// External user without avatar
{
external_id: "vendor_user_42",
display_name: "Sarah from Vendor Corp"
}
];Call user types are typically used within call-related Block Kit blocks:
import { CallUser, SectionBlock } from "@slack/types";
function createCallSummaryBlock(participants: CallUser[]): SectionBlock {
const participantNames = participants.map(user => {
if ('slack_id' in user) {
return `<@${user.slack_id}>`;
} else {
return user.display_name;
}
}).join(', ');
return {
type: "section",
text: {
type: "mrkdwn",
text: `*Call Participants:* ${participantNames}`
}
};
}Use type guards to differentiate between user types:
import { CallUser, CallUserSlack, CallUserExternal } from "@slack/types";
function isSlackUser(user: CallUser): user is CallUserSlack {
return 'slack_id' in user;
}
function isExternalUser(user: CallUser): user is CallUserExternal {
return 'external_id' in user;
}
function formatUserForDisplay(user: CallUser): string {
if (isSlackUser(user)) {
return `<@${user.slack_id}>`;
} else {
return user.display_name;
}
}These types are primarily used with Slack's Web API methods related to calls:
When creating a call, you specify participants using these user types:
// Example API call structure (not part of @slack/types)
const callData = {
external_unique_id: "call_12345",
join_url: "https://zoom.us/j/123456789",
title: "Project Kickoff Meeting",
users: [
{ slack_id: "U1234567890" },
{ slack_id: "U0987654321" },
{
external_id: "client_001",
display_name: "Client Representative",
avatar_url: "https://client.com/avatar.png"
}
] as CallUser[]
};Update call information including participant changes:
const updatedParticipants: CallUser[] = [
{ slack_id: "U1234567890" },
{
external_id: "new_participant",
display_name: "Late Joiner",
avatar_url: "https://example.com/avatars/late-joiner.png"
}
];CallUserSlack for workspace members as it provides better integration with Slack's user management.external_id values across calls for the same external user to enable proper user recognition.import { CallUser } from "@slack/types";
interface ConferenceBridgeParticipant {
phoneNumber?: string;
slackUserId?: string;
displayName: string;
avatarUrl?: string;
}
function mapBridgeParticipants(
bridgeParticipants: ConferenceBridgeParticipant[]
): CallUser[] {
return bridgeParticipants.map(participant => {
if (participant.slackUserId) {
return {
slack_id: participant.slackUserId
};
} else {
return {
external_id: participant.phoneNumber || `external_${Date.now()}`,
display_name: participant.displayName,
avatar_url: participant.avatarUrl
};
}
});
}import { CallUser } from "@slack/types";
interface VideoCallParticipant {
userId: string;
name: string;
email?: string;
avatarUrl?: string;
isSlackUser: boolean;
slackId?: string;
}
function convertVideoParticipants(
videoParticipants: VideoCallParticipant[]
): CallUser[] {
return videoParticipants.map(participant => {
if (participant.isSlackUser && participant.slackId) {
return {
slack_id: participant.slackId
};
} else {
return {
external_id: participant.userId,
display_name: participant.name,
avatar_url: participant.avatarUrl
};
}
});
}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