Chat bot
Build a production-ready AI support bot that intelligently answers questions in whop communities.
This tutorial was submitted by @script, a member of the Whop Developers community. Submit your own tutorial and get paid real $!
Summary
This tutorial will guide you through building a chat bot that can answer questions in whop communities. View the final product here by installing the app to your whop.
1. Set up your Next.js project
Clone the AI Support Bot repository:
Install dependencies:
2. Get your Whop API credentials
Create a Whop App
- Go to https://whop.com/dashboard/developer
- Navigate to Developer
- Click the Create App button
- Give your app a name like “AI Support Bot”
- Click Create
Get your API Key, Agent User ID, and App ID
After creating your app:
- Copy the App API Key - you’ll need this for
WHOP_API_KEY
- Copy the Agent User ID - you’ll need this for
WHOP_AGENT_USER_ID
- Copy the App ID - you’ll need this for
WHOP_APP_ID
The Agent User ID is what allows your bot to send messages on behalf of your app.
3. Set up Supabase Database
Create a Supabase Project
- Go to https://supabase.com
- Click Start your project
- Sign in or create an account
- Click New project
- Choose your organization
- Enter a Database Name (e.g., “ai-support-bot”)
- Enter a Database Password (save this!)
- Select a Region close to your users
- Click Create new project
Get Database Connection Strings
Once your project is created:
- Go to Settings → Database
- Scroll down to Connection string
- Copy the URI format for
DATABASE_URL
- Copy the Direct connection for
DIRECT_URL
Replace [YOUR-PASSWORD]
in both URLs with the database password you created.
4. Get OpenRouter AI API Key
Create OpenRouter Account
- Go to https://openrouter.ai
- Click Sign In or Sign Up
- Complete the registration process
Get API Key
- Go to Keys in the dashboard
- Click Create Key
- Give it a name like “AI Support Bot”
- Copy the API key - you’ll need this for
OPENROUTER_API_KEY
OpenRouter gives you $1 free credit when you sign up, which is more than enough for testing with Gemini 2.0 Flash!
5. Configure Environment Variables
Copy Environment Template
Fill in Required Variables
Open .env
in your text editor and fill in these required fields:
6. Set up the Database
Push the database schema to Supabase:
This will create the necessary tables:
companies
- Store bot settings for each Whop companyexperience_mappings
- Map Whop experiences to companies
7. Install Whop Dev Proxy
For Whop integration to work in development, you need to install the Whop dev proxy globally:
The Whop dev proxy is required for the iframe integration to work properly during development.
8. Run the Application
Start the Web Server with Whop Proxy
Run this command to start both the Whop proxy and Next.js development server:
You should see output indicating both the proxy and Next.js are running. The web app will be available at http://localhost:3000
Do NOT use npm run dev
alone - it won’t include the Whop proxy and the iframe integration won’t work!
Start the AI Bot (New Terminal)
In a new terminal window:
You should see:
9. Configure App Settings in Whop
Important: You must configure these settings BEFORE installing the app to your community.
Set Base URL and App Path
- Go to your Whop app dashboard → Developer → Your App
- In the Hosting section, configure:
- Base URL:
http://localhost:3000/
- App path:
/company/[companyId]
- Base URL:
- Click Save to update the settings
If you skip this step, the app installation and iframe integration won’t work properly!
10. Install to Your Whop Community
- Go to your Whop company dashboard
- Navigate to Settings → API keys
- Click on your AI Support Bot app
- Find and copy the Installation Link
- Visit the installation link and grant the necessary permissions
11. Configure Your Bot
Access Bot Settings via Whop iframe
- After installing the app, click Open Whop in the top right
- When redirected to Whop, click the Settings button
- Change the dropdown from Production to Localhost
- Choose your port (usually 3000)
- You’ll now see the bot configuration dashboard
Only company admins can access the bot settings page.
Set Up Your Bot
Configure these settings:
- Enable Bot: Turn on the AI responses
- Knowledge Base: Add information about your community
- Response Style: Choose professional, friendly, casual, or technical
- Preset Q&A: Add common questions with instant answers
- Custom Instructions: Fine-tune the AI’s behavior
12. Test Your Bot
- Go to your Whop community chat
- Ask a question like “How do I join?”
- The bot should respond within a few seconds
Troubleshooting
What’s Next?
Your AI Support Bot is now ready! Here are some next steps:
- Customize responses: Add more preset Q&A pairs for instant answers
- Train the AI: Update the knowledge base with community-specific information
- Monitor usage: Check the bot console for statistics and performance
- Scale up: Deploy to production using Vercel, Railway, or your preferred platform
The bot saves 80-90% on AI costs through smart question detection and caching. Perfect for high-volume communities!
Need Help?
- Join the Developer Whop
- View the source code of this app here
- DM @script on Whop