Skip to content

armgit / eve

Public Imported from GitHub
0

The Open Framework for Building Agents

feat(eve): export callSlackApi and resolveSlackBotToken from eve/channels/slack (#605)

Allen Zhou9c63a4e1a83b
diff --git a/.changeset/export-call-slack-api.md b/.changeset/export-call-slack-api.md
new file mode 100644
index 000000000..832664397
--- /dev/null
+++ b/.changeset/export-call-slack-api.md
@@ -0,0 +1,5 @@
+---
+"eve": patch
+---
+
+Export `callSlackApi` and `resolveSlackBotToken` from `eve/channels/slack`. Code running outside a webhook-side handler — schedules resolving reactions or reading history, for example — has no `ctx.slack` handle; these were the internal primitives behind `slack.request`, already public-shaped and documented, and are now importable so apps stop hand-rolling `fetch` against the Slack Web API.
diff --git a/docs/channels/slack.mdx b/docs/channels/slack.mdx
index ea9ca1d1b..d86758bf2 100644
--- a/docs/channels/slack.mdx
+++ b/docs/channels/slack.mdx
@@ -70,6 +70,33 @@ export default slackChannel({
`threadContext` performs one `conversations.replies` request for each triggering thread reply and requires the matching Slack history scope. Omit it when the agent should see only direct mentions. `loadThreadContextMessages` remains available when you need custom filtering or non-model processing of the raw thread messages.
+### Slack API calls outside a handler
+
+Inside webhook-side handlers (`onAppMention`, `onInteraction`, `events`),
+`ctx.slack.request(operation, body)` is the raw-API escape hatch. Outside
+those contexts there is no handle — a schedule resolving reactions on old
+messages, for example, has no inbound Slack request. For that, call the
+same primitive the handle uses directly:
+
+```ts
+import { callSlackApi, resolveSlackBotToken } from "eve/channels/slack";
+import { connectSlackCredentials } from "@vercel/connect/eve";
+
+const { botToken } = connectSlackCredentials("slack/my-agent");
+const response = await callSlackApi({
+ botToken,
+ operation: "reactions.get",
+ body: { channel: "C0123456789", timestamp: "1712345678.000100", full: true },
+});
+if (!response.ok) throw new Error(String(response.error));
+```
+
+`callSlackApi` resolves function-form tokens (secret managers, Connect
+rotation) at call time and form-encodes the body — the only safe default,
+since Slack's JSON support is partial (`conversations.replies` rejects
+JSON). `resolveSlackBotToken` materializes a `SlackBotToken` to a string
+when you need the bearer token itself.
+
### Delivery
The default handlers reply in-thread and show progress. Typing indicators post automatically: `Thinking…` on inbound, `Working…` on `turn.started`, a truncated reasoning snippet on `reasoning.appended`, and tool status on `actions.requested`. Reasoning snippets build progressively: extensions of at least four characters appear immediately, while smaller streamed deltas use the five-second refresh interval to avoid one Slack request per token. Override `events["reasoning.appended"]` if you prefer generic wording. Override `onAppMention` or the `events` handlers to customize.
diff --git a/packages/eve/src/public/channels/slack/index.ts b/packages/eve/src/public/channels/slack/index.ts
index 57b2365ad..4ab220380 100644
--- a/packages/eve/src/public/channels/slack/index.ts
+++ b/packages/eve/src/public/channels/slack/index.ts
@@ -40,6 +40,8 @@ export type {
} from "#public/channels/slack/inbound.js";
export {
+ callSlackApi,
+ resolveSlackBotToken,
slackContinuationToken,
type SlackPostInput,
type SlackPostedMessage,