An intelligent conversational food ordering system built with Google Dialogflow, FastAPI, and MySQL. Foodoo enables customers to browse menus, place orders, and track deliveries through natural language conversations, providing a seamless ordering experience.
- ๐ค Natural Language Processing: Powered by Google Dialogflow for understanding user intent
- ๐ Menu Browsing: Interactive menu exploration through conversation
- ๐ Order Management: Add items, modify quantities, and complete orders
- ๐ฆ Order Tracking: Real-time order status updates
- ๐พ Database Integration: MySQL backend for persistent storage
- ๐ Web Interface: Beautiful frontend with embedded chatbot
- โก FastAPI Backend: High-performance RESTful API
- ๐ Session Management: Context-aware conversations
- ๐ฑ Responsive Design: Works seamlessly across devices
Try Foodoo in action:
- Browse the menu: "Show me the menu"
- Place an order: "I want 2 pizzas and 1 burger"
- Track order: "What's my order status?"
- Modify order: "Add 1 more pizza"
โโโโโโโโโโโโโโโ โโโโโโโโโโโโโโโโ โโโโโโโโโโโโโโโ
โ User โโโโโโโถโ Dialogflow โโโโโโโถโ FastAPI โ
โ (Frontend) โ โ (NLP Agent) โ โ (Backend) โ
โโโโโโโโโโโโโโโ โโโโโโโโโโโโโโโโ โโโโโโโโโโโโโโโ
โ โ
โ โผ
โ โโโโโโโโโโโโโโโ
โโโโโโโโโโโโโโโโถโ MySQL DB โ
โ (Storage) โ
โโโโโโโโโโโโโโโ
User โ "I want 2 pizzas"
โ
Dialogflow extracts: {item: "pizza", quantity: 2}
โ
Webhook โ FastAPI โ Database
โ
Response โ "Added 2 pizzas to your order!"
- Python 3.8 or higher
- MySQL Server (or SQLite for testing)
- Google Cloud account (for Dialogflow)
- Ngrok account (for local development)
git clone https://github.com/Devatva24/Foodoo-FoodChatBot.git
cd Foodoo-FoodChatBot# Create virtual environment
python -m venv venv
# Activate virtual environment
# On Windows:
venv\Scripts\activate
# On macOS/Linux:
source venv/bin/activatepip install -r requirements.txtDependencies include:
- FastAPI - Web framework
- uvicorn - ASGI server
- mysql-connector-python - Database connector
- pydantic - Data validation
- python-dotenv - Environment variables
# Login to MySQL
mysql -u root -p
# Create database
CREATE DATABASE pandeyji_eatery;
# Import schema
mysql -u root -p pandeyji_eatery < db/pandeyji_eatery.sqlsqlite3 foodoo.db < db/pandeyji_eatery.sqlCreate a .env file in the root directory:
# Database Configuration
DB_HOST=localhost
DB_USER=root
DB_PASSWORD=your_password
DB_NAME=pandeyji_eatery
# Server Configuration
PORT=9000
HOST=0.0.0.0
# Dialogflow Configuration
PROJECT_ID=your-dialogflow-project-iduvicorn main:app --reload --port 9000The API will be available at http://localhost:9000
# Start ngrok
ngrok http 9000Copy the HTTPS URL (e.g., https://abc123.ngrok.io)
- Go to Dialogflow Console
- Create a new agent named "Foodoo"
- Set the default language and timezone
Import the training phrases from dialogflow_assets/:
Key Intents:
new.order- Start a new orderorder.add- Add items to orderorder.remove- Remove items from orderorder.complete- Finalize the ordertrack.order- Check order status
- Go to Fulfillment section
- Enable Webhook
- Enter your ngrok URL:
https://your-ngrok-id.ngrok.io/webhook - Save
For each intent:
- Scroll to Fulfillment section
- Enable "Enable webhook call for this intent"
- Save
order.add intent:
- I want 2 pizzas
- Add 1 burger to my order
- Can I get 3 pasta dishes
- 2 margherita pizzas please
- Add one large coke
track.order intent:
- What's my order status?
- Track my order
- Where is my order?
- Order status please
Edit frontend/home.html and update the Dialogflow integration code:
<script src="https://www.gstatic.com/dialogflow-console/fast/messenger/bootstrap.js?v=1"></script>
<df-messenger
chat-title="Foodoo"
agent-id="YOUR-AGENT-ID"
language-code="en">
</df-messenger># Using Python's built-in server
cd frontend
python -m http.server 8080Visit http://localhost:8080/home.html
Foodoo-FoodChatBot/
โโโ frontend/
โ โโโ home.html # Main website with chatbot
โ โโโ styles.css # Styling
โ โโโ banner.jpg # Header image
โ โโโ menu1.jpg # Menu images
โ โโโ menu2.jpg
โ โโโ menu3.jpg
โโโ db/
โ โโโ pandeyji_eatery.sql # Database schema & data
โโโ dialogflow_assets/
โ โโโ training_phrases.txt # Sample intents
โโโ main.py # FastAPI application
โโโ db_helper.py # Database operations
โโโ generic_helper.py # Utility functions
โโโ requirements.txt # Python dependencies
โโโ ngrok.exe # Tunneling tool (Windows)
โโโ README.md # Documentation
POST /webhook
Content-Type: application/json
{
"queryResult": {
"intent": {
"displayName": "order.add"
},
"parameters": {
"food-item": ["pizza"],
"number": [2]
}
},
"session": "projects/.../sessions/..."
}Response:
{
"fulfillmentText": "Added 2 pizzas to your order!"
}User: Hi, I want to place an order
Bot: Great! What would you like to order?
User: 2 pizzas and 1 burger
Bot: Added 2 pizzas and 1 burger to your order. Anything else?
User: That's all
Bot: Your order total is $25.99. Confirm order?
User: Yes
Bot: Order confirmed! Your order ID is #1234
User: Track my order 1234
Bot: Your order #1234 is being prepared. Estimated delivery: 30 minutes
User: Add 1 more pizza
Bot: Added 1 pizza. Your order now has 3 pizzas and 1 burger
User: Remove the burger
Bot: Removed burger from your order
food_items
CREATE TABLE food_items (
item_id INT PRIMARY KEY AUTO_INCREMENT,
name VARCHAR(255),
price DECIMAL(10,2)
);orders
CREATE TABLE orders (
order_id INT PRIMARY KEY AUTO_INCREMENT,
total_price DECIMAL(10,2),
status VARCHAR(50),
created_at TIMESTAMP DEFAULT CURRENT_TIMESTAMP
);order_items
CREATE TABLE order_items (
item_id INT PRIMARY KEY AUTO_INCREMENT,
order_id INT,
food_item_id INT,
quantity INT,
FOREIGN KEY (order_id) REFERENCES orders(order_id),
FOREIGN KEY (food_item_id) REFERENCES food_items(item_id)
);order_tracking
CREATE TABLE order_tracking (
order_id INT PRIMARY KEY,
status VARCHAR(50),
FOREIGN KEY (order_id) REFERENCES orders(order_id)
);- Environment Variables: Never commit
.envfiles - API Keys: Use environment variables for sensitive data
- Database: Use parameterized queries (already implemented)
- HTTPS: Always use HTTPS for webhooks in production
- Input Validation: Validate all user inputs (implemented with Pydantic)
# Install Heroku CLI
heroku login
# Create app
heroku create foodoo-chatbot
# Add database
heroku addons:create cleardb:ignite
# Deploy
git push heroku master
# Update Dialogflow webhook URL
# https://foodoo-chatbot.herokuapp.com/webhook- Set up EC2 instance
- Install dependencies
- Configure MySQL RDS
- Use Nginx as reverse proxy
- Set up SSL with Let's Encrypt
- Update Dialogflow webhook
# Deploy to Cloud Run
gcloud run deploy foodoo \
--source . \
--region us-central1 \
--allow-unauthenticated# Health check
curl http://localhost:9000/
# Test webhook
curl -X POST http://localhost:9000/webhook \
-H "Content-Type: application/json" \
-d @test_payload.json- Use Try it now panel in Dialogflow Console
- Test various intents and scenarios
- Check webhook calls in FastAPI logs
Solution:
- Check if FastAPI server is running
- Verify ngrok is active and URL is updated in Dialogflow
- Check FastAPI logs for errors
Solution:
- Verify MySQL is running
- Check credentials in
.envfile - Test connection:
mysql -u root -p
Solution:
- Add more training phrases
- Retrain the agent
- Check entity extraction in parameters
Solution:
- Enable Dialogflow session management
- Check session parameters in webhook payload
# In db_helper.py
def add_menu_item(name, price):
cursor.execute(
"INSERT INTO food_items (name, price) VALUES (%s, %s)",
(name, price)
)
db.commit()- Create new intent in Dialogflow
- Add webhook fulfillment
- Implement handler in
main.py:
@app.post("/webhook")
async def handle_webhook(request: Request):
intent = request["queryResult"]["intent"]["displayName"]
if intent == "custom.intent":
return custom_intent_handler(request)Edit frontend/styles.css:
/* Custom theme colors */
:root {
--primary-color: #ff6b6b;
--secondary-color: #4ecdc4;
--background-color: #f7f7f7;
}Add logging for tracking:
import logging
logging.basicConfig(level=logging.INFO)
logger = logging.getLogger(__name__)
@app.post("/webhook")
async def handle_webhook(request: Request):
logger.info(f"Received intent: {intent_name}")
# Process requestContributions are welcome! Here's how:
- Fork the repository
- Create feature branch (
git checkout -b feature/AmazingFeature) - Commit changes (
git commit -m 'Add AmazingFeature') - Push to branch (
git push origin feature/AmazingFeature) - Open a Pull Request
- Payment gateway integration
- Multi-restaurant support
- Voice ordering capability
- Order history dashboard
- Rating and review system
- Delivery tracking map
- Mobile app integration
This project is licensed under the MIT License - see the LICENSE file for details.
- Google Dialogflow - NLP platform
- FastAPI - Web framework
- Ngrok - Secure tunneling
- MySQL - Database system
Devatva Rachit
- GitHub: @Devatva24
- Project: Foodoo
Give a โญ๏ธ if this project helped you!
- Multi-language support
- Voice interface integration
- Payment processing (Stripe/PayPal)
- Restaurant dashboard
- Customer loyalty program
- AI-powered recommendations
- Real-time delivery tracking
- Push notifications
- Social media integration
Built with ๐ and ๐ by Devatva Rachit