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§
Macros§
Structs§
- Email
Address - SLACK_
HTTP_ EMPTY_ GET_ PARAMS - Slack
Action Id - Slack
Action Type - Slack
ApiCookie Value - Slack
ApiResponse Scroller State - Slack
ApiToken - Slack
ApiToken Init - Slack
ApiToken Scope - Slack
ApiToken Value - Slack
AppCredentials - Slack
AppCredentials Init - Slack
AppId - Slack
AppManifest - Slack
AppManifest Display Information - Slack
AppManifest Display Information Init - Slack
AppManifest Features - Slack
AppManifest Features AppHome - Slack
AppManifest Features AppHome Init - Slack
AppManifest Features BotUser - Slack
AppManifest Features BotUser Init - Slack
AppManifest Features Init - Slack
AppManifest Features Shortcut - Slack
AppManifest Features Shortcut Init - Slack
AppManifest Features Slash Command - Slack
AppManifest Features Slash Command Init - Slack
AppManifest Features Workflow Step - Slack
AppManifest Features Workflow Step Init - Slack
AppManifest Init - Slack
AppManifest Metadata - Slack
AppManifest Metadata Init - Slack
AppManifestO Auth Config - Slack
AppManifestO Auth Config Init - Slack
AppManifestO Auth Config Scopes - Slack
AppManifestO Auth Config Scopes Init - Slack
AppManifest Settings - Slack
AppManifest Settings Event Subscriptions - Slack
AppManifest Settings Event Subscriptions Init - Slack
AppManifest Settings Init - Slack
AppManifest Settings Interactivity - Slack
AppManifest Settings Interactivity Init - Slack
Avatar Hash - Slack
Basic Channel Info - Slack
Basic Channel Info Init - Slack
Basic Team Info - Slack
Basic Team Info Init - Slack
Basic User Info - Slack
Basic User Info Init - Slack
BotId - Slack
BotInfo - Slack
BotInfo Init - Slack
Callback Id - Slack
Channel Current State - Slack
Channel Current State Init - Slack
Channel Details - Slack
Channel Details Init - Slack
Channel Flags - Slack
Channel Flags Init - Slack
Channel Id - Slack
Channel Info - Slack
Channel Info Init - Slack
Channel Priority - Slack
Channel Type - Slack
Client - Slack
Client ApiCall Context - Slack
Client Http Api - Slack
Client Http ApiUri - Slack
Client Http Session Api - Slack
Client Id - Slack
Client Message Id - Slack
Client Secret - Slack
Client Session - Slack
Color - Slack
Command Id - Slack
Conversation Id - Slack
Cursor Id - Slack
Date Time - Slack
Emoji - Slack
Emoji Name - Represent a Slack custom emoji name without the leading
:
and trailing:
- Slack
Enterprise Id - Slack
Enterprise Subteam Id - Slack
Enterprise User - Slack
Enterprise User Init - Slack
Envelope Message - Slack
Event Type - Slack
File - Slack
File Comment Id - Slack
File External Type - Slack
File Flags - Slack
File Flags Init - Slack
File Id - Slack
File Init - Slack
File Pretty Type - Slack
File Snippet Type - Slack
File Type - Slack
File Upload Url - Slack
History Message - Slack
History Message Init - Slack
Icon - Slack
Icon Images - Slack
Icon Images Init - Slack
Icon Init - Slack
Locale - Slack
Message - Slack
Message Attachment - Slack
Message Attachment Field Object - Slack
Message Attachment Field Object Init - Slack
Message Attachment Init - Slack
Message Content - Slack
Message Content Init - Slack
Message Edited - Slack
Message Edited Init - Slack
Message Init - Slack
Message Metadata - Slack
Message Metadata Init - Slack
Message Origin - Slack
Message Origin Init - Slack
Message Sender - Slack
Message Sender Init - Slack
Mime Type - Slack
Parent Message Params - Slack
Parent Message Params Init - Slack
Reaction - Slack
Reaction Init - Slack
Reaction Name - Slack
Response Metadata - Slack
Response Metadata Init - Slack
Response Url - Slack
Scheduled Mid - Slack
Signing Secret - Slack
Stars Item Channel - Slack
Stars Item Channel Init - Slack
Stars Item File - Slack
Stars Item File Comment - Slack
Stars Item File Comment Init - Slack
Stars Item File Init - Slack
Stars Item Group - Slack
Stars Item Group Init - Slack
Stars Item Im - Slack
Stars Item ImInit - Slack
Stars Item Message - Slack
Stars Item Message Init - Slack
Team Id - Slack
Team Info - Slack
Team Info Init - Slack
Team Profile - Slack
Team Profile Field - Slack
Team Profile Field Id - Slack
Team Profile Field Init - Slack
Team Profile Init - Slack
Team Url - Slack
Trigger Id - SlackTs
- Slack
Unfurl Id - Slack
Updated Message - Slack
Updated Message Init - Slack
User - Slack
User Flags - Slack
User Flags Init - Slack
User Group - Slack
User Group Id - Slack
User Group Init - Slack
User Group Prefs - Slack
User Group Prefs Init - Slack
User Id - Slack
User Init - Slack
User Profile - Slack
User Profile Init - Slack
Verification Token - Slack
View Id - Slack
WebSockets Url
Enums§
- Slack
ApiToken Type - Slack
Auto Type - Slack
Conversation Type - Slack
Emoji Ref - Slack
Message Response Type - Slack
Reactions Item - Slack
Shortcut Type - Slack
Stars Item
Traits§
- HasChannel
Info - Slack
ApiResponse Scroller - Slack
ApiScrollable Request - Slack
ApiScrollable Response - Slack
Blocks Template - Slack
Client Http Connector - Slack
Message Template - Slack
Text Format