The Bot9 Palace Booking Bot is a Telegram bot designed to assist users in booking rooms at the Bot9 Palace. Users can interact with the bot to view available rooms and book them by providing necessary details. Upon successful booking, the bot generates a booking ID and confirms the room reservation.
- View Available Rooms: Users can inquire about available rooms and their prices.
- Book Rooms: Users can book rooms by providing their full name, email, number of nights for the stay, and the room name.
- Booking Confirmation: The bot generates a booking ID and confirms the reservation with the user.
- Node.js installed on your system.
- A Telegram account.
- MySQL installed on your system.
Clone the project repository to your local machine using the following command:
git clone <repository-url>
Navigate to the project directory and install the required dependencies using the following command:
npm install
NOTE: If do not want to use a telegram bot scroll down to step 8 "Using Postman to interact with the bot"
- Open the Telegram app and search for the BotFather.
- Create a new bot by following the instructions provided by the BotFather.
- Copy the bot token generated by the BotFather.
- Set the bot privacy to
Disable
to allow the bot to read all messages sent to it. - Copy the bot token and save it for later use.
- Visit the OpenAI website and sign up or log in.
- Navigate to the API section and generate a new API key.
Create a .env
file in the project directory and add the following environment variables:
TELEGRAM_BOT_TOKEN=<your_telegram_bot_token>
OPENAI_API_KEY=<your_openai_api_key>
- Create a new MySQL database.
- In the config.json file replace the database name, username, and password with your database details.
Run the following command to start the bot:
node bot.js
Run the following command to start the server:
node server.js
- Open Postman after starting the server.
- Send a POST request to
http://localhost:3000/chat/
with the following JSON body:
{
"chatId": "<This is basically the user id that is provided by the telegram bot api, use unique numbers for your users>",
"message": "<Your message>"
}
- The bot will respond with a message body that contains the bot response.
After starting the bot, you can interact with it through Telegram by sending messages. Use the /start command to begin a conversation with the bot and follow the prompts to view available rooms or book a room.