This is a TypeScript port of the Python career conversation chatbot. It provides the same functionality as the original Python version but runs on Node.js with Express.js instead of Gradio.
Learning Project: This project was created as part of learning from the Udemy course by Ed Donner. You can find the course here.
- AI-powered career conversation using OpenAI's GPT-4o-mini
- Tool integration for recording user details and unknown questions
- Push notifications via Pushover
- PDF parsing for LinkedIn profile data
- Web-based chat interface
- Node.js (version 16 or higher)
- npm or yarn package manager
- OpenAI API key
- Pushover account and API keys (optional)
-
Install dependencies:
npm install
-
Set up environment variables: Create a
.envfile in this directory with:OPENAI_API_KEY=your_openai_api_key_here PUSHOVER_USER=your_pushover_user_key_here PUSHOVER_TOKEN=your_pushover_token_here -
Prepare your profile data:
- Add your
linkedin.pdffile to theme/directory - Edit
me/summary.txtwith your career summary
- Add your
-
Build the TypeScript code:
npm run build
npm run devnpm startThe application will be available at http://localhost:3000
- Web Framework: Uses Express.js instead of Gradio
- Chat Interface: Custom HTML/CSS/JavaScript interface instead of Gradio's UI
- PDF Processing: Uses
pdf-parseinstead ofpypdf - HTTP Requests: Uses
axiosinstead ofrequests - Environment Variables: Uses
dotenvpackage - Type Safety: Full TypeScript typing for better development experience
- Clean Architecture: Separated concerns with modular TypeScript files
- Static Assets: Organized CSS and JavaScript in separate files
├── src/ # TypeScript source files
│ ├── app.ts # Main chatbot logic and Me class
│ ├── server.ts # Express.js web server
│ ├── tools.ts # AI tool functions and definitions
│ └── types.ts # TypeScript type definitions
├── public/ # Static web assets
│ ├── css/
│ │ └── styles.css # Application styles
│ ├── js/
│ │ └── chat.js # Client-side chat functionality
│ └── index.html # Clean HTML structure
├── me/ # Personal profile data
│ ├── linkedin.pdf # Your LinkedIn profile as PDF
│ ├── summary.txt # Your career summary text
│ └── README.md # Profile setup instructions
├── dist/ # Compiled TypeScript output
├── package.json # Node.js dependencies and scripts
├── tsconfig.json # TypeScript configuration
└── project.json # Project structure documentation
GET /- Serves the chat interfacePOST /chat- Handles chat messages- Request body:
{ message: string, history: Message[] } - Response:
{ response: string }
- Request body:
The chatbot includes two main tools:
- record_user_details - Records when users provide contact information
- record_unknown_question - Records questions the bot cannot answer
Both tools send push notifications via Pushover when triggered.
The project follows a clean separation of concerns:
- Backend (
src/): TypeScript files for server logic, AI integration, and tool functions - Frontend (
public/): Static assets with separated HTML, CSS, and JavaScript - Types (
src/types.ts): Centralized type definitions for better type safety - Tools (
src/tools.ts): AI tool functions and OpenAI API definitions
- Backend Logic: Edit files in
src/directory - Styling: Update
public/css/styles.css - Frontend Behavior: Modify
public/js/chat.js - HTML Structure: Edit
public/index.html
# Development with auto-reload
npm run dev
# Build TypeScript
npm run build
# Run production build
npm start
# Watch for TypeScript changes
npm run watchTo modify the chatbot behavior:
- Edit the
Meclass insrc/app.ts - Update tool functions in
src/tools.ts - Modify the system prompt in the
systemPrompt()method - Rebuild with
npm run build
This TypeScript version can be deployed to various platforms:
- Railway:
- Set environment variables in Railway dashboard
- The project includes
railway.jsonconfiguration - Build command:
npm run build - Start command:
npm start - Health check endpoint:
/health
- Heroku: Add a
Procfilewithweb: node dist/src/server.js - Vercel: May need serverless function adaptation
- DigitalOcean App Platform: Configure build and run commands
- AWS/GCP/Azure: Deploy as containerized application
-
Environment Variables: Set these in Railway dashboard:
OPENAI_API_KEY(required)PUSHOVER_USER(optional)PUSHOVER_TOKEN(optional)NODE_ENV=production
-
Build Process: Railway will automatically run
npm installandnpm run build -
Troubleshooting Railway:
- Check the build logs for TypeScript compilation errors
- Verify environment variables are set correctly
- Use
/healthendpoint to test if server is running - Ensure your
me/directory files are included in the deployment
Make sure to set environment variables in your deployment platform.
- Module not found errors: Run
npm installto install dependencies - TypeScript compilation errors: Check
tsconfig.jsonconfiguration - Environment variables not loaded: Ensure
.envfile exists and is properly formatted - PDF parsing issues: Verify
me/linkedin.pdfexists and is readable - Port already in use: Change the PORT environment variable or kill existing processes
- Railway deployment failures:
- Check build logs for compilation errors
- Verify environment variables are set in Railway dashboard
- Test health endpoint:
your-app-url.railway.app/health - Ensure OpenAI API key is valid and has credits
MIT License - feel free to modify and use as needed.
