VercelLogotypeVercelLogotype
LoginSign Up
Back to Templates

OpenAI AI-Powered Slackbot with GPT

Build an AI-powered Slackbot with Node.js and Vercel Functions.

DeployView Demo
Slackbot OpenAI

OpenAI Slackbot with Node.js

This is a Slackbot you can ask questions and get answers from OpenAI's GPT model.

Environment Variables

After completing the setup instructions below, you will have the following .env file in your project for testing locally, and the same environment variables added on Vercel:

OPENAI_API_KEY=
SLACK_BOT_TOKEN=
SLACK_SIGNING_SECRET=
SLACK_ADMIN_MEMBER_ID=
OpenAI API Key
  • Create a new key on OpenAI API Keys and "Create new secret key", optionally naming the key.
  • Add the key to Vercel's environment variables as OPENAI_API_KEY.
Slack Bot Token & Signing Secret

Go to Slack API Apps Page:

  • Create new App
    • From Scratch
    • Name your app & pick a workspace
  • Go to OAuth & Permissions
    • Scroll to scopes
    • Add the following scopes
      • app_mentions:read
      • channels:history
      • chat:write
      • commands
    • Click "Install to Workplace"
    • Copy Bot User OAuth Token
    • Add the token to Vercel's environment variables as SLACK_BOT_TOKEN
  • Getting signing secret
    • Basic Information --> App Credentials --> Copy Signing Secret
    • Add the secret to Vercel's environment variables as SLACK_SIGNING_SECRET
Admin's Slack Member ID
  • Click on your profile picture in Slack and click Profile.
  • Click on the three dots in the middle right corner and select Copy member ID.
  • Add the ID to Vercel's environment variables as SLACK_ADMIN_MEMBER_ID.

Enable Slack Events

After successfully deploying the app, go to Slack API Apps Page and select your app:

  • Go to Event Subscriptions and enable events.
  • Add the following URL to Request URL:
    • https://<your-vercel-app>.vercel.app/api/events
    • Make sure the URL is verified, otherwise check out Vercel Logs for troubleshooting.
    • Subscribe to bot events by adding:
      • app_mention
      • channel_created
    • Click Save Changes.
  • Slack requires you to reinstall the app to apply the changes.

Local Development

Use the Vercel CLI and localtunnel to test out this project locally:

pnpm i -g vercel
pnpm vercel dev --listen 3000 --yes
npx localtunnel --port 3000

Make sure to modify the subscription URL to the localtunnel URL.

GitHub Repovercel/examples
LicenseView License
Use Cases
AI
Stack
Other

Related Templates

Get Started

  • Templates
  • Supported frameworks
  • Marketplace
  • Domains

Build

  • Next.js on Vercel
  • Turborepo
  • v0

Scale

  • Content delivery network
  • Fluid compute
  • CI/CD
  • Observability
  • AI GatewayNew
  • Vercel AgentNew

Secure

  • Platform security
  • Web Application Firewall
  • Bot management
  • BotID
  • SandboxNew

Resources

  • Pricing
  • Customers
  • Enterprise
  • Articles
  • Startups
  • Solution partners

Learn

  • Docs
  • Blog
  • Changelog
  • Knowledge Base
  • Academy
  • Community

Frameworks

  • Next.js
  • Nuxt
  • Svelte
  • Nitro
  • Turbo

SDKs

  • AI SDK
  • Workflow SDKNew
  • Flags SDK
  • Chat SDK
  • Streamdown AINew

Use Cases

  • Composable commerce
  • Multi-tenant platforms
  • Web apps
  • Marketing sites
  • Platform engineers
  • Design engineers

Company

  • About
  • Careers
  • Help
  • Press
  • Legal
  • Privacy Policy

Community

  • Open source program
  • Events
  • Shipped on Vercel
  • GitHub
  • LinkedIn
  • X
  • YouTube

Loading status…

Select a display theme:
    • AI Cloud
      • v0

        Build applications with AI

      • AI SDK

        The AI Toolkit for TypeScript

      • AI Gateway

        One endpoint, all your models

      • Vercel Agent

        An agent that knows your stack

      • Sandbox

        AI workflows in live environments

    • Core Platform
      • CI/CD

        Helping teams ship 6× faster

      • Content Delivery

        Fast, scalable, and reliable

      • Fluid Compute

        Servers, in serverless form

      • Observability

        Trace every step

    • Security
      • Bot Management

        Scalable bot protection

      • BotID

        Invisible CAPTCHA

      • Platform Security

        DDoS Protection, Firewall

      • Web Application Firewall

        Granular, custom protection

    • Company
      • Customers

        Trusted by the best teams

      • Blog

        The latest posts and changes

      • Changelog

        See what shipped

      • Press

        Read the latest news

      • Events

        Join us at an event

    • Learn
      • Docs

        Vercel documentation

      • Academy

        Linear courses to level up

      • Knowledge Base

        Find help quickly

      • Community

        Join the conversation

    • Open Source
      • Next.js

        The native Next.js platform

      • Nuxt

        The progressive web framework

      • Svelte

        The web’s efficient UI framework

      • Turborepo

        Speed with Enterprise scale

    • Use Cases
      • AI Apps

        Deploy at the speed of AI

      • Composable Commerce

        Power storefronts that convert

      • Marketing Sites

        Launch campaigns fast

      • Multi-tenant Platforms

        Scale apps with one codebase

      • Web Apps

        Ship features, not infrastructure

    • Tools
      • Marketplace

        Extend and automate workflows

      • Templates

        Jumpstart app development

      • Partner Finder

        Get help from solution partners

    • Users
      • Platform Engineers

        Automate away repetition

      • Design Engineers

        Deploy for every idea

  • Enterprise
  • Pricing
Log InContact
Sign Up
Sign Up
Back to Templates
DeployView Demo

Chatbot UI

A ChatGPT clone for running locally in your browser.
Chatbot UI

Scribble Diffusion

Turn your rough sketch into a refined image using AI. Powered by Replicate and ControlNet.
Scribble Diffusion

Node.js Serverless Function

Use Node.js with Vercel Serverless Functions.
Node.js Serverless Function
v0

Build applications with AI

AI SDK

The AI Toolkit for TypeScript

AI Gateway

One endpoint, all your models

Vercel Agent

An agent that knows your stack

Sandbox

AI workflows in live environments

CI/CD

Helping teams ship 6× faster

Content Delivery

Fast, scalable, and reliable

Fluid Compute

Servers, in serverless form

Observability

Trace every step

Bot Management

Scalable bot protection

BotID

Invisible CAPTCHA

Platform Security

DDoS Protection, Firewall

Web Application Firewall

Granular, custom protection

Customers

Trusted by the best teams

Blog

The latest posts and changes

Changelog

See what shipped

Press

Read the latest news

Events

Join us at an event

Docs

Vercel documentation

Academy

Linear courses to level up

Knowledge Base

Find help quickly

Community

Join the conversation

Next.js

The native Next.js platform

Nuxt

The progressive web framework

Svelte

The web’s efficient UI framework

Turborepo

Speed with Enterprise scale

AI Apps

Deploy at the speed of AI

Composable Commerce

Power storefronts that convert

Marketing Sites

Launch campaigns fast

Multi-tenant Platforms

Scale apps with one codebase

Web Apps

Ship features, not infrastructure

Marketplace

Extend and automate workflows

Templates

Jumpstart app development

Partner Finder

Get help from solution partners

Platform Engineers

Automate away repetition

Design Engineers

Deploy for every idea