A complete messaging application built with Next.js and Weavy that combines real-time messaging with AI agent management capabilities. This project demonstrates how to integrate Weavy's powerful collaboration features with custom AI agent functionality.
- Real-time Messaging: Full-featured chat interface powered by Weavy Messenger
- Google OAuth Authentication: Secure sign-in with Google accounts
- AI Agent Builder: Create, edit, and manage AI agents with custom instructions
- Knowledge Base Management: File upload and management for agent knowledge bases
- Responsive Design: Mobile-friendly Bootstrap UI
- Create Agents: Build custom AI agents with names, descriptions, and instructions
- Edit Agents: Update agent details and instructions
- Delete Agents: Remove agents with confirmation
- Knowledge Bases: Automatic file app creation for each agent
- Agent Listing: Browse all created agents with detailed information
- Google OAuth Integration: Seamless sign-in with Google accounts
- Access Token Management: Secure token generation for Weavy integration
- User Profile Sync: Automatic user creation in Weavy with Google profile data
- Session Management: Persistent authentication state
- Framework: Next.js 14 with App Router
- Authentication: NextAuth.js with Google Provider
- UI Framework: Bootstrap 5.3
- Real-time Chat: Weavy UIKit
- Language: TypeScript
- Deployment: Vercel
Before you begin, ensure you have:
- Node.js (version 18 or higher)
- A Weavy account and environment
- Google OAuth credentials
- Vercel account (for deployment)
```bash git clone https://github.com/your-username/weavy-messenger-mvp.git cd weavy-messenger-mvp ```
```bash npm install ```
Create a `.env.local` file in the root directory:
```env
WEAVY_URL=https://your-weavy-environment.weavy.io WEAVY_API_KEY=your-weavy-api-key NEXT_PUBLIC_WEAVY_URL=https://your-weavy-environment.weavy.io
NEXTAUTH_SECRET=your-nextauth-secret NEXTAUTH_URL=http://localhost:3000
GOOGLE_CLIENT_ID=your-google-client-id GOOGLE_CLIENT_SECRET=your-google-client-secret ```
- Go to the Google Cloud Console
- Create a new project or select an existing one
- Enable the Google+ API
- Create OAuth 2.0 credentials
- Add authorized redirect URIs:
- `http://localhost:3000/api/auth/callback/google\` (development)
- `https://your-domain.com/api/auth/callback/google\` (production)
- Sign up for a Weavy account
- Create a new environment
- Generate an API key
- Note your environment URL
```bash npm run dev ```
Open http://localhost:3000 in your browser.
``` weavy-messenger-mvp/ βββ app/ β βββ api/ β β βββ auth/[...nextauth]/ # NextAuth configuration β β βββ weavy/ β β β βββ agents/ # Agent management endpoints β β β βββ token/ # Token generation β β β βββ users/ # User management β βββ auth/ # Authentication pages β βββ agent-builder/ # Agent builder page β βββ components/ # React components β β βββ agent-detail.tsx # Agent detail modal β β βββ create-agent-modal.tsx # Create agent form β β βββ edit-agent-modal.tsx # Edit agent form β βββ globals.css # Global styles β βββ layout.tsx # Root layout β βββ page.tsx # Home page (messenger) β βββ providers.tsx # Context providers βββ middleware.ts # NextAuth middleware βββ README.md ```
| Variable | Description | Required |
|---|---|---|
| `WEAVY_URL` | Your Weavy environment URL | β |
| `WEAVY_API_KEY` | Your Weavy API key (server-side only) | β |
| `NEXT_PUBLIC_WEAVY_URL` | Public Weavy URL for client-side | β |
| `NEXTAUTH_SECRET` | Secret for NextAuth.js | β |
| `NEXTAUTH_URL` | Your application URL | β |
| `GOOGLE_CLIENT_ID` | Google OAuth client ID | β |
| `GOOGLE_CLIENT_SECRET` | Google OAuth client secret | β |
- Create Environment: Set up your Weavy environment
- Generate API Key: Create an API key with appropriate permissions
- Configure CORS: Add your domain to allowed origins
-
Connect Repository: ```bash vercel --prod ```
-
Set Environment Variables in Vercel dashboard
-
Update OAuth Settings:
- Add production URL to Google OAuth redirect URIs
- Update `NEXTAUTH_URL` to your production domain
The application can be deployed to any platform that supports Next.js:
- Netlify: Use the Next.js build command
- Railway: Connect your GitHub repository
- DigitalOcean App Platform: Deploy from GitHub
- Sign In: Use Google OAuth to authenticate
- Start Chatting: The messenger loads automatically
- Real-time Communication: Messages appear instantly
- Navigate to Agent Builder: Click the "Agent Builder" tab
- Create Agent: Click "Create New Agent" and fill in details
- Manage Knowledge Base: Upload files to agent knowledge bases
- Edit Agents: Click the edit button on any agent card
- Delete Agents: Click the trash button with confirmation
- Automatic Creation: Each agent gets a dedicated file app
- Upload Files: Use the Weavy Files interface
- File Management: Organize and manage agent knowledge
- `POST /api/auth/[...nextauth]` - NextAuth.js endpoints
- `POST /api/weavy/token` - Generate Weavy access tokens
- `GET /api/weavy/users` - Get user information
- `POST /api/weavy/users` - Create/update users
- `GET /api/weavy/agents` - List all agents
- `GET /api/weavy/agents/[uid]` - Get specific agent
- `POST /api/weavy/agents/create` - Create new agent
- `PATCH /api/weavy/agents/[uid]/update` - Update agent
- `DELETE /api/weavy/agents/[uid]/delete` - Delete agent
The project uses Bootstrap 5.3 for styling. Customize by:
- Modify `globals.css` for global styles
- Update Bootstrap variables by importing custom SCSS
- Add custom components with Tailwind-style classes
Customize Weavy components by:
- CSS Variables: Override Weavy's CSS custom properties
- Custom Themes: Apply your brand colors and fonts
- Component Configuration: Modify Weavy component attributes
Authentication Errors:
- Verify Google OAuth configuration
- Check redirect URIs match exactly
- Ensure `NEXTAUTH_SECRET` is set
Weavy Connection Issues:
- Verify API key permissions
- Check CORS settings in Weavy
- Ensure environment URL is correct
Agent Creation Fails:
- Check Weavy API key has agent creation permissions
- Verify all required fields are provided
- Check server logs for detailed errors
Enable debug logging by setting: ```env NODE_ENV=development ```
Check browser console and server logs for detailed error information.
- Fork the repository
- Create a feature branch: `git checkout -b feature/amazing-feature`
- Commit changes: `git commit -m 'Add amazing feature'`
- Push to branch: `git push origin feature/amazing-feature`
- Open a Pull Request
This project is licensed under the MIT License - see the LICENSE file for details.
- Weavy - For the excellent collaboration platform
- NextAuth.js - For authentication made simple
- Vercel - For seamless deployment
- Bootstrap - For responsive UI components
- Documentation: Weavy Docs
- Community: Weavy Community
- Issues: GitHub Issues
- Live Demo: https://your-app.vercel.app
- Weavy Platform: https://www.weavy.com
- v0.dev: https://v0.dev