A production-ready chatbot platform that allows users to define chatbots using a custom Domain-Specific Language (DSL), compile them into optimized JSON configurations, and deploy them instantly with a beautiful embeddable widget. https://buildchatbot.onrender.com
- Custom DSL Compiler: Define chatbots with a simple, intuitive DSL
- MongoDB Storage: Persistent storage with connection pooling
- Runtime Engine: Optimized message matching with multiple strategies
- Embeddable Widget: Beautiful, responsive chat widget for any website
- Web Dashboard: Compile and manage bots through a web interface
- REST API: Full CRUD operations for bot management
- Production Ready: Error handling, validation, rate limiting, and logging
DSL β Compiler β JSON β MongoDB
β
Widget β API β Runtime Engine
- Compiler Pipeline: Lexer β Parser β Semantic Analyzer β IR Generator
- Runtime Engine: Message matching with keyword indexing and trie-based search
- API Layer: RESTful endpoints with validation and error handling
- Frontend: Vanilla JS widget + HTML dashboard
- Node.js 16+
- MongoDB (local or Atlas)
-
Clone the repository
git clone <repository-url> cd dsl-chatbot-platform
-
Install dependencies
npm install
-
Configure environment
# Copy and edit .env cp .env.example .envEdit
.env:MONGODB_URI=mongodb://localhost:27017/dsl_chatbot DB_NAME=dsl_chatbot PORT=5000 NODE_ENV=production
-
Start the server
npm start
-
Open the dashboard
http://localhost:5000
Define your chatbot using our custom DSL:
bot MyChatbot
domain ecommerce
tone friendly
welcome "Hello! How can I help you today?"
intent product_search
keywords: shirts pants dresses shoes
response "Great choice! What size are you looking for?"
intent order_status
keywords: order status tracking
response "Please provide your order number."
fallback "I'm sorry, I didn't understand. Can you rephrase?"bot <name>: Bot namedomain <type>: ecommerce, education, saastone <style>: friendly, formal, professionalwelcome "<message>": Welcome messageintent <name>: Define an intentkeywords: word1 word2: Keywords for matchingresponse "<message>": Bot responsefallback "<message>": Default response
POST /api/compile
Content-Type: application/json
{
"dsl": "bot MyBot\ndomain ecommerce..."
}POST /api/chat/{botId}
Content-Type: application/json
{
"message": "Hello"
}GET /api/bot/{botId}GET /api/botsDELETE /api/bot/{botId}GET /api/healthAdd this script tag to your website:
<script src="https://yourdomain.com/widget.js" data-bot-id="bot_abc123"></script>- Visit
http://localhost:5000 - Paste DSL code in the left panel
- Click "Compile Bot"
- Copy the embed code and use the bot ID
# Compile a bot
curl -X POST http://localhost:5000/api/compile \
-H "Content-Type: application/json" \
-d '{
"dsl": "bot TestBot\ndomain ecommerce\ntone friendly\nwelcome \"Hello!\"\nintent greet\nkeywords: hello hi\nresponse \"Hi there!\"\nfallback \"Sorry\""
}'
# Chat with the bot
## Deploying to Render
Follow these steps to deploy on Render (https://render.com):
1. Remove any committed secrets from the repository (run locally):
```bash
git rm --cached .env || true
git commit -m "Remove local .env from repo"
```
2. Ensure `.env` is listed in `.gitignore` (already configured).
3. Create a new Web Service on Render and connect your Git repository.
4. In the Render service settings, set the following Environment variables:
- `MONGODB_URI` : your MongoDB connection string
- `DB_NAME` : database name (e.g. `dsl_chatbot`)
- `NODE_ENV` : `production`
- `JWT_SECRET` : a secure random string
- `REDIS_URL` : (optional) Redis connection string
5. Leave the build command as `npm install` and the start command as `npm start`, or use the provided `render.yaml` or `Dockerfile` for Docker-based deploys.
6. Optional: Use the included `Dockerfile` for a containerized deployment on Render (recommended for consistent runtime).
7. After deployment, check the health endpoint at `https://<your-service>.onrender.com/api/health`.
curl -X POST http://localhost:5000/api/chat/bot_abc123 \
-H "Content-Type: application/json" \
-d '{"message": "hello"}'# Development mode with auto-restart
npm run dev
# Run tests
npm test
# Lint code
npm run lint
# Format code
npm run formatβββ src/
β βββ compiler/ # DSL Compiler Pipeline
β β βββ index.js # Compiler facade
β β βββ lexer.js # Lexical analysis
β β βββ parser.js # Syntax analysis
β β βββ semantic.js # Semantic validation
β β βββ ir.js # IR generation
β βββ engine/ # Runtime Engine
β β βββ runtime.js # Runtime manager
β β βββ matcher.js # Message matching
β βββ storage/ # Database Layer
β β βββ mongodb.repository.js # MongoDB operations
β β βββ cache.js # Runtime cache
β β βββ initDb.js # Database setup
β βββ api/ # API Layer
β β βββ routes.js # Route definitions
β β βββ controllers/ # Request handlers
β β βββ middleware/ # Express middleware
β βββ errors/ # Error classes
β βββ server.js # Main server file
βββ public/ # Static assets
β βββ index.html # DSL Editor UI
β βββ widget.js # Chat widget
βββ tests/ # Test files and examples
βββ templates/ # DSL templates
βββ .env # Environment variables
βββ package.json
βββ README.md
MONGODB_URI: MongoDB connection stringDB_NAME: Database namePORT: Server port (default: 5000)NODE_ENV: Environment (development/production)
The system automatically creates optimized indexes:
{ user_id: 1, bot_id: 1 }(unique){ user_id: 1, created_at: -1 }
FROM node:16-alpine
WORKDIR /app
COPY package*.json ./
RUN npm ci --only=production
COPY . .
EXPOSE 5000
CMD ["npm", "start"]For production:
- Set
NODE_ENV=production - Use a production MongoDB instance
- Configure proper logging
- Set up monitoring
- Fork the repository
- Create a feature branch
- Make your changes
- Add tests
- Submit a pull request
Vaishnavi Khandelwal
MIT License - see LICENSE file for details.
- Documentation: [Link]
- Issues: [GitHub Issues]
- Email: support@example.com
Built with β€οΈ using Node.js, Express, MongoDB, and vanilla JavaScript.