A FastAPI application that connects to the Notion API and provides RAG (Retrieval-Augmented Generation) capabilities using MongoDB Atlas Vector Search and Google AI Studio.
- ๐ Connect to Notion API
- ๐ Fetch data from Notion databases
- ๐ Simplified data extraction
- ๐ง Sync Notion content to MongoDB Atlas as vector embeddings
- ๐ Vector similarity search using sentence transformers
- ๐ค Question answering with Google AI Studio (Gemini)
- ๐ฌ Chat interface for natural language queries
Create a .env file in the project root with the following configuration:
# Notion API Configuration
NOTION_API_KEY=your_notion_integration_token_here
NOTION_DATABASE_IDS=your_comma_separated_database_ids_here
# MongoDB Atlas Configuration
MONGODB_URI=your_url_to_mongodb_atlas_cluster_here
MONGODB_DATABASE=your_database_name_here
MONGODB_COLLECTION=your_collection_name_here
# Google AI Studio Configuration
GOOGLE_API_KEY=your_google_ai_studio_api_key (optional, could use another LLM)
GOOGLE_MODEL=(gemini-2.5-flash or other model)
# Vector Database Configuration (Optional - defaults provided)
EMBEDDING_MODEL=all-MiniLM-L6-v2
MAX_CHUNK_TOKENS=500
CHUNK_OVERLAP_TOKENS=50
MAX_CONTEXT_CHUNKS=5
MIN_SIMILARITY_SCORE=0.7
# Other Configurations
CORS_ALLOW_ORIGINS=could be '*' or specific origins here
API_SECRET_KEY=generate_random_string_here
# WAHA configuration
WHITELISTED_NUMBERS=your_comma_separated_phone_numbers_here
WAHA_API_URL=your_url_to_waha_api_here
WAHA_API_KEY=your_waha_api_key_here
WAHA_SESSION_NAME=your_waha_session_name_here- Create a MongoDB Atlas cluster
- Create a database
- Create a collection
- Important: Create a vector search index:
- Index name:
vector_index - Field path:
embedding - Dimensions:
384(for all-MiniLM-L6-v2 model) - Similarity:
cosine
- Index name:
pip install -r requirements.txtuvicorn main:app --reloadThe API will be available at http://localhost:8000
Once the server is running, visit:
- Interactive API docs:
http://localhost:8000/docs - ReDoc documentation:
http://localhost:8000/redoc
- Go to Notion Integrations
- Click "New integration"
- Give it a name and select your workspace
- Copy the "Internal Integration Token" - this is your
NOTION_API_KEY - Share your databases with the integration:
- Open the database in Notion
- Click "Share" โ "Invite"
- Search for your integration name and invite it
WAHA enables WhatsApp integration, allowing your application to receive and respond to WhatsApp messages with AI-generated answers based on your Notion content.
-
Install and run WAHA using Docker:
docker pull devlikeapro/waha docker run -it --rm -p 3000:3000 --name waha devlikeapro/waha
-
Connect WhatsApp: Open
http://localhost:3000, create a session, and scan the QR code with your phone. -
Configure environment variables in your
.envfile:WAHA_API_URL=http://localhost:3000 WAHA_API_KEY=your_waha_api_key_here WAHA_SESSION_NAME=default WHITELISTED_NUMBERS=1234567890,9876543210
-
Set webhook URL in WAHA dashboard to:
http://your-app-domain.com/waha/webhook
- Incoming WhatsApp messages are sent to your application via webhook
- Only whitelisted numbers can interact with the bot
- Messages are processed through the RAG system and responses are sent back via WhatsApp
For detailed installation, configuration, and production deployment instructions, visit the WAHA official documentation.
Instead of running WAHA locally, you can host WAHA+ on SumoPod, which offers low cost hosting (starts from IDR20K/month) for small projects like this one. Follow these steps:
- Sign up for an account on SumoPod
- Deploy your WAHA instance by clicking the "Deploy Now" button below.
- Once deployed, follow the setup guide above to configure your WAHA instance.
# Install test dependencies
pip install pytest pytest-asyncio httpx
# Run tests (when test files are created)
pytest- Fork the repository
- Create a feature branch
- Make your changes
- Add tests if applicable
- Submit a pull request
This project is open source and available under the MIT License.
If you encounter any issues or have questions, please open an issue on GitHub.
If you like this repo or think it useful, please leave a โญ๏ธ on it.
Made with โค๏ธ by the open-source community