Skip to content

AzaWang/rasa-pizza-shop

Repository files navigation

Rasa Pizza Shop Chatbot

How to play? One-click helper:

make start-app

🍕 Rasa Pizza Shop Assistant - An intelligent chatbot for ordering pizzas and drinks!

This starter pack demonstrates building a pizza delivery chatbot using the Rasa framework with the following features:

Features

🛒 Pizza Ordering

  • Three sizes: Small (€12), Medium (€14), Large (€18)
  • Three pizza types: Margherita (€2 discount), Marinara, Hawaiian
  • Automatic price calculation with discount support
  • Custom pizzas with topping selection

🥤 Beverage Management

  • Cola, Sprite, Fanta Orange (€2.50)
  • Water (€1.50)
  • Juice (€3.00)
  • Beer (€4.00)
  • Wine (€5.00)

📋 Order Management

  • Order ID generation for pickup identification
  • Order summary display
  • Checkout process with total calculation
  • Order history tracking

ℹ️ Shop Information

  • Business hours inquiry by day
  • Menu display with prices and discounts
  • Help and support responses

Project Structure

config.yml                    # Rasa configuration
credentials.yml              # Service credentials
endpoints.yml               # Endpoint configuration
requirements.txt            # Python dependencies
Makefile                    # Build automation
actions/
  ├── __init__.py
  ├── database.py           # In-memory database with menu and orders
  └── actions.py            # Custom actions (add pizza, drink, etc.)
data/
  ├── nlu.yml              # NLU training data
  ├── stories.yml          # Conversation flows
  ├── pizzas/
  │   └── order_pizza.yml
  ├── drinks/
  │   └── order_drinks.yml
  └── general/
      └── general.yml
domain/
  └── domain.yml           # Intents, entities, slots, responses
tests/
  ├── happy_paths/         # Standard business flows
  └── demo_scripts/        # Full workflow demonstrations
chatwidget/
  ├── index.html          # Chat interface
  └── style.css           # Styling
prompts/
  └── templates.py        # Jinja2 prompt templates

Installation

Prerequisites

  1. Python 3.8+
  2. pip (Python package manager)

Local Installation

  1. Clone or navigate to the project

    cd /Users/wangyiju/Documents/LenguajeN/rasa-pizza-shop
  2. Install dependencies

    make install

    Or manually:

    pip install -r requirements.txt
  3. Train the model

    make train

Docker Installation

Build and run with Docker:

make docker-build
make docker-run

Running the Chatbot

Option 1: Rasa Shell (Interactive Testing)

make shell

Option 2: Rasa Server + Action Server

In one terminal:

make run

In another terminal:

make action-server

Option 3: Both at once

make run-all

Option 4: Web Chat Widget

After starting the servers, open chatwidget/index.html in your browser.

Testing

Run end-to-end tests:

# All tests
make test

# Happy path tests only
make test-happy-paths

# Demo workflow
make test-demo

Example Interactions

Scenario 1: Simple Order

User: Hi, I'd like to order a pizza
Bot: Welcome! I'll help you order.
User: I want a medium margherita pizza
Bot: Great! Added Medium Margherita pizza for €12.00 to your order.
User: I'm done
Bot: Order confirmed! Your order is #ABC123D. Pickup in 30 minutes!

Scenario 2: Order with Drink

User: Show me the menu
Bot: [Displays pizza and drink options]
User: I want a large hawaiian pizza and a beer
Bot: Added Large Hawaiian pizza for €18.00...
     Added Beer for €4.00...
User: Checkout
Bot: Order confirmed! Total: €22.00

Scenario 3: Custom Pizza

User: I want a custom pizza
Bot: What size and type would you like?
User: Large, with extra cheese, mushrooms, and olives
Bot: Added Large pizza with extra toppings...

Key Technologies

  • Framework: Rasa (CALM framework recommended for production)
  • Language: Python 3.8+
  • NLU: Rasa NLU with TED policy
  • Storage: In-memory database
  • Frontend: HTML5 + CSS3

Configuration

Environment Variables (Optional)

For Rasa Pro with GPT-4 (update config.yml):

export OPENAI_API_KEY=your-api-key

Customization

Adding New Pizza Types

Edit actions/database.py in the PIZZA_TYPES dictionary:

PIZZA_TYPES = {
    "my_pizza": {"name": "My Pizza Name", "discount": 1.0},
}

Adding New Drinks

Edit actions/database.py in the DRINKS dictionary:

DRINKS = {
    "my_drink": {"name": "My Drink", "price": 3.50},
}

Modifying Business Hours

Edit actions/database.py in the BUSINESS_HOURS dictionary:

BUSINESS_HOURS = {
    "monday": "10:00 - 22:00",
}

Common Commands

# Clean up generated files
make clean

# Clean everything including virtual environment
make clean-all

# View all available commands
make help

Deployment Options

  1. Local Development: Use make run-all
  2. Docker: Use make docker-run
  3. Rasa Cloud: Deploy via Rasa Cloud dashboard
  4. Custom Server: Configure endpoints.yml for your infrastructure

Troubleshooting

Actions not running?

Ensure the action server is running:

make action-server

Port already in use?

Change ports in your Rasa command:

rasa run -m models --port 5006
rasa run actions --port 5056

Chat widget not connecting?

Check if Rasa server is running on port 5005 and CORS is enabled.

Advanced Features (Rasa Pro)

For production use with CALM framework:

  1. Install Rasa Pro:

    make install-rasa-pro
  2. Update config.yml to use CALM policies

  3. Use GPT-4 for better NLU and dialogue management

Support & Documentation

License

This starter pack is based on Rasa's retail banking example and is free to use and modify locally.


Ready to serve pizzas with AI! 🚀🍕

About

No description, website, or topics provided.

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

 
 
 

Contributors