Skip to main content
This guide demonstrates how to create a memory-enabled voice assistant using LiveKit, Deepgram, OpenAI, and Mem0, focusing on creating an intelligent, context-aware travel planning agent.

Prerequisites

Before you begin, make sure you have:
  1. Installed Livekit Agents SDK with voice dependencies of silero and deepgram:
  1. Installed Mem0 SDK:
  1. Set up your API keys in a .env file:
Note: Make sure to have a Livekit and Deepgram account. You can find these variables LIVEKIT_URL, LIVEKIT_API_KEY, and LIVEKIT_API_SECRET from the LiveKit Cloud Console. For more information, refer to the LiveKit Documentation. For DEEPGRAM_API_KEY, you can get it from the Deepgram Console. Refer to the Deepgram Documentation for more details.

Code Breakdown

Let’s break down the key components of this implementation using LiveKit Agents:

1. Setting Up Dependencies and Environment

2. Mem0 Client and Agent Definition

3. Entrypoint and Session Setup

Key Features of This Implementation

  1. Semantic Memory Retrieval: Uses Mem0 to store and retrieve contextually relevant memories
  2. Voice Interaction: Leverages LiveKit for voice communication with proper turn detection
  3. Intelligent Context Management: Augments conversations with past interactions
  4. Travel Planning Specialization: Focused on creating a helpful travel guide assistant
  5. Function Tools: Modern tool definition for enhanced capabilities

Running the Example

To run this example:
  1. Install all required dependencies
  2. Set up your .env file with the necessary API keys
  3. Ensure your microphone and audio setup are configured
  4. Run the script with Python 3.11 or newer and with the following command:
or to start your agent in console mode to run inside your terminal:
  1. After the script starts, you can interact with the voice agent using LiveKit’s Agent Platform and connect to the agent to start conversations.

Best Practices for Voice Agents with Memory

  1. Context Preservation: Store enough context with each memory for effective retrieval
  2. Privacy Considerations: Implement secure memory management
  3. Relevant Memory Filtering: Use semantic search to retrieve only the most relevant memories
  4. Error Handling: Implement robust error handling for memory operations

Debugging Function Tools

  • To run the script in debug mode simply start the assistant with dev mode:
  • When working with memory-enabled voice agents, use Python’s logging module for effective debugging:
  • Check the logs for any issues with API keys, connectivity, or memory operations.
  • Ensure your .env file is correctly configured and loaded.

ElevenLabs Integration

Build conversational voice agents with ElevenLabs

Pipecat Integration

Create real-time voice applications with Pipecat
Enjoying Mem0? Star us on GitHub — it takes two seconds and helps more developers discover open-source memory.