A full-stack application for managing message templates with Telegram bot integration. improvements that were made was adding openai gpt-4 to enhance ux with bot integration.
- started to integrate cicd pipeline.
- Frontend: React
- Backend: Node.js/Express
- Database: MongoDB
- Bot: Telegram API
- CI/CD: GitHub Actions
- Containerization: Docker
- Node.js: 18+
- Docker & Docker Compose
- MongoDB Instance
- Telegram Bot Token
- OpenAI API Key
git clone https://github.com/yourusername/mtsystem.git
cd mtsystemCreate a .env file in the root directory:
**MONGODB_URI=your_mongodb_connection_string**
**TELEGRAM_BOT_TOKEN=your_telegram_bot_token**
**OPENAI_API_KEY=your_openai_api_key**npm install
Open two terminal windows or tabs.
# Terminal 1: Start Server
cd server
npm run dev
span
Terminal 2: Start Client
cd client
npm start
The application should now be running:
- Client:
http://localhost:3000 - Server:
http://localhost:5000
- Open your browser and navigate to
http://localhost:3000. - You will see the Message Template Manager interface.
- Create a New Template:
- Click on the "Add Template" button.
- Fill in the Name and Context fields.
- Name: A descriptive name for the template (e.g., "Book Recommendation").
- Context: A keyword or phrase related to the template (e.g., "books").
- Submit the form to save the template.
- Manage Existing Templates:
- View the list of existing templates.
- Edit or delete templates as needed using the provided buttons.
- Start the Bot:
- Open Telegram and search for your bot using its username.
- Click on Start to begin interacting with the bot.
- Command:
/start- Response: "Welcome to the Template Bot!"
- View Available Commands:
- Command:
/templates- Response: Displays a list of all available templates with their names and contexts.
- Command:
- Retrieve a Template Using Context:
- Send a regular message that matches a template's context.
- Example Message: "I'm looking for a template related to books."
- Response: The bot will return the corresponding template if a matching context is found.
- Send a regular message that matches a template's context.
- Example Workflow:
- Add a Template:
- Name: Book Recommendation
- Context: books
- Use the Bot:
- Command:
/templates-
Bot Response:
Available Templates:
- Book Recommendation: Here is a great book for you...
-
- Message: "I'm looking for a template related to books."
- Bot Response: "Here is a great book for you"
- Command:
- Add a Template:
- Ensure that the server is running and connected to MongoDB.
- Use the client application to add, view, edit, and delete templates.
- Interact with the Telegram bot to retrieve templates based on context.
- Verify that templates are correctly returned and managed.
Ensure you have a .env file in the root directory with the following variables:
MONGODB_URI=your_mongodb_connection_string
TELEGRAM_BOT_TOKEN=your_telegram_bot_token
OPENAI_API_KEY=your_openai_api_key
Ensure your docker-compose.yml includes the necessary environment variables:
version: '3.8'
services:
client:
build: ./client
ports:
- "3000:80"
environment:
- REACT_APP_API_URL=http://localhost:5000
depends_on:
- server
server:
build: ./server
ports:
- "5000:5000"
env_file:
- .env
environment:
- PORT=5000
docker-compose up --build
****The application should now be accessible at:
- Client:
http://localhost:3000 - Server:
http://localhost:5000
Add the following secrets to your GitHub repository:
DOCKER_HUB_USERNAMEDOCKER_HUB_TOKENMONGODB_URITELEGRAM_BOT_TOKENOPENAI_API_KEY
Pushing to the main branch will trigger the CI/CD pipeline:
git add .
git commit -m "Set up CI/CD pipeline"
git push origin main
mtsystem/
βββ client/ # React frontend
β βββ src/
β β βββ components/ # React components
β β βββ services/ # API services
β β βββ context/ # React context
β βββ Dockerfile
βββ server/ # Node.js backend
β βββ routes/ # API routes
β βββ models/ # MongoDB models
β βββ Dockerfile
βββ .github/
β βββ workflows/ # GitHub Actions
βββ docker-compose.yml
βββ README.md
- CRUD Operations: Create, read, update, delete message templates
- Telegram Bot Integration
- OpenAI Integration
- Docker Containerization
- Automated CI/CD Pipeline
docker-compose down
docker-compose up --build
- Verify the
MONGODB_URIin .env - Check network connectivity
- Ensure MongoDB instance is running
- Client:
docker logs mtsystem-client - Server:
docker logs mtsystem-server