Skip to main content
Vercel

Vercel Shows How to Build Slack AI Agents and Stream Claude Responses in Next.js

Published by
SectorHQ Editorial
Vercel Shows How to Build Slack AI Agents and Stream Claude Responses in Next.js

Photo by Alexandre Debiève on Unsplash

Vercel reports that developers can now build AI‑powered Slack agents in Next.js using its Chat SDK and AI SDK, with the ToolLoopAgent handling autonomous tool calls, state managed via Redis and Vercel AI Gateway, all without custom infrastructure.

Key Facts

  • Key company: Vercel

Vercel’s new guide demonstrates a full‑stack pattern for turning a Slack bot into an autonomous AI agent by combining its Chat SDK, AI SDK, and the Vercel AI Gateway. The walkthrough starts by wiring Slack’s event API to the Chat SDK, which normalizes webhook verification, message parsing, and thread tracking across platforms. Once a mention arrives, the SDK routes the payload to an `onNewMention` handler that invokes the AI SDK’s `ToolLoopAgent`. This agent wraps an Anthropic Claude model—identified by the string `anthropic/claude-sonnet-4.6`—and supplies a toolbox of functions the model can call. The loop runs until the model produces a final response, at which point the Chat SDK formats the output and posts it back to the Slack thread, all without the developer writing any custom integration code for the Slack API (Vercel Knowledge Base).

State management is handled by a Redis adapter that Vercel ships as part of the Chat SDK. The adapter stores conversation history and a distributed lock for each thread, ensuring that concurrent mentions on the same channel do not race. According to the Vercel documentation, the Redis instance can be a local server or a managed service such as Upstash, and the SDK automatically serializes messages into a format compatible with Claude’s chat API. By delegating state to Redis, the agent can resume multi‑turn dialogs after a restart, a capability that would otherwise require a bespoke persistence layer.

The AI SDK’s streaming support is illustrated in a separate Vercel blog post on Claude API streaming. Using the `streamText` helper from `ai/react`, developers expose an API route (`/api/chat`) that forwards the incoming message to Claude via the Vercel AI Gateway and returns a `ReadableStream` to the client. The client component consumes the stream with `useChat`, rendering tokens as they arrive. The post notes that the first token appears in roughly 500 ms, turning an 8‑15 second “black‑box” wait into a fluid, real‑time experience, even though the total latency remains unchanged. This pattern is directly reused in the Slack agent: the `ToolLoopAgent` streams partial tool results and model output back to Slack, giving users the impression of instantaneous feedback.

Tool invocation is the most distinctive feature of the agent. The guide shows how to register functions—such as a weather lookup or a ticket‑creation API—with the `ToolLoopAgent`. When Claude decides that a tool call is needed, the SDK executes the function, captures the result, and feeds it back into the model as a new system message. This closed‑loop reasoning enables the bot to perform complex tasks without human intervention. The Vercel Knowledge Base points out that the same pattern scales: developers can add new tools to the agent’s toolbox and let Claude orchestrate them autonomously, a capability that previously required hand‑crafted prompt engineering.

Finally, the guide emphasizes deployment simplicity. By pushing the Next.js app to Vercel, the AI Gateway automatically injects the Anthropic API key, and the Vercel platform provisions serverless functions for the webhook endpoints and streaming routes. No separate compute clusters or container orchestration are needed. The entire stack—Slack adapter, Redis state, Claude model, and streaming response—runs within Vercel’s serverless environment, allowing developers to focus on business logic rather than infrastructure. This end‑to‑end example illustrates how Vercel’s unified SDKs lower the barrier to building production‑grade, tool‑enabled AI agents for messaging platforms.

Sources

Primary source
Other signals
  • Dev.to AI Tag

Reporting based on verified sources and public filings. Sector HQ editorial standards require multi-source attribution.

More from SectorHQ:📊Intelligence📝Blog

🏢Companies in This Story

Related Stories