A voice-driven medication reminder system that uses Twilio to make calls to patients, remind them about their medications, and capture their responses using Speech-to-Text technology.
- Trigger voice calls to patients via a REST API
- Text-to-Speech (TTS) for medication reminders using ElevenLabs
- Real-time Speech-to-Text (STT) with Deepgram for interactive conversations
- Intelligent response generation using OpenAI's GPT-4o
- Voicemail and SMS fallback for unanswered calls
- Call data logging to console
- Robust error handling and edge case management
- Comprehensive test suite
- Node.js (v18 or higher)
- npm or yarn
- Twilio account
- Deepgram account (for STT)
- ElevenLabs account (for TTS)
- OpenAI account (for LLM)
- ngrok (for local webhook testing)
-
Clone the repository:
git clone https://github.com/chai-dev682/voice-medication-reminder-system.git cd voice-medication-reminder -
Install dependencies:
npm install -
Create a
.envfile based on the.env.exampletemplate:cp .env.example .env -
Fill in your API keys and configuration in the
.envfile.
Your .env file should include the following variables:
- Sign up for a Twilio account at twilio.com
- Purchase a phone number with voice capabilities
- Get your Account SID and Auth Token from the Twilio dashboard
- Add these credentials to your
.envfile
- Sign up for a Deepgram account at deepgram.com
- Create an API key
- Add the API key to your
.envfile
- Sign up for an ElevenLabs account at elevenlabs.io
- Create an API key
- Add the API key to your
.envfile
- Install ngrok:
npm install -g ngrokor download from ngrok.com - Start your application:
npm run dev - In a separate terminal, start ngrok:
ngrok http 3000 - Copy the ngrok URL (e.g.,
https://abc123.ngrok.io) and add it to your.envfile asWEBHOOK_BASE_URL - Configure your Twilio phone number's webhook to point to
{WEBHOOK_BASE_URL}/api/calls/incoming
npm start
For development with auto-reload:
npm run dev
POST /api/calls/outgoing
Content-Type: application/json
{
"phoneNumber": "+1234567890"
}
- System initiates a call to the patient
- When answered, the system plays a medication reminder message
- The patient responds verbally
- Deepgram transcribes the response in real-time
- OpenAI processes the transcription and generates an appropriate reply
- ElevenLabs converts the reply to speech
- The system plays the response to the patient
- The conversation continues until the call ends
Run the test suite:
npm test
For test coverage:
npm run test:coverage
MIT