tools-src/slack/README.md
A standalone WASM component that provides Slack integration for IronClaw. This serves as both a functional tool and a template for building custom WASM tools.
Rust toolchain with WASM target:
rustup target add wasm32-wasip2
cargo-component for building WASM components:
cargo install cargo-component
Slack Bot Token with the following OAuth scopes:
chat:write - Send messageschannels:read - List public channelschannels:history - Read channel historygroups:read - List private channelsgroups:history - Read private channel historyreactions:write - Add reactionsusers:read - Get user informationcd tools-src/slack
cargo component build --release
The compiled WASM component will be at:
target/wasm32-wasip2/release/slack_tool.wasm
Copy the WASM and capabilities files to the agent's tools directory:
mkdir -p ~/.ironclaw/tools
cp target/wasm32-wasip2/release/slack_tool.wasm ~/.ironclaw/tools/slack.wasm
cp slack.capabilities.json ~/.ironclaw/tools/
Use the agent CLI or API to store the tool:
ironclaw tool install \
--name slack \
--wasm target/wasm32-wasip2/release/slack_tool.wasm \
--capabilities slack.capabilities.json
Store your Slack bot token as a secret:
ironclaw secret set slack_bot_token "xoxb-your-token-here"
Or via SQL:
INSERT INTO secrets (user_id, name, encrypted_value, key_salt)
VALUES ('your_user_id', 'slack_bot_token', ...);
{
"action": "send_message",
"channel": "#general",
"text": "Hello from IronClaw!"
}
{
"action": "send_message",
"channel": "C1234567890",
"text": "This is a thread reply",
"thread_ts": "1234567890.123456"
}
{
"action": "list_channels",
"limit": 50
}
{
"action": "get_channel_history",
"channel": "C1234567890",
"limit": 10
}
{
"action": "post_reaction",
"channel": "C1234567890",
"timestamp": "1234567890.123456",
"emoji": "thumbsup"
}
{
"action": "get_user_info",
"user_id": "U1234567890"
}
This tool runs in a sandboxed WASM environment with strict capability controls:
slack.com/api/*The slack.capabilities.json file declares what this tool needs:
{
"http": {
"allowlist": [
{ "host": "slack.com", "path_prefix": "/api/", "methods": ["GET", "POST"] }
],
"credentials": {
"slack_bot_token": {
"secret_name": "slack_bot_token",
"location": { "type": "bearer" },
"host_patterns": ["slack.com"]
}
},
"rate_limit": { "requests_per_minute": 50, "requests_per_hour": 1000 }
},
"secrets": {
"allowed_names": ["slack_bot_token"]
}
}
Use this as a template for creating new WASM tools:
Cargo.toml with your tool namesrc/types.rs with your action typessrc/api.rssrc/lib.rs*.capabilities.json filecargo component build --releaseCargo.toml - Rust package config with WASM targetsrc/lib.rs - WIT bindings and main dispatchsrc/types.rs - Request/response typessrc/api.rs - API implementation*.capabilities.json - Security capabilities declarationTools implement the sandboxed-tool world from wit/tool.wit:
world sandboxed-tool {
import host; // log, http-request, secret-exists, etc.
export tool; // execute, schema, description
}
Ensure you've stored the secret:
ironclaw secret set slack_bot_token "xoxb-..."
Check that slack.capabilities.json includes the endpoint you're trying to access.
The tool has a default rate limit of 50 requests/minute. Wait and retry.
Ensure you have the WASM target and cargo-component installed:
rustup target add wasm32-wasip2
cargo install cargo-component
MIT OR Apache-2.0