Backend API server for the Travel & History chatbot powered by Groq AI.
- Express.js REST API
- Groq AI integration for natural language processing
- TypeScript for type safety
- Environment variable configuration
- Node.js 18 or higher
- npm or yarn package manager
- Groq API key
- Clone the repository
git clone https://github.com/yourusername/travel-history-chatbot-backend.git
cd travel-history-chatbot-backend- Install dependencies
npm install- Create a
.envfile in the root directory with the following variables:
PORT=3000
GROQ_API_KEY=your_groq_api_key_here
To start the development server:
npm run devThis will build the TypeScript code and start the server at http://localhost:3000.
GET /api/health: Check if the API is running
POST /api/chat: Send messages to the chatbot- Request body:
{ "messages": [ { "role": "user", "content": "Tell me about the history of Rome" } ], "options": { "temperature": 0.7, "maxTokens": 1024, "model": "llama3-8b-8192" } }- Response:
{ "message": { "role": "assistant", "content": "Rome has a rich and fascinating history..." } }
Build for production:
npm run buildStart the production server:
npm run startISC