This is a restaurant chatbot that assists customers in placing orders for their preferred meals.
- User can place orders for their preferred meals.
- User can view, cancel or checkout a pending order.
- User can view order history, including cancelled orders.
Chowbot is easy to use. It will provide the user with a list of options, and the user will select an option by responding with the corresponding number. For example, A typical workflow:
- Chowbot will prompt the user to select an option from the main menu.
- The user will select
1
to place an order. - Chowbot will prompt the user to select a meal from the menu.
- The user will select
1
to select the first meal on the menu. - Chowbot will prompt the user to select another meal or go back to main menu.
- The user will select
0
to go back to the main menu. - Chowbot will prompt the user to select an option from the main menu.
- The user will select
99
to proceed to checkout. - Chowbot will send a comfirmatory message, and prompt the user to select an option from the main menu.
field | data_type | constraints |
---|---|---|
userId | string | required, unique |
orders | [ orderSchema ] | |
chatHistory | ref - Chat |
Order Schema
field | data_type | constraints |
---|---|---|
status | string | required, enum: ["pending", "confirmed", "cancelled"] |
date | string | required |
items | [ name: string, price: number, qty: number ] | required |
total | number |
field | data_type | constraints |
---|---|---|
message | string | required, trim |
isBot | boolean | required |
user | ref - User |
field | data_type | constraints |
---|---|---|
name | string | required |
price | number | required |
event | payload | description |
---|---|---|
message | eventName, message, isBot | Sends a message to the client. |
chatHistory | eventName, message, isBot | Sends a message from the chat history to the client. Emitted when getChatHistory() method is called |
field | data_type | description |
---|---|---|
message | string | The message to be sent |
data | any | Additional data to be sent |
eventName | string | The name of the event being emitted |
isBot | boolean | Indicates if a message was initialised by the bot or the user |
event | description |
---|---|
message | Sends a message to the server |
menu | Sends a message to the server and triggers the server's handleMenu() method for processing menu selections |
field | data_type | description |
---|---|---|
eventName | string | The name of the event |
input | string | The message to be sent to the server |
- Make sure you have Nodejs installed.
- Make sure you have MongoDB installed and running, or use MongoDB Atlas for a cloud-based database.
- Make sure you have a Sentry account for error logging. If you don't want to use Sentry, you can remove the
sentry
middleware frombackend/src/middleware/sentry.js
andbackend/src/app.js
.
- Clone the repository
git clone https://github.com/misspee007/chowbot.git
- Navigate to the root folder, copy the .env.example file and fill in the values.
cp .env.example .env
- Navigate to frontend directory and install dependencies
cd frontend && npm install
- Run build command
npm run build
The build command will create a dist
folder in the frontend directory. This folder will be used by the backend server to serve the frontend files.
- Open another terminal, navigate to backend directory, install dependencies and start server
cd backend && npm install
npm run start
- Go to http://localhost:\ to view. The default PORT is 3399.
- Run the seeder script to clear the database and seed it with menu items.
npm run seed
.
├── backend
│ ├── src
│ │ ├── controllers
│ │ │ └── OrderingSession.js //contains the logic for the ordering session
│ │ ├── config
│ │ │ └── index.js //contains the configuration for the app (i.e initialisation of env variables)
│ │ ├── database
│ │ │ ├── db.js //contains the connection to the database
│ │ │ ├── seeder.js //contains the logic for seeding the database. The seeder script will run this file.
│ │ │ └── index.js
│ │ ├── middleware
│ │ │ ├── sentry.js //contains the config for the sentry logging middleware
│ │ │ └── session.js //contains the config for the express-session middleware
│ │ ├── models
| | | ├── chatModel.js
| | | ├── menuModel.js
| | | ├── userModel.js
│ │ │ └── index.js
│ │ └── utils
│ │ ├── orderSession.utils.js //helper functions and constand data for the ordering session component
│ │ ├── constants.js //contains constants used in the app
│ │ └── server.utils.js //helpers for server.js
│ ├── app.js //express app
│ ├── package-lock.json
│ ├── package.json //contains the dependencies for the backend
│ └── server.js //socket.io server
├── frontend
│ ├── src
│ │ ├── config
│ │ │ └── index.js
│ │ ├── App.jsx //main app component
│ │ └── index.html
│ ├── vite.config.js
│ ├── package-lock.json
│ └── package.json //contains the dependencies for the frontend
├── .env.example
├── .gitignore
├── package.json //contains the scripts for the app used in production. Not recommended for development.
|── Procfile //contains the command to start the app in production
└── README.md
- Nodejs - Backend runtime
- Express - Backend framework
- MongoDB - Database
- Mongoose - MongoDB object modeling
- Socket.io - Websocket library
- Express-Session - Session management
- Reactjs - Frontend framework
- React-Bootstrap - UI library
- Vite - Frontend build tool
- Sentry - Error logging and monitoring
Precious Abubakar | [email protected]