Crate slack_morphism

Source
Expand description

§Slack Morphism for Rust

Slack Morphism is a modern client library for Slack Web/Events API and Block Kit.

§Slack Web API client

§Create a client instance:

use slack_morphism::prelude::*;

let client = SlackClient::new(SlackClientHyperConnector::new());

§Make Web API methods calls

For most of Slack Web API methods (except for OAuth methods, Incoming Webhooks and event replies) you need a Slack token to make a call. For simple bots you can have it in your config files, or you can obtain workspace tokens using Slack OAuth.

In the example below, we’re using a hardcoded Slack token, but don’t do that for your production bots and apps. You should securely and properly store all of Slack tokens.


use slack_morphism::prelude::*;


let client = SlackClient::new(SlackClientHyperConnector::new());

// Create our Slack API token
let token_value: SlackApiTokenValue = "xoxb-89.....".into();
let token: SlackApiToken = SlackApiToken::new(token_value);

// Create a Slack session with this token
// A session is just a lightweight wrapper around your token
// not to specify it all the time for series of calls.
let session = client.open_session(&token);

// Make your first API call (which is `api.test` here)
let test: SlackApiTestResponse = session
        .api_test(&SlackApiTestRequest::new().with_foo("Test".into()))
        .await?;

// Send a simple text message
let post_chat_req =
    SlackApiChatPostMessageRequest::new("#general".into(),
           SlackMessageContent::new().with_text("Hey there!".into())
    );

let post_chat_resp = session.chat_post_message(&post_chat_req).await?;

§Events API and OAuth support for Hyper and Axum

The library provides two different ways to work with Slack Events API:

  • Using pure Hyper-based solution
  • Using more high-level solution for axum web framework.

Also the library provides Slack events signature verifier (SlackEventSignatureVerifier) (which is already integrated in the routes implementation for you). All you need is provide your client id and secret configuration to route implementation.

§Socket Mode support

The library provides Socket Mode support additionally Events API leveraging Web-sockets in cases you don’t want/need to expose publicly available HTTP endpoint.

§Docs and examples

Please follow to the official website. Examples available on: github.

Re-exports§

pub use socket_mode::*;

Modules§

api
apps
blocks
comments
errors
events
files
listener
manifest
multipart_form
prelude
socket_mode

Macros§

md
pt
slack_block_item
slack_blocks

Structs§

EmailAddress
SLACK_HTTP_EMPTY_GET_PARAMS
SlackActionId
SlackActionType
SlackApiCookieValue
SlackApiResponseScrollerState
SlackApiToken
SlackApiTokenInit
SlackApiTokenScope
SlackApiTokenValue
SlackAppCredentials
SlackAppCredentialsInit
SlackAppId
SlackAppManifest
SlackAppManifestDisplayInformation
SlackAppManifestDisplayInformationInit
SlackAppManifestFeatures
SlackAppManifestFeaturesAppHome
SlackAppManifestFeaturesAppHomeInit
SlackAppManifestFeaturesBotUser
SlackAppManifestFeaturesBotUserInit
SlackAppManifestFeaturesInit
SlackAppManifestFeaturesShortcut
SlackAppManifestFeaturesShortcutInit
SlackAppManifestFeaturesSlashCommand
SlackAppManifestFeaturesSlashCommandInit
SlackAppManifestFeaturesWorkflowStep
SlackAppManifestFeaturesWorkflowStepInit
SlackAppManifestInit
SlackAppManifestMetadata
SlackAppManifestMetadataInit
SlackAppManifestOAuthConfig
SlackAppManifestOAuthConfigInit
SlackAppManifestOAuthConfigScopes
SlackAppManifestOAuthConfigScopesInit
SlackAppManifestSettings
SlackAppManifestSettingsEventSubscriptions
SlackAppManifestSettingsEventSubscriptionsInit
SlackAppManifestSettingsInit
SlackAppManifestSettingsInteractivity
SlackAppManifestSettingsInteractivityInit
SlackAvatarHash
SlackBasicChannelInfo
SlackBasicChannelInfoInit
SlackBasicTeamInfo
SlackBasicTeamInfoInit
SlackBasicUserInfo
SlackBasicUserInfoInit
SlackBotId
SlackBotInfo
SlackBotInfoInit
SlackCallbackId
SlackChannelCurrentState
SlackChannelCurrentStateInit
SlackChannelDetails
SlackChannelDetailsInit
SlackChannelFlags
SlackChannelFlagsInit
SlackChannelId
SlackChannelInfo
SlackChannelInfoInit
SlackChannelPriority
SlackChannelType
SlackClient
SlackClientApiCallContext
SlackClientHttpApi
SlackClientHttpApiUri
SlackClientHttpSessionApi
SlackClientId
SlackClientMessageId
SlackClientSecret
SlackClientSession
SlackColor
SlackCommandId
SlackConversationId
SlackCursorId
SlackDateTime
SlackEmoji
SlackEmojiName
Represent a Slack custom emoji name without the leading : and trailing :
SlackEnterpriseId
SlackEnterpriseSubteamId
SlackEnterpriseUser
SlackEnterpriseUserInit
SlackEnvelopeMessage
SlackEventType
SlackFile
SlackFileCommentId
SlackFileExternalType
SlackFileFlags
SlackFileFlagsInit
SlackFileId
SlackFileInit
SlackFilePrettyType
SlackFileSnippetType
SlackFileType
SlackFileUploadUrl
SlackHistoryMessage
SlackHistoryMessageInit
SlackIcon
SlackIconImages
SlackIconImagesInit
SlackIconInit
SlackLocale
SlackMessage
SlackMessageAttachment
SlackMessageAttachmentFieldObject
SlackMessageAttachmentFieldObjectInit
SlackMessageAttachmentInit
SlackMessageContent
SlackMessageContentInit
SlackMessageEdited
SlackMessageEditedInit
SlackMessageInit
SlackMessageMetadata
SlackMessageMetadataInit
SlackMessageOrigin
SlackMessageOriginInit
SlackMessageSender
SlackMessageSenderInit
SlackMimeType
SlackParentMessageParams
SlackParentMessageParamsInit
SlackReaction
SlackReactionInit
SlackReactionName
SlackResponseMetadata
SlackResponseMetadataInit
SlackResponseUrl
SlackScheduledMid
SlackSigningSecret
SlackStarsItemChannel
SlackStarsItemChannelInit
SlackStarsItemFile
SlackStarsItemFileComment
SlackStarsItemFileCommentInit
SlackStarsItemFileInit
SlackStarsItemGroup
SlackStarsItemGroupInit
SlackStarsItemIm
SlackStarsItemImInit
SlackStarsItemMessage
SlackStarsItemMessageInit
SlackTeamId
SlackTeamInfo
SlackTeamInfoInit
SlackTeamProfile
SlackTeamProfileField
SlackTeamProfileFieldId
SlackTeamProfileFieldInit
SlackTeamProfileInit
SlackTeamUrl
SlackTriggerId
SlackTs
SlackUnfurlId
SlackUpdatedMessage
SlackUpdatedMessageInit
SlackUser
SlackUserFlags
SlackUserFlagsInit
SlackUserGroup
SlackUserGroupId
SlackUserGroupInit
SlackUserGroupPrefs
SlackUserGroupPrefsInit
SlackUserId
SlackUserInit
SlackUserProfile
SlackUserProfileInit
SlackVerificationToken
SlackViewId
SlackWebSocketsUrl

Enums§

SlackApiTokenType
SlackAutoType
SlackConversationType
SlackEmojiRef
SlackMessageResponseType
SlackReactionsItem
SlackShortcutType
SlackStarsItem

Traits§

HasChannelInfo
SlackApiResponseScroller
SlackApiScrollableRequest
SlackApiScrollableResponse
SlackBlocksTemplate
SlackClientHttpConnector
SlackMessageTemplate
SlackTextFormat

Type Aliases§

AnyStdResult
ClientResult
SlackChannelPurposeInfo
SlackChannelTopicInfo
UserCallbackResult