⚡ Build a Telegram AI assistant with MemMachine, OpenAI, and voice support

309 views · ⚡ Personal Productivity

Description

Build a Telegram assistant with MemMachine and voice support

An AI assistant that NEVER forgets using MemMachine for persistent cross-session memory, with voice transcription support and productivity tools.

⚠️ Important Deployment Note: This workflow is designed for self-hosted n8n instances. If you’re using n8n Cloud, you’ll need to deploy MemMachine to a cloud server and update the HTTP Request URLs in nodes 4, 5, and 9.

What This Template Does

This workflow creates an intelligent personal assistant that maintains perfect memory across all conversations, whether you message today or weeks from now. It supports both text and voice messages, automatically transcribes voice using OpenAI Whisper, and provides tools for Gmail, Google Sheets, and Google Calendar.

Key Features

Real-World Example

Day 1 - Text Message:

Day 3 - Voice Message:

Day 7 - Text Message:

The AI remembers who John is, what you discussed, and when it happened - all without you having to repeat yourself!

How It Works

Message Flow

For Text Messages:

  1. Telegram Trigger receives message
  2. Extract user data and message text
  3. Store message in MemMachine
  4. Search conversation history (last 30 memories)
  5. AI processes with full context + tools
  6. Store AI response for future reference
  7. Send reply to user

For Voice Messages:

  1. Telegram Trigger receives voice message
  2. Download voice file
  3. OpenAI Whisper transcribes to text
  4. Extract transcribed text and user data
  5. Store in MemMachine (same as text flow)
  6. Process with AI + tools
  7. Send reply to user

Requirements

Services & Credentials

Installation

MemMachine Setup

# Clone and start MemMachine
git clone https://github.com/MemMachine/MemMachine
cd MemMachine
docker-compose up -d

# Verify it's running
curl http://localhost:8080/health

Workflow Configuration

Deployment Options

This workflow supports two deployment scenarios:

Option 1: Self-Hosted n8n (Recommended)

Option 2: n8n Cloud

Configuration Steps

  1. Import this template into your n8n instance

  2. Update MemMachine URLs (nodes 4, 5, 9):

    • Self-hosted n8n in Docker: http://host.docker.internal:8080
    • Self-hosted n8n (direct install): http://localhost:8080
    • n8n Cloud: https://your-memmachine-domain.com
  3. Set Organization IDs (nodes 4, 5, 9):

    • Change your-org-id to your organization name
    • Change your-project-id to your project name
  4. Add Credentials:

    • Telegram Bot Token (node 1)
    • OpenAI API Key (nodes 4, 7)
    • Gmail OAuth (Gmail Tool node)
    • Google Sheets OAuth (Sheets Tool node)
    • Google Calendar OAuth (Calendar Tool node)

Use Cases

Personal Productivity

Customer Support

Task Management

Email Automation

Calendar Management

Customization Guide

Extend Memory Capacity

In Node 5 (Search Memory), adjust:

"top_k": 30  // Increase for more context (costs more tokens)

Modify AI Personality

In Node 7 (AI Agent), edit the system prompt to:

Add More Tools

Connect additional n8n tool nodes to the AI Agent:

Multi-Channel Memory

Create similar workflows for:

All channels can share the same memory by using consistent customer_email identifiers!

Memory Architecture

Storage Structure

Every message is stored with:

{
  "content": "message text",
  "producer": "user@email.com",
  "role": "user" or "assistant",
  "metadata": {
    "customer_email": "user@email.com",
    "channel": "telegram",
    "username": "john_doe",
    "timestamp": "2026-01-07T12:00:00Z"
  }
}

Retrieval & Formatting

  1. Search - Finds relevant memories by customer email
  2. Sort - Orders chronologically (oldest to newest)
  3. Format - Presents last 20 messages to AI
  4. Context - AI uses history to inform responses

Cost Estimate

Monthly estimate for 1,000 messages (mix of text/voice):

Troubleshooting

Deployment Issues

n8n Cloud: Can’t connect to MemMachine

Self-Hosted: Can’t connect to MemMachine

Voice not transcribing

AI not remembering

Tools not working

Advanced Features

Cloud Deployment Guide (For n8n Cloud Users)

If you’re using n8n Cloud, follow these steps to deploy MemMachine:

1. Choose a Cloud Provider

2. Deploy MemMachine

For DigitalOcean/AWS/GCP:

# SSH into your server
ssh root@your-server-ip

# Install Docker
curl -fsSL https://get.docker.com -o get-docker.sh
sh get-docker.sh

# Clone and start MemMachine
git clone https://github.com/MemMachine/MemMachine
cd MemMachine
docker-compose up -d

3. Configure HTTPS (Required for n8n Cloud)

# Install Caddy for automatic HTTPS
apt install caddy

# Create Caddyfile
cat > /etc/caddy/Caddyfile << 'CADDYEND'
your-domain.com {
    reverse_proxy localhost:8080
}
CADDYEND

# Start Caddy
systemctl start caddy

4. Update Workflow

5. Security Best Practices

Semantic Memory

MemMachine automatically extracts semantic facts from conversations for better recall of important information.

Chronological Context

Memories are sorted by timestamp, not relevance, to maintain natural conversation flow.

Cross-Session Persistence

Unlike session-based chatbots, this assistant remembers across days, weeks, or months.

Multi-Modal Input

Seamlessly handles both text and voice, storing transcriptions alongside text messages.

Template Information

Author: David Olusola
Version: 1.0.0
Created: January 2026

Support & Resources

Contributing

Found a bug or have an improvement? Contribute to the template or share your modifications with the n8n community!


Start building your perfect-memory AI assistant today! 🚀

🔗 Nodes Used

HTTP Request, Telegram, Telegram Trigger, AI Agent, OpenAI Chat Model, OpenAI

📥 Import

Download workflow.json and import into n8n: Workflow menu → Import from File

📖 Importing guide · 🔑 Credential setup