This project consists of two main components: a voice-based AI assistant for handling customer inquiries and a dashboard for monitoring and analyzing call data.
- Node.js
- Express.js
- WebSocket (express-ws)
- OpenAI GPT for natural language processing
- Deepgram for speech-to-text transcription
- Twilio for handling phone calls
- MongoDB for data storage
- Next.js 14
- React
- TypeScript
- Tailwind CSS
- Chart.js and react-chartjs-2 for data visualization
- MongoDB for data retrieval
The caller agent is built on top of the call-gpt project by Twilio Labs, which provides a foundation for creating AI-powered voice applications using Twilio Media Streams. We've extended and customized this project to fit the specific needs of our car dealership assistant.
- Voice-to-text transcription using Deepgram
- Natural language processing with OpenAI's GPT model
- Text-to-speech conversion for AI responses
- Integration with Twilio for handling phone calls
- MongoDB integration for storing call logs and transcriptions
- Real-time audio streaming and processing
app.js: The main application file that sets up the Express server and WebSocket connectionsgpt-service.js: Handles interactions with the OpenAI APItts-service.js: Manages text-to-speech conversiontranscription-service.js: Handles speech-to-text conversiondb-service.js: Manages database operations with MongoDBrecording-service.js: Handles call recording functionalitystream-service.js: Manages audio streaming
The AI assistant can perform various functions, such as:
- Checking car availability
- Getting car prices
- Scheduling test drives
- Scheduling maintenance appointments
- Scheduling oil changes
These functions are defined in the functions directory and are dynamically loaded based on the function-manifest.js file.
The dashboard is a Next.js application that provides a user interface for viewing and analyzing call data.
- Overview of call statistics
- Detailed call logs
- Transcription viewer
- Charts for data visualization
- Appointment management
app/dashboard/page.tsx: The main dashboard pagecomponents/CallLogDetail.tsx: Displays detailed information for a specific callcomponents/CallLogsList.tsx: Lists all call logscomponents/charts.tsx: Renders various charts for data visualizationcomponents/AppointmentsList.tsx: Manages and displays appointments
The dashboard uses custom UI components built with Tailwind CSS and Radix UI primitives, including:
- Cards
- Tables
- Tabs
- Badges
- Charts
-
Clone the repository
-
Install dependencies for both the caller agent and dashboard:
cd caller-agent && npm install cd ../dashboard && npm install -
Set up environment variables:
- For the caller agent, copy
.env.exampleto.envand fill in the required values - For the dashboard, set up the necessary environment variables, including the MongoDB connection string
- For the caller agent, copy
-
Start the caller agent:
cd caller-agent && npm run dev -
Start the dashboard:
cd dashboard && npm run dev
The caller agent includes Jest tests for various functions. Run tests using:
npm run test
The caller agent can be deployed using Fly.io. Modify the fly.toml file with your app name and use the following commands:
fly launch
fly deploy
fly secrets import < .env
The dashboard can be deployed to your preferred Next.js hosting platform, such as Vercel or Netlify. Follow the platform-specific deployment instructions.
- The project uses ESLint for code linting
- Tailwind CSS is used for styling in the dashboard
- TypeScript is used in the dashboard for type safety
This project is licensed under the MIT License. See the LICENSE file for details.