This repository contains example chatbot applications that integrate with the Fanvue API using OAuth 2.0 authentication. Choose between Python or JavaScript/Node.js implementations based on your preference and experience.
- Python Example (
python/) - Flask-based chatbot application - JavaScript Example (
javascript/) - Node.js/Express-based chatbot application
Both examples provide:
- OAuth 2.0 authentication with Fanvue
- Simple web-based chat interface
- Integration with Fanvue's chat API
- Comprehensive setup instructions for non-developers
- New to programming? Start with the JavaScript example - it's straightforward and has great tooling support
- Prefer Python? Use the Python example - Python is known for being beginner-friendly
- Already know one language? Use the example in the language you're most comfortable with
Before starting, you'll need:
-
Programming Language Runtime
-
Package Manager (for JavaScript)
- pnpm (Installation Guide)
-
Fanvue API Access
- Go to the Fanvue Developer Area
- Create an OAuth application
New to this? Start with the Setup Checklist to track your progress step-by-step.
cd python
# Follow the instructions in python/README.mdcd javascript
# Follow the instructions in javascript/README.mdBoth examples create a simple web-based chatbot that:
- Authenticates users via Fanvue OAuth
- Displays a chat interface in your web browser
- Sends messages through the Fanvue API
- Handles conversations automatically
Regardless of which example you choose, you'll need to:
-
Choose an App Name - Pick a name for your local domain (e.g.,
my-chatbot) -
Set Up HTTPS for Local Development - OAuth requires HTTPS, even locally
- Install
mkcertto generate SSL certificates - Generate certificates for your app name
- Update your hosts file
- Install
-
Create an OAuth Application in Fanvue Developer Area
- Get your Client ID and Client Secret
- Set the Redirect URI using HTTPS (e.g.,
https://your-app-name.dev:5001/callbackfor Python orhttps://your-app-name.dev:3001/callbackfor JavaScript) - Select required scopes:
read:self,read:chat,write:chat
-
Configure Environment Variables
- Copy
.env.exampleto.env - Fill in your OAuth credentials
- Set a secure session secret
- Update Redirect URI to use HTTPS
- Copy
-
Install Dependencies
- Python:
pip install -r requirements.txt - JavaScript:
pnpm install
- Python:
-
Run the Application (requires two terminal windows)
- Terminal 1: Start the app (Python:
python app.pyor JavaScript:pnpm start) - Terminal 2: Start the HTTPS proxy with
npx local-ssl-proxy
- Terminal 1: Start the app (Python:
-
Access in Browser
- Open
https://your-app-name.dev:5001(Python) orhttps://your-app-name.dev:3001(JavaScript) - Accept the security warning (normal for local development)
- Click "Login with Fanvue"
- Start chatting!
- Open
- ✅ OAuth 2.0 authentication
- ✅ Secure session management
- ✅ Chat interface with message history
- ✅ Automatic conversation handling
- ✅ Error handling and user feedback
- ✅ Clean, modern UI
- Never commit
.envfiles - They contain sensitive credentials - Use strong session secrets - Generate random strings for production
- Keep credentials secure - Treat Client Secret like a password
- Use HTTPS in production - Required for OAuth redirects
- Verify your Client ID and Client Secret are correct
- Ensure Redirect URI matches exactly in both
.envand Fanvue Developer area - Check that required scopes are selected
- Make sure the application is running (check terminal output)
- Verify the port isn't already in use
- Check firewall settings
- Verify you have API access enabled
- Check that scopes include
read:chatandwrite:chat - Review error messages in the terminal
For more specific troubleshooting, see the README in your chosen example directory.
Once you have the basic chatbot working:
- Customize Responses - Modify the chatbot logic to add custom responses
- Add AI Integration - Connect to OpenAI, Anthropic, or other AI services
- Enhance UI - Improve the chat interface with better styling
- Add Features - Message history, file uploads, emoji support, etc.
- Deploy - Host your chatbot on Vercel, Railway, Heroku, or another platform
If you encounter issues:
- Check the troubleshooting section in your chosen example's README
- Review the Fanvue API documentation
- Verify all environment variables are set correctly
- Check terminal output for error messages
MIT License - Feel free to use and modify these examples for your own projects.
Found a bug or have a suggestion? Feel free to open an issue or submit a pull request!