Slack Source/Output for Waken -- Socket Mode in, chat.postMessage out.
Project description
waken-slack
Slack Source/Output for Waken --
"nginx for AI agents." Unlike a Target adapter (waken-claude,
waken-gemini, ...), Slack here is a channel: SlackSource turns incoming
Slack messages into waken Events, and SlackOutput posts a Target's
Response back to the channel/thread it came from.
Install
pip install waken-slack
Needs a Slack app with Socket Mode enabled, and two tokens -- unlike most sibling adapters, which need only one:
SLACK_APP_TOKEN-- app-level token, startsxapp-, needs theconnections:writescope. Used only to open the Socket Mode connection.SLACK_BOT_TOKEN-- bot token, startsxoxb-. Used to post messages (SlackOutput) and to authenticate the Socket Mode client (SlackSource).
The app also needs the message.channels (or message.groups/message.im,
depending on where it should listen) Events API subscription turned on, even
though delivery happens over the socket rather than HTTP.
Usage
from waken import Runtime
from waken_claude import ClaudeAdapter
from waken_slack import SlackOutput, SlackSource
runtime = Runtime()
runtime.target("claude", ClaudeAdapter())
runtime.source("slack", SlackSource(target="claude"))
runtime.output("slack", SlackOutput())
runtime.run()
SlackSource resolves SLACK_APP_TOKEN/SLACK_BOT_TOKEN from the
environment by default, or accepts them as constructor arguments. Every
incoming message becomes an Event(source="slack", target="claude", payload={"prompt": text}, session_id=runtime.session("slack", external_key=f"{channel}:{thread_ts}"), metadata={"channel": ..., "thread_ts": ...}) -- replies in the same Slack thread resume the same
waken session. SlackOutput reads event.metadata["channel"]/["thread_ts"]
back off to know where to post the reply.
Bot messages (including SlackOutput's own replies) and non-message
subtypes (edits, deletes, channel-join notices, ...) are filtered out before
dispatch -- otherwise a reply posted back into Slack would re-trigger
SlackSource and loop forever.
Design notes
Socket Mode, not the HTTP Events API. waken's built-in
WebhookSource (POST /webhook/{name}) exists for exactly this kind of
integration, but its route only passes the parsed JSON body to a parser
callback -- no request headers. Slack's HTTP Events API needs the raw
X-Slack-Signature/X-Slack-Request-Timestamp headers to verify a
request's HMAC signature, which is therefore not currently possible through
WebhookSource. This is a real gap in waken core (worth fixing for any
future HTTP-webhook integration that needs header access), not something
this package works around.
Socket Mode sidesteps it entirely: a persistent WebSocket, authenticated by
the app-level token, needs no public endpoint and no signature
verification -- the connection itself is the auth. This also matches the
Source protocol's own documented flexibility (start()/stop() own "a
socket, a poll timer, a subprocess" between them).
slack_sdk directly, not slack_bolt. SlackSource talks to
slack_sdk.socket_mode.aiohttp.SocketModeClient directly rather than going
through slack_bolt's App/AsyncSocketModeHandler. slack_bolt brings a
full listener/middleware/OAuth/multi-workspace framework this package has no
use for -- one message event listener and an acknowledgement is all Socket
Mode strictly requires.
Development
git clone https://github.com/WakenHQ/waken-slack
cd waken-slack
python3 -m venv .venv && source .venv/bin/activate
pip install -e ".[dev]"
pytest
Tests mock the Slack SDK entirely (SocketModeClient, AsyncWebClient) --
no real network access, WebSocket connection, or Slack tokens needed to run
the suite.
License
Project details
Release history Release notifications | RSS feed
Download files
Download the file for your platform. If you're not sure which to choose, learn more about installing packages.
Source Distribution
Built Distribution
Filter files by name, interpreter, ABI, and platform.
If you're not sure about the file name format, learn more about wheel file names.
Copy a direct link to the current filters
File details
Details for the file waken_slack-0.1.0.tar.gz.
File metadata
- Download URL: waken_slack-0.1.0.tar.gz
- Upload date:
- Size: 9.8 kB
- Tags: Source
- Uploaded using Trusted Publishing? Yes
- Uploaded via: twine/6.1.0 CPython/3.13.12
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
8fd62a3303388a00b3317afcd3eea7b2f74be25c620903b213047197540d730a
|
|
| MD5 |
91fac0c0ddd44520c00d8662ab9f6fe9
|
|
| BLAKE2b-256 |
189314e5d3b7d20a868cb8e13ede9e904253f75c5919f337482fb45ca608af17
|
Provenance
The following attestation bundles were made for waken_slack-0.1.0.tar.gz:
Publisher:
publish.yml on WakenHQ/waken-slack
-
Statement:
-
Statement type:
https://in-toto.io/Statement/v1 -
Predicate type:
https://docs.pypi.org/attestations/publish/v1 -
Subject name:
waken_slack-0.1.0.tar.gz -
Subject digest:
8fd62a3303388a00b3317afcd3eea7b2f74be25c620903b213047197540d730a - Sigstore transparency entry: 2082043965
- Sigstore integration time:
-
Permalink:
WakenHQ/waken-slack@3d7e4add76f83bb75d89c18216c865dfdbbff9d0 -
Branch / Tag:
refs/tags/v0.1.0 - Owner: https://github.com/WakenHQ
-
Access:
public
-
Token Issuer:
https://token.actions.githubusercontent.com -
Runner Environment:
github-hosted -
Publication workflow:
publish.yml@3d7e4add76f83bb75d89c18216c865dfdbbff9d0 -
Trigger Event:
push
-
Statement type:
File details
Details for the file waken_slack-0.1.0-py3-none-any.whl.
File metadata
- Download URL: waken_slack-0.1.0-py3-none-any.whl
- Upload date:
- Size: 7.9 kB
- Tags: Python 3
- Uploaded using Trusted Publishing? Yes
- Uploaded via: twine/6.1.0 CPython/3.13.12
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
2755ca5e0402b66e9d75065928e560b10a486b777a8fabd5907d20df745b8d57
|
|
| MD5 |
dde80601562f73352b9ddc4978d4ab20
|
|
| BLAKE2b-256 |
2efd5e84fd69e086416af9a1ba3047956795e48f68fc00f8485c12a1903be88a
|
Provenance
The following attestation bundles were made for waken_slack-0.1.0-py3-none-any.whl:
Publisher:
publish.yml on WakenHQ/waken-slack
-
Statement:
-
Statement type:
https://in-toto.io/Statement/v1 -
Predicate type:
https://docs.pypi.org/attestations/publish/v1 -
Subject name:
waken_slack-0.1.0-py3-none-any.whl -
Subject digest:
2755ca5e0402b66e9d75065928e560b10a486b777a8fabd5907d20df745b8d57 - Sigstore transparency entry: 2082044018
- Sigstore integration time:
-
Permalink:
WakenHQ/waken-slack@3d7e4add76f83bb75d89c18216c865dfdbbff9d0 -
Branch / Tag:
refs/tags/v0.1.0 - Owner: https://github.com/WakenHQ
-
Access:
public
-
Token Issuer:
https://token.actions.githubusercontent.com -
Runner Environment:
github-hosted -
Publication workflow:
publish.yml@3d7e4add76f83bb75d89c18216c865dfdbbff9d0 -
Trigger Event:
push
-
Statement type: