// Helper types export type SlackAppMentionUserGroupMetadata = { teamId: string userGroupId: string userGroupName: string channelIds: string[] } export type SlackFrom = | { type: "user"; id: string } | { type: "bot"; id: string } | { type: "external_app"; id: string } | { type: "webhook"; id: string } | { type: "system" } | { type: "unknown" } | { type: "file_comment" } | { type: "workflow_builder" } | { type: "unknown_message" } | { type: "usergroup"; id: string } | { type: "integration"; id: string } | { type: "internal" } | { type: "ai_connector"; id: string } | { type: "messages_api"; id: string } | { type: "channel" } export type SlackMessage = { id: string message: string timestamp: string threadTimestamp: string uri: string from: SlackFrom to: SlackTo reactions?: Record files?: Array fileIds?: Array isFromSlackAiConnector?: boolean threadId?: string parentTimestamp?: string messageId: string } export type SlackTo = | { type: "channel"; name: string; id: string } | { type: "direct"; userIds: Array } export type SlackChannel = { id: string name: string nameNormalized?: string created: number isChannel?: boolean isGeneral?: boolean isIm?: boolean isPrivate?: boolean isMpim?: boolean isShared?: boolean isOrgShared?: boolean botIsMember?: boolean } export type SlackUser = { id: string teamId: string name: string type: "user" | "bot" scopes?: string[] userTeamIds?: string[] teamIdsForUserTeams?: string[] } export type RecordPointer = Record export type ExternalScopedConnectionTable = Record export type ExternalConnectionTable = Record export type ParsedAgentUrl = Record // Permissions export type { SlackAction, SlackModulePermissionAiConfigurable, SlackIntegration, ModulePermissions, ModuleState, } from "./integration" export type ModuleConfiguration = { name?: string connectionPointer?: RecordPointer scopes?: Array appMentionUserGroup?: SlackAppMentionUserGroupMetadata error?: | { type: "no_slack_ai_connector" } | { type: "grid_ai_connector" } | { type: "slack_workspace_mismatch" workflowsTeamId: string workflowsTeamName: string aiConnectorTeamId: string aiConnectorTeamName: string } } export type CreateThreadInChannel = ( args: | { attachedFileIds?: Array channelName: string message: string } | { attachedFileIds?: Array channelId: string message: string }, ) => Promise export type CreateThreadInDirectMessage = (args: { userIds: Array message: string attachedFileIds?: Array }) => Promise export type ReplyInThread = (args: { prefixedThreadUri: string message: string attachedFileIds?: Array }) => Promise export type UpdateMessage = (args: { prefixedMessageUri: string message: string }) => Promise export type SlackReactionResult = { status: "added" | "already_present" | "removed" | "already_absent" reaction: string channelName: string prefixedMessageUri: string message?: string } export type AddReactionToMessage = (args: { prefixedMessageUri: string reaction: string }) => Promise export type RemoveReactionFromMessage = (args: { prefixedMessageUri: string reaction: string }) => Promise export type GetThreadsInChannelSince = (args: { channelName: string timestamp: string }) => Promise>> export type QueryChannels = (args: { id?: string name?: string createdStart?: string createdEnd?: string isGeneral?: boolean isIm?: boolean isPrivate?: boolean isMpim?: boolean isShared?: boolean isOrgShared?: boolean botIsMember?: boolean }) => Promise> export type GetUser = (args: { userId: string }) => Promise export type FindUserByEmail = (args: { email: string }) => Promise export type ParseSlackUriOrUrl = (args: { uriOrUrl: string }) => Extract< ParsedAgentUrl, { type: "slackMessage" | "slackUser" | "slackChannel" } > export type ViewFileUrl = (args: { url: string }) => Promise<{ url: string fileUrl?: string fileName?: string }> export type SlackSearchInput = { question: string keywords: string lookback?: string options?: { channel?: string } } export type SlackSearchResult = { results: Array<{ id: string lastEdited: string channel?: string messages: Array<{ messageId: string lastEdited: string text: string user: string }> }> } export type Search = (args: SlackSearchInput) => Promise export type SlackLoadMessageInput = { channelId: string messageTs: string threadTs?: string } export type SlackLoadMessageResult = Record export type LoadMessage = ( args: SlackLoadMessageInput, ) => Promise export type SlackUserMessagesContextMessage = { userId: string text: string timestamp: string } export type SlackUserMessagesResultItem = { id: string channel?: string channelId: string text: string timestamp: string contextMessages?: { before?: SlackUserMessagesContextMessage[] after?: SlackUserMessagesContextMessage[] } url?: string } export type SlackUserMessagesResult = { user: SlackUser messages: Array totalCount: number } export type GetUserMessages = (args: { name?: string email?: string since?: string }) => Promise export type Module = { createThreadInChannel: CreateThreadInChannel createThreadInDirectMessage: CreateThreadInDirectMessage replyInThread: ReplyInThread updateMessage: UpdateMessage addReactionToMessage: AddReactionToMessage removeReactionFromMessage: RemoveReactionFromMessage getThreadsInChannelSince: GetThreadsInChannelSince queryChannels: QueryChannels getUser: GetUser findUserByEmail: FindUserByEmail parseSlackUriOrUrl: ParseSlackUriOrUrl viewFileUrl: ViewFileUrl search: Search loadMessage: LoadMessage getUserMessages: GetUserMessages } // Triggers export type { SlackReactionAddedTriggerConfig, SlackMessageTriggerConfig, SlackThreadCreatedTriggerConfig, SlackAppMentionTriggerConfig, SlackReactionAddedTriggerVariables, SlackMessageTriggerVariables, SlackThreadCreatedTriggerVariables, SlackAppMentionTriggerVariables, } from "./triggers"