Slack Agent
This guide shows how to build event-driven AI agents with VoltAgent and Slack using Triggers and Actions.
You'll create an agent that uses Triggers to receive Slack messages, processes them (with optional weather lookup), and uses Actions to reply in the same channel.
Follow the steps with your own keys and workspace. You can get the agent source code here.
Create the Project
Run the CLI to scaffold a new project:
npm create voltagent-app@latest
Configure and Start
If you skipped API key entry during setup, create or edit the .env file in your project root and add your API key:
- OpenAI
- Anthropic
- Google Gemini
- Groq
- Mistral
OPENAI_API_KEY=your-api-key-here
ANTHROPIC_API_KEY=your-api-key-here
GOOGLE_GENERATIVE_AI_API_KEY=your-api-key-here
GROQ_API_KEY=your-api-key-here
MISTRAL_API_KEY=your-api-key-here
Now start the development server:
- npm
- yarn
- pnpm
npm run dev
yarn dev
pnpm dev
You should see the VoltAgent server startup message:
═══════════════════════════════════════════════════
VOLTAGENT SERVER STARTED SUCCESSFULLY
═══════════════════════════════════════════════════
✓ HTTP Server: http://localhost:3141
↪ Share it: pnpm volt tunnel 3141 (secure HTTPS tunnel for teammates)
Docs: https://voltagent.dev/docs/deployment/local-tunnel/
✓ Swagger UI: http://localhost:3141/ui
Test your agents with VoltOps Console: https://console.voltagent.dev
═══════════════════════════════════════════════════
Set Up the Slack Trigger in Console
Open VoltAgent Console and go to Triggers → Create Trigger.
- Select Slack → Message posted to channel
- Use the managed Slack app when prompted
- Create a Slack credential and save the
credentialId
Expose Your Local Agent with Volt Tunnel
Volt Tunnel exposes your local server to the internet so triggers can reach it.
Run the tunnel command:
pnpm volt tunnel 3141
Copy the tunnel URL (e.g., https://your-tunnel.tunnel.voltagent.dev) and set it as the Endpoint URL in the trigger configuration.
The project is set up and the Slack trigger is configured. The following steps cover wiring the trigger to your agent and adding the reply action.
Wire the Slack Trigger to Your Agent
This code sets up a trigger handler that receives Slack messages and can call a weather tool. The reply tool is added in the next step.
Add the Slack Action and Reply Tool
Open VoltAgent Console and go to Actions → Create Action.
- Select Slack and the same credential
- Save the action
Add the VoltOps client and sendSlackMessage tool to your code:
Test End-to-End
Now test the complete flow from Slack to your agent and back.
Add these environment variables to your .env file:
VOLTAGENT_PUBLIC_KEY=pk_...
VOLTAGENT_SECRET_KEY=sk_...
SLACK_CREDENTIAL_ID=cred_...
With the tunnel and server running:
- Mention the bot or post a message in the channel
- The trigger sends the event to your agent
- The agent processes the message (calls
getWeatherif asked) - The agent replies via
sendSlackMessage
View request/response logs in Actions → Runs in Console.
- Shared Slack app Request URL: https://api.voltagent.dev/hooks/slack (or your host).
- Invite the bot to the channel (/invite @your-bot).
- Keep VOLTAGENT_PUBLIC_KEY, VOLTAGENT_SECRET_KEY, and SLACK_CREDENTIAL_ID in .env.
- Use Volt Tunnel locally; switch to your deployed URL later.
Related Documentation
- Triggers Usage - Trigger configuration reference
- Tools - Creating agent tools