Skip to content

FOODOO is an intelligent food delivery chatbot built with Dialogflow, designed to assist users in browsing menus, placing orders, and tracking deliveries through natural conversations. It provides a smooth and interactive ordering experience with real-time responses.

License

Notifications You must be signed in to change notification settings

Devatva24/Foodoo-FoodChatBot

Folders and files

NameName
Last commit message
Last commit date

Latest commit

ย 

History

11 Commits
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 

Repository files navigation

๐Ÿ” Foodoo - AI-Powered Food Delivery Chatbot

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.

Python FastAPI Dialogflow License

โœจ Features

  • ๐Ÿค– 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

๐ŸŽฏ Demo

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"

๐Ÿ—๏ธ Architecture

โ”Œโ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”      โ”Œโ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”      โ”Œโ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”
โ”‚   User      โ”‚โ”€โ”€โ”€โ”€โ”€โ–ถโ”‚  Dialogflow  โ”‚โ”€โ”€โ”€โ”€โ”€โ–ถโ”‚   FastAPI   โ”‚
โ”‚  (Frontend) โ”‚      โ”‚  (NLP Agent) โ”‚      โ”‚  (Backend)  โ”‚
โ””โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”˜      โ””โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”˜      โ””โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”˜
                            โ”‚                      โ”‚
                            โ”‚                      โ–ผ
                            โ”‚               โ”Œโ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”
                            โ””โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ–ถโ”‚   MySQL DB  โ”‚
                                            โ”‚  (Storage)  โ”‚
                                            โ””โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”˜

Conversation Flow

User โ†’ "I want 2 pizzas" 
    โ†“
Dialogflow extracts: {item: "pizza", quantity: 2}
    โ†“
Webhook โ†’ FastAPI โ†’ Database
    โ†“
Response โ† "Added 2 pizzas to your order!"

๐Ÿ“‹ Prerequisites

  • Python 3.8 or higher
  • MySQL Server (or SQLite for testing)
  • Google Cloud account (for Dialogflow)
  • Ngrok account (for local development)

๐Ÿš€ Installation

1. Clone the Repository

git clone https://github.com/Devatva24/Foodoo-FoodChatBot.git
cd Foodoo-FoodChatBot

2. Create Virtual Environment

# Create virtual environment
python -m venv venv

# Activate virtual environment
# On Windows:
venv\Scripts\activate
# On macOS/Linux:
source venv/bin/activate

3. Install Dependencies

pip install -r requirements.txt

Dependencies include:

  • FastAPI - Web framework
  • uvicorn - ASGI server
  • mysql-connector-python - Database connector
  • pydantic - Data validation
  • python-dotenv - Environment variables

4. Setup Database

Using MySQL:

# Login to MySQL
mysql -u root -p

# Create database
CREATE DATABASE pandeyji_eatery;

# Import schema
mysql -u root -p pandeyji_eatery < db/pandeyji_eatery.sql

Using SQLite (for testing):

sqlite3 foodoo.db < db/pandeyji_eatery.sql

5. Configure Environment Variables

Create 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-id

6. Run the Backend Server

uvicorn main:app --reload --port 9000

The API will be available at http://localhost:9000

7. Setup Ngrok (for Dialogflow Webhook)

# Start ngrok
ngrok http 9000

Copy the HTTPS URL (e.g., https://abc123.ngrok.io)

๐Ÿค– Dialogflow Configuration

1. Create Dialogflow Agent

  1. Go to Dialogflow Console
  2. Create a new agent named "Foodoo"
  3. Set the default language and timezone

2. Import Intents

Import the training phrases from dialogflow_assets/:

Key Intents:

  • new.order - Start a new order
  • order.add - Add items to order
  • order.remove - Remove items from order
  • order.complete - Finalize the order
  • track.order - Check order status

3. Configure Webhook

  1. Go to Fulfillment section
  2. Enable Webhook
  3. Enter your ngrok URL: https://your-ngrok-id.ngrok.io/webhook
  4. Save

4. Enable Webhook for Intents

For each intent:

  1. Scroll to Fulfillment section
  2. Enable "Enable webhook call for this intent"
  3. Save

5. Training Phrases Examples

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

๐ŸŒ Frontend Setup

1. Update Chatbot Integration

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>

2. Serve the Frontend

# Using Python's built-in server
cd frontend
python -m http.server 8080

Visit http://localhost:8080/home.html

๐Ÿ“ Project Structure

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

๐Ÿ”ง API Endpoints

Webhook Endpoint

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!"
}

๐Ÿ’ก Usage Examples

Starting an 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

Tracking an Order

User: Track my order 1234
Bot: Your order #1234 is being prepared. Estimated delivery: 30 minutes

Modifying an Order

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

๐Ÿ—„๏ธ Database Schema

Tables

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)
);

๐Ÿ”’ Security Best Practices

  1. Environment Variables: Never commit .env files
  2. API Keys: Use environment variables for sensitive data
  3. Database: Use parameterized queries (already implemented)
  4. HTTPS: Always use HTTPS for webhooks in production
  5. Input Validation: Validate all user inputs (implemented with Pydantic)

๐Ÿš€ Deployment

Deploy to Heroku

# 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

Deploy to AWS

  1. Set up EC2 instance
  2. Install dependencies
  3. Configure MySQL RDS
  4. Use Nginx as reverse proxy
  5. Set up SSL with Let's Encrypt
  6. Update Dialogflow webhook

Deploy to Google Cloud

# Deploy to Cloud Run
gcloud run deploy foodoo \
  --source . \
  --region us-central1 \
  --allow-unauthenticated

๐Ÿงช Testing

Test the API

# Health check
curl http://localhost:9000/

# Test webhook
curl -X POST http://localhost:9000/webhook \
  -H "Content-Type: application/json" \
  -d @test_payload.json

Test Dialogflow

  1. Use Try it now panel in Dialogflow Console
  2. Test various intents and scenarios
  3. Check webhook calls in FastAPI logs

๐Ÿ› Troubleshooting

Issue: Webhook not responding

Solution:

  • Check if FastAPI server is running
  • Verify ngrok is active and URL is updated in Dialogflow
  • Check FastAPI logs for errors

Issue: Database connection error

Solution:

  • Verify MySQL is running
  • Check credentials in .env file
  • Test connection: mysql -u root -p

Issue: Dialogflow not recognizing intent

Solution:

  • Add more training phrases
  • Retrain the agent
  • Check entity extraction in parameters

Issue: Session context lost

Solution:

  • Enable Dialogflow session management
  • Check session parameters in webhook payload

๐ŸŽจ Customization

Adding New Menu Items

# 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()

Custom Intents

  1. Create new intent in Dialogflow
  2. Add webhook fulfillment
  3. 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)

Styling Frontend

Edit frontend/styles.css:

/* Custom theme colors */
:root {
    --primary-color: #ff6b6b;
    --secondary-color: #4ecdc4;
    --background-color: #f7f7f7;
}

๐Ÿ“Š Analytics & Monitoring

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 request

๐Ÿค Contributing

Contributions are welcome! Here's how:

  1. Fork the repository
  2. Create feature branch (git checkout -b feature/AmazingFeature)
  3. Commit changes (git commit -m 'Add AmazingFeature')
  4. Push to branch (git push origin feature/AmazingFeature)
  5. Open a Pull Request

Areas for Contribution

  • Payment gateway integration
  • Multi-restaurant support
  • Voice ordering capability
  • Order history dashboard
  • Rating and review system
  • Delivery tracking map
  • Mobile app integration

๐Ÿ“ License

This project is licensed under the MIT License - see the LICENSE file for details.

๐Ÿ™ Acknowledgments

๐Ÿ‘ค Author

Devatva Rachit

โญ Show Your Support

Give a โญ๏ธ if this project helped you!

๐Ÿ”ฎ Future Enhancements

  • 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

About

FOODOO is an intelligent food delivery chatbot built with Dialogflow, designed to assist users in browsing menus, placing orders, and tracking deliveries through natural conversations. It provides a smooth and interactive ordering experience with real-time responses.

Topics

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published