Slack
Receive Slack Events API and interactivity requests.
The signing secret is on your Slack app's Basic Information page. Slack sends a url_verification challenge when you register the URL; answer it from the handler.
app/api/webhooks/slack/route.ts
import { webhook, slack } from "next-webhooks";
export const POST = webhook({
provider: slack({ secret: process.env.SLACK_SIGNING_SECRET! }),
handler: async (event) => {
const payload = event.payload as {
type?: string;
challenge?: string;
event?: unknown;
};
if (payload?.type === "url_verification") {
return Response.json({ challenge: payload.challenge });
}
if (payload?.type === "event_callback") {
// payload.event has the actual event (message, reaction_added, ...)
}
},
});Notes
- Slack expects a response within 3 seconds, so keep the handler fast and defer heavy work
- Events are deduplicated by the event_id field in the payload