A Node.js-based chatbot server with AI integration, Twilio messaging support, and EdX API integration.
- 🤖 AI-powered chatbot using OpenAI
- 📱 Twilio SMS integration
- 🎓 EdX API integration for course management
- 🔐 Auth0 authentication
- 🗄️ PostgreSQL database with Sequelize ORM
- 🧪 Comprehensive testing with Jest
- 🐳 Docker support for easy development
- 📝 API documentation
- Node.js 20.19.2 or higher
- PostgreSQL 15 or higher
- Docker and Docker Compose (for containerized development)
- pnpm package manager
git clone <repository-url>
cd chatbot
pnpm install
Copy the environment example files and configure them:
cp env.example .env
cp docker.env.example .docker/.env
Edit .env
and .docker/.env
with your actual configuration values.
# Create database
pnpm db:create
# Run migrations
pnpm db:migrate
# Seed with demo data (optional)
pnpm db:seed:all
# Development mode
pnpm dev
# Production mode
pnpm serve
For containerized development:
# Build and start containers
./scripts/rebuild.sh
./scripts/start.sh
# Stop containers
./scripts/stop.sh
POST /chatbot/message
- Send a message to the chatbotGET /chatbot/history
- Get chat historyGET /chatbot/health
- Health check
POST /messaging/webhook/incoming-message
- Twilio webhookGET /messaging
- Messaging service status
GET /auth/login
- Login endpoint
GET /edx/courses
- Get available courses
# Run all tests
pnpm test
# Run tests in watch mode
pnpm test:watch
# Run tests with coverage
pnpm test:coverage
# Run tests in verbose mode
pnpm test:verbose
# Create database
pnpm db:create
# Generate model
pnpm db:create-model
# Generate migration
pnpm db:generate-migration
# Run migrations
pnpm db:migrate
# Undo last migration
pnpm db:undo-migration
# Rollback all migrations
pnpm db:rollback-migrations
# Drop database
pnpm db:drop
# Check code quality
pnpm lint
# Auto-fix issues
pnpm lint:fix
src/
├── config/ # Configuration files
├── controllers/ # Request handlers
├── middlewares/ # Express middlewares
├── models/ # Database models
├── routes/ # API routes
├── services/ # Business logic
├── utils/ # Utility functions
└── validations/ # Input validation schemas
Variable | Description | Required | Default |
---|---|---|---|
NODE_ENV |
Environment | No | development |
PORT |
Server port | No | 3001 |
APP_URL |
Application URL | Yes | - |
POSTGRES_HOST |
Database host | Yes | - |
POSTGRES_PORT |
Database port | No | 5432 |
POSTGRES_USER |
Database user | Yes | - |
POSTGRES_PASSWORD |
Database password | Yes | - |
POSTGRES_DB |
Database name | Yes | - |
AUTH0_DOMAIN |
Auth0 domain | Yes | - |
AUTH0_CLIENT_ID |
Auth0 client ID | Yes | - |
AUTH0_CLIENT_SECRET |
Auth0 client secret | Yes | - |
AUTH0_AUDIENCE |
Auth0 audience | Yes | - |
AUTH0_ISSUER_BASE_URL |
Auth0 issuer URL | Yes | - |
TWILIO_ACCOUNT_SID |
Twilio account SID | Yes | - |
TWILIO_AUTH_TOKEN |
Twilio auth token | Yes | - |
TWILIO_PHONE_NUMBER |
Twilio phone number | Yes | - |
EDX_API_KEY |
EdX API key | Yes | - |
EDX_API_URL |
EdX API URL | Yes | - |
EDX_CLIENT_ID |
EdX client ID | Yes | - |
EDX_CLIENT_SECRET |
EdX client secret | Yes | - |
AI_API_KEY |
OpenAI API key | Yes | - |
AI_MODEL |
AI model to use | No | gpt-4 |
- Fork the repository
- Create a feature branch
- Make your changes
- Add tests for new functionality
- Ensure all tests pass
- Submit a pull request
This project is licensed under the MIT License.