A purpose-built, containerized Rasa chatbot designed to assist customers with salon bookings, cancellations, and rescheduling, as well as to answer frequently asked questions.
This project is built to run in a custom, multi-container Docker environment, specifically compiled to be fully compatible with Apple Silicon (arm64) hardware.
- Appointment Booking: A multi-step form that collects user details (
service,date,time,name,contact). - Appointment Cancellation: A custom action (
action_cancel_appointment) that locates a user's booking and removes it. - Advanced Validation: Custom Python logic in
actions.pyvalidates user input against business rules, such as:- Checking for valid business hours.
- Preventing double-bookings.
- Handling date-only inputs (e.g., "next Saturday") vs. full timestamps.
- FAQ Handling: Responds to simple queries like opening hours (
ask_hours). - Persistent Storage: Saves and manages appointments in a
appointments.jsonfile, made persistent via a Docker Named Volume.
- Backend: Rasa, Python 3.10
- NLU: Duckling (for
time,date, andphone-numberentity extraction) - Containerization: Docker & Docker Compose
- Frontend Widget: React, Axios
- Testing Dashboard: Flask (Provides a calendar view of
appointments.json)
This project is a full-stack application composed of two main parts within this repository:
salon-bot/: The complete Rasa backend. It is managed bydocker-compose.yml, which orchestrates four services:rasa: The main Rasa server for NLU and dialogue.action-server: Runs all custom Python logic fromactions/actions.py.duckling: The entity extraction service.dashboard: A simple Flask server that provides a test calendar UI.
salon-widget-ui/: A standalone React application that provides a modern chat interface to interact with the Rasa backend.
A primary challenge of this project was deploying on an Apple Silicon Mac. Official Docker images for Rasa and Duckling are built for the amd64 (Intel/AMD) architecture, which is incompatible with Apple's arm64 chips. This caused low-level AVX instructions errors, making the standard setup unusable.
The solution involved abandoning pre-built images and engineering a custom, multi-container environment from the ground up.
- Custom Rasa Image: The main
Dockerfileuses apython:3.10-slim(arm64) base image and installs Rasa from source. This ensures all Python dependencies, including TensorFlow, are compiled natively for arm64. - Custom Duckling Image: The
duckling/Dockerfilebuilds Duckling from its Haskell source. This required patching the build process to solve two issues:- OS Dependency: The build used an old Debian "Buster" image, which required redirecting
apt-getto the archive repositories. - Compiler Dependency: The build was pinned to a specific GHC (Haskell compiler) version, which was sourced from an older base image.
- OS Dependency: The build used an old Debian "Buster" image, which required redirecting
- Docker Networking Fix: A bug in Docker's internal DNS service prevented the
rasacontainer from resolving theducklingcontainer. This was solved by adding an explicitlinksdirective in thedocker-compose.ymlfile. - File Permission Fix: The Action Server container was unable to write to the
appointments.jsonfile due to a Docker file-sharing bug. This was definitively solved by moving the file into a Docker Named Volume (salon-data), which grants the container proper ownership.
- Docker Desktop
- Node.js (LTS) & npm
- Git
-
Clone the Repository
git clone https://github.com/ChrisPham03/Chat-Bot-Assistant-.git cd Chat-Bot-Assistant- -
Create a
.gitignorefile To keep your repository clean, create a file named.gitignorein the project root (Chat-Bot-Assistant-) and add the following:# Rasa cache and models salon-bot/.rasa/cache/ salon-bot/models/ salon-bot/results/ # Python cache salon-bot/__pycache__/ salon-bot/actions/__pycache__/ # Node modules salon-widget-ui/node_modules/ # OS-specific .DS_Store
This project requires two separate terminal processes to run the backend and frontend.
-
Navigate into the backend directory:
cd salon-bot -
Build the Custom Images This command builds the custom
rasaandducklingimages. You only need to re-run this if you changeDockerfile,requirements.txt, or theduckling/source.docker-compose build
-
Train Your First Model This command runs a one-off container to train your NLU model.
docker-compose run --rm rasa train
-
Start All Services This command starts the Rasa server, Action Server, Duckling, and the Flask Dashboard in detached mode.
docker-compose up -d
-
Open a new terminal and navigate to the root folder (
Chat-Bot-Assistant-). -
Navigate into the frontend directory:
cd salon-widget-ui -
Install Dependencies
npm install
-
Start the React App
npm start
Once both the backend and frontend are running, open your browser and go to:
http://localhost:3000
You will see the chat widget and can interact with your bot live.
You can view the appointments saved in appointments.json on a simple calendar. This dashboard is started by docker-compose up.
Visit the Flask dashboard in your browser (check your docker-compose.yml for the exposed port, e.g., http://localhost:5001).
You can send messages directly to the Rasa server's REST API.
Full Booking Flow Example:
# 1. Start the conversation
curl -X POST http://localhost:5006/webhooks/rest/webhook \
-H "Content-Type: application/json" \
-d '{"sender": "test_user", "message": "I want to book a Men''s Cut on next saturday"}'
# 2. Bot will ask for a time. Respond:
curl -X POST http://localhost:5006/webhooks/rest/webhook \
-H "Content-Type: application/json" \
-d '{"sender": "test_user", "message": "How about 4pm"}'
# 3. Bot will ask for a name. Respond:
curl -X POST http://localhost:5006/webhooks/rest/webhook \
-H "Content-Type: application/json" \
-d '{"sender": "test_user", "message": "My name is Susan"}'
# 4. Bot will ask for contact info. Respond:
curl -X POST http://localhost:5006/webhooks/rest/webhook \
-H "Content-Type: application/json" \
-d '{"sender": "test_user", "message": "555-555-1234"}'Check the Database: To confirm the booking was saved, you can "look inside" the container's volume:
docker exec salon-bot-action-server-1 cat /data/appointments.jsonThe best way to debug the NLU/dialogue flow is in the terminal.
# Make sure you are in the salon-bot/ directory
docker-compose run --rm rasa shell --debug