deno.land / x / slack_bolt@1.0.0

src/
import * as slackBolt from "https://deno.land/x/slack_bolt@1.0.0/mod.ts";

Classes

App

A Slack App

AppInitializationError
AuthorizationError
ContextMissingPropertyError
HTTPReceiver

Receives HTTP requests with Events, Slash Commands, and Actions

HTTPReceiverDeferredRequestError
MemoryStore

Default implementation of ConversationStore, which stores data in memory.

MultipleListenerError
OpineReceiver

Receives HTTP requests with Events, Slash Commands, and Actions

ReceiverAuthenticityError
ReceiverInconsistentStateError
ReceiverMultipleAckError
SocketModeReceiver

Receives Events, Slash Commands, and Actions of a web socket connection

UnknownError
WorkflowStep

Class

WorkflowStepInitializationError

Enums

ErrorCode
LogLevel

Severity levels for log entries

Variables

onlyActions

Middleware that filters out any event that isn't an action

onlyCommands

Middleware that filters out any event that isn't a command

onlyEvents

Middleware that filters out any event that isn't an event

onlyOptions

Middleware that filters out any event that isn't an options

onlyShortcuts

Middleware that filters out any event that isn't a shortcut

onlyViewActions

Middleware that filters out any event that isn't a view_submission or view_closed event

Functions

asCodedError
directMention
ignoreSelf
matchCommandName

Middleware that filters out any command that doesn't match name

matchConstraints

Middleware that checks for matches given constraints

matchEventType
matchMessage
subtype

Interfaces

AckFn
Action
ActionConstraints
ActionsBlock
AllMiddlewareArgs
AppHomeOpenedEvent
AppMentionEvent
AppOptions

App initialization options

AppRequestedEvent
AppUninstalledEvent
AttachmentAction
Authorize

Authorization function - seeds the middleware processing and listeners with an authorization context

AuthorizeResult

Authorization function outputs - data that will be available as part of event processing

AuthorizeSourceData

Authorization function inputs - authenticated data about an event for the authorization function

BasicElementAction

Any action from Slack's interactive elements

BasicSlackEvent

Any event in Slack's Events API

Block
BlockAction

A Slack Block Kit element action wrapped in the standard metadata.

BotMessageEvent
Button
ButtonAction

An action from a button element

ButtonClick

A button click action from a legacy interactive message.

CallRejectedEvent
CallUserExternal
CallUserSlack
ChannelArchiveEvent
ChannelCreatedEvent
ChannelDeletedEvent
ChannelHistoryChangedEvent
ChannelIDChangedEvent
ChannelLeftEvent
ChannelRenameEvent
ChannelSharedEvent
ChannelsSelect
ChannelsSelectAction

An action from a select menu with channels list

ChannelUnarchiveEvent
ChannelUnsharedEvent
Checkboxes
CheckboxesAction

An action from a checkboxes element

CodedError
Confirm
Confirmation
ContextBlock
ConversationsSelect
ConversationsSelectAction

An action from a select menu with conversations list

ConversationStore

Storage backend used by the conversation context middleware

Datepicker
DatepickerAction

An action from a date picker element

Dialog
DialogSubmitAction

A Slack dialog submit action wrapped in the standard metadata.

DialogValidation

A Slack dialog submission validation response. Use an object of this type to describe errors regarding inputs that were part of the submission.

DispatchActionConfig
DividerBlock
DNDUpdatedEvent
DNDUpdatedUserEvent
EmailDomainChangedEvent
EmojiChangedEvent
ExternalSelect
ExternalSelectAction

An action from a select menu with external data source

FileBlock
FileChangeEvent
FileCommentDeletedEvent
FileCreatedEvent
FileDeletedEvent
FilePublicEvent
FileSharedEvent
FileUnsharedEvent
GenericMessageEvent
GlobalShortcut

A Slack global shortcut wrapped in the standard metadata.

GridMigrationFinishedEvent
GridMigrationStartedEvent
GroupArchiveEvent
GroupCloseEvent
GroupDeletedEvent
GroupHistoryChangedEvent
GroupLeftEvent
GroupOpenEvent
GroupRenameEvent
GroupUnarchiveEvent
HeaderBlock
HTTPReceiverOptions
ImageBlock
ImageElement
IMCloseEvent
IMCreatedEvent
IMHistoryChangedEvent
IMOpenEvent
InputBlock
Installation

An individual installation of the Slack app.

InstallationQuery
InstallationStore
InstallProviderOptions
InstallURLOptions
InteractiveMessage

A Slack legacy interactive message action wrapped in the standard metadata.

InviteRequestedEvent
LinkSharedEvent
LinkUnfurls
Logger

Interface for objects where objects in this package's logs can be sent (can be used as logger option).

MemberJoinedChannelEvent
MemberLeftChannelEvent
MenuSelect

A menu selection action from a legacy interactive message.

MessageAttachment
MessageShortcut

A Slack message action wrapped in the standard metadata.

Middleware
MrkdwnElement
MultiChannelsSelect
MultiChannelsSelectAction

An action from a multi select menu with channels list

MultiConversationsSelect
MultiConversationsSelectAction

An action from a multi select menu with conversations list

MultiExternalSelect
MultiExternalSelectAction

An action from a multi select menu with external data source

MultiStaticSelect
MultiStaticSelectAction

An action from a multi select menu with static options

MultiUsersSelect
MultiUsersSelectAction

An action from a multi select menu with user list

OpineReceiverOptions
Option
OptionField
OptionsRequest

A request for options for a select menu with an external data source, wrapped in the standard metadata. The menu can have a source of Slack's Block Kit external select elements, dialogs, or legacy interactive components.

Overflow
OverflowAction

An action from an overflow menu element

PinAddedEvent
PinRemovedEvent
PlainTextElement
PlainTextInput
RadioButtons
RadioButtonsAction

An action from a radio button element

ReactionAddedEvent
ReactionFileCommentItem
ReactionFileItem
ReactionMessageItem
ReactionRemovedEvent
Receiver
ReceiverEvent
RespondFn
SayFn
SectionBlock
SelectOption
SlackActionMiddlewareArgs

Arguments which listeners and middleware receive to process an action from Slack's Block Kit interactive components, message actions, dialogs, or legacy interactive messages.

SlackCommandMiddlewareArgs

Arguments which listeners and middleware receive to process a slash command from Slack.

SlackEventMiddlewareArgs

Arguments which listeners and middleware receive to process an event from Slack's Events API.

SlackOptionsMiddlewareArgs

Arguments which listeners and middleware receive to process an options request from Slack

SlackShortcutMiddlewareArgs

Arguments which listeners and middleware receive to process a shortcut from Slack.

SlackViewMiddlewareArgs

Arguments which listeners and middleware receive to process a view submission event from Slack.

SlashCommand

A Slack slash command

SocketModeReceiverOptions
StarAddedEvent
StarRemovedEvent
StateStore
StaticSelect
StaticSelectAction

An action from a select menu with static options

SubteamCreated
SubteamMembersChanged
SubteamSelfAddedEvent
SubteamSelfRemovedEvent
SubteamUpdatedEvent
TeamDomainChangedEvent
TeamJoinEvent
TeamRenameEvent
TokensRevokedEvent
UserChangeEvent
UsersSelect
UsersSelectAction

An action from a select menu with user list

View
ViewClearResponseAction
ViewClosedAction

A Slack view_closed event wrapped in the standard metadata.

ViewErrorsResponseAction
ViewOutput
ViewPushResponseAction
ViewSubmitAction

A Slack view_submission event wrapped in the standard metadata.

ViewUpdateResponseAction
ViewWorkflowStepClosedAction

A Slack view_closed Workflow Step event

ViewWorkflowStepSubmitAction

A Slack view_submission Workflow Step event

WorkflowDeletedEvent
WorkflowPublishedEvent
WorkflowStepConfig
WorkflowStepDeletedEvent
WorkflowStepEdit

A Slack workflow step action wrapped in the standard metadata.

WorkflowStepExecuteEvent
WorkflowUnpublishedEvent

Type Aliases

AnyMiddlewareArgs
BlockButtonAction
BlockChannelsSelectAction
BlockCheckboxesAction
BlockConversationsSelectAction
BlockDatepickerAction
BlockElementAction

All known actions from in Slack's interactive elements

BlockExternalSelectAction
BlockOverflowAction
BlockRadioButtonsAction
BlockStaticSelectAction
BlockUsersSelectAction
CallUser
EventTypePattern
InteractiveAction

All actions which Slack delivers from legacy interactive messages. The full body of these actions are represented as [[InteractiveMessage]].

InteractiveButtonClick
InteractiveMenuSelect
KnownBlock
MessageEvent
MultiSelect
NextFn
OptionsSource

All sources from which Slack sends options requests.

RespondArguments
SayArguments
Select
SlackAction

All known actions from Slack's Block Kit interactive components, message actions, dialogs, and legacy interactive messages.

SlackEvent

All known event types in Slack's Events API

SlackShortcut

All known shortcuts from Slack.

SlackViewAction

Known view action types

StringIndexed

Extend this interface to build a type that is treated as an open set of properties, where each key is a string.

ViewResponseAction
WorkflowStepEditMiddleware
WorkflowStepExecuteMiddleware
WorkflowStepSaveMiddleware
blueprint illustration

Slack Bolt

TypeScript framework to build Slack apps in a flash with the latest platform features. Deno port of @slack/bolt

build status language code size issues license version

View on deno.land




Table of Contents

Usage

import "https://deno.land/x/dotenv@v2.0.0/load.ts"
import { App } from "https://deno.land/x/slack_bolt@1.0.0/mod.ts"

const app = new App({
    signingSecret: Deno.env.get("SLACK_SIGNING_SECRET"),
    token: Deno.env.get("SLACK_BOT_TOKEN"),
    ignoreSelf: true,
})

app.event("message", async ({ event, say }) => {
    console.log(event)
    await say("pong")
})

await app.start({ port: 3000 })
console.log("🦕 ⚡️")

API

Quirks

OpineReciever and HTTPReceiver/SocketModeReciever req/res types are not compatible. This causes trouble when providing a custom callback for built-in oauth failure / success (if you're not using built-in oauth / not implementing custom callbacks for failure / success, you don't have to worry about this). This requires a type guard (See simpler alternative below).

import { ServerRequest } from "https://deno.land/std@0.87.0/http/server.ts"
import {
    ParamsDictionary,
    Request as OpineRequest,
    Response as OpineResponse,
} from "https://deno.land/x/opine@1.1.0/mod.ts"

const customCallbackOptions = {
    failure: async (
        req: ServerRequest | OpineRequest<ParamsDictionary, any, any>,
        res?: OpineResponse<any>,
    ) => {
        if (isOpineRequest(req)) {
            // Your custom code here, req is Request<ParamsDictionary, any, any> and res is Response<any> from deno.land/x/opine
            // Example:
            res?.setStatus(500).send(
                "<html><body><h1>OAuth failed!</h1><div>See stderr for errors.</div></body></html>",
            )
        } else {
            // Your custom code here, req is a std/http ServerRequest, res is undefined
            // Example:
            await req.respond({
                status: 500,
                headers: new Headers({
                    "Content-Type": "text/html",
                }),
                body:
                    `<html><body><h1>OAuth failed!</h1><div></div></body></html>`,
            })
        }

        function isOpineRequest(
            _req: ServerRequest | OpineRequest<ParamsDictionary, any, any>,
            res?: OpineResponse<any>,
        ): _req is OpineRequest<ParamsDictionary, any, any> {
            return !!res // If res exists, OpineReciever is being used since only 'req' exists for HTTPReciever and SocketModeReceiver
        }
    },
}

Alternatively, just specify the correct type according to your Receiver (if you don't specify this, its HTTPReceiver by default)

  • For HTTPReceiver (default) / SocketModeReceiver
import { ServerRequest } from "https://deno.land/std@0.87.0/http/server.ts"
const customCallbackOptions = {
    failure: async (req: ServerRequest) => {
        // Your custom code here
        // Example:
        await req.respond({
            status: 500,
            headers: new Headers({
                "Content-Type": "text/html",
            }),
            body: `<html><body><h1>OAuth failed!</h1><div></div></body></html>`,
        })
    },
}
  • For OpineReceiver
import {
    ParamsDictionary,
    Request as OpineRequest,
    Response as OpineResponse,
} from "https://deno.land/x/opine@1.1.0/mod.ts"

const customCallbackOptions = {
    failure: async (
        req: OpineRequest<ParamsDictionary, any, any>,
        res: OpineResponse<any>,
    ) => {
        // Your custom code here, req is Request<ParamsDictionary, any, any> and res is Response<any> from deno.land/x/opine
        // Example:
        res?.setStatus(500).send(
            "<html><body><h1>OAuth failed!</h1><div>See stderr for errors.</div></body></html>",
        )
    },
}

Supporters

Stargazers repo roster for @KhushrajRathod/slack-bolt

Forkers repo roster for @KhushrajRathod/slack-bolt

slack_bolt
TypeScript framework to build Slack apps in a flash with the latest platform features. Deno port of @slack/bolt
GitHub Stars
42

Version Info

Tagged at
a year ago

External Dependencies