After-hours Voicemail and Notification
After-hours Voicemail and Notification
Handle calls outside business hours by collecting a message, transcribing it, and notifying the team.
Overview
This use case demonstrates:
- Time-of-day routing (business hours vs. after hours)
- Pre-answer connect during business hours
- AI voicemail recording and transcription
- Database storage of voicemails
- Team notification via Slack/webhook
State flow (business hours): PENDING -> CONNECTED -> DISCONNECTED
State flow (after hours): PENDING -> ANSWERED -> DISCONNECTED
Example
How It Works
- When a call arrives, the handler checks the current time
- During business hours: the call is connected to the original callee using
connect()without answering, and the agent leaves withclose(). The caller goes straight to ringing the callee. - After hours: the AI answers, plays a voicemail prompt, and records the caller’s message
- The AI detects when the caller has finished speaking (silence detection)
- The recorded audio is transcribed using a speech-to-text service
- Both the raw audio and transcript are saved to the database
- A notification is sent to a Slack channel (or any webhook) with the caller’s number and transcript
- The AI confirms the message was recorded and ends the call
Key Commands Used
connect()- Route to the original callee during business hours (pre-answer)close()- Leave the call after connecting the caller to the calleeanswer()- Answer for voicemail after hoursaudio_stream()- Record the caller’s messagesend_audio()- Play the voicemail promptdisconnect()- End the voicemail call after the goodbye prompt
Related
- AI Receptionist with Database Lookup - Answering with CRM context
- Interactive Notifications - Following up on recorded messages
