Slaq: A Slack API Client
[!WARNING] This is an experimental crate for now, with plans to expand into a library that fully supports the Slack API.
Typed Slack Web API payload builders with an optional reqwest transport. Build request payloads in Rust, then send them with the provided blocking client or with any HTTP client you prefer.
Features
- transport-reqwest (default): enables the built-in blocking client using reqwest.
- Build-only mode: disable default features to use just the typed builders without pulling in reqwest.
Install
Default (with transport):
[dependencies]
slaq = "0.0.3"
Build-only (no reqwest; you provide HTTP):
[dependencies]
slaq = { version = "0.0.3", default-features = false }
Quick Start
With the built-in client (default feature):
use ;
use PostMessage;
Build, then send with the same client (explicit request):
use ;
use PostMessage;
Supported Methods
The following Slack Web API chat.* methods are currently available as typed payload builders:
- chat.postMessage →
api::chat::post_message::PostMessage - chat.postEphemeral →
api::chat::post_ephemeral::PostEphemeral - chat.delete →
api::chat::delete::Delete - chat.deleteScheduledMessage →
api::chat::delete_scheduled_message::DeleteScheduledMessage - chat.meMessage →
api::chat::me_message::MeMessage - chat.scheduleMessage →
api::chat::schedule_message::ScheduleMessage - chat.scheduledMessages.list →
api::chat::scheduled_messages_list::ScheduledMessagesList - chat.unfurl →
api::chat::unfurl::Unfurl - chat.update →
api::chat::update::Update
Blocks
This crate includes a minimal BlockKit-like builder with two blocks: divider and markdown.
use blocks;
use PostMessage;
let blocks = vec!;
let payload = new
.text
.blocks;
Examples
There is a basic example that sends a message:
cargo run --example hello
It expects the following environment variables:
SLACK_BOT_TOKEN: your app’s bot tokenSLACK_CHANNEL: the channel ID to post to (e.g.C01234567)
Build-only usage (no reqwest; you send it):
// Cargo.toml: slaq = { version = "0.0.3", default-features = false }
use PostMessage;
use SlackRequest; // request wrapper
Notes
- Encoding is currently JSON;
req.content_type()returnsapplication/jsonandreq.to_json()produces the body. - The built-in client is blocking. If you need async or a different transport, use build-only mode and plug in your HTTP stack.
- Responses: Slack responses include an
okfield. The built-in client handles decoding and error mapping. In build-only mode, you receive the raw response and should handle Slack errors yourself.