Skip to content

VikingBot: Build AI Agents with Persistent Context Using OpenViking

I spent weeks building AI agents from scratch. Each time I hit the same wall: memory management. My agents would forget user preferences, lose conversation context, and require me to rebuild the same infrastructure repeatedly.

Then I found VikingBot.

The Problem with Building Agents from Scratch

Every agent I built needed the same components:

  • A way to store and retrieve memories
  • Session management across conversations
  • Platform adapters for different messaging apps
  • A skill system for extensibility

I kept rewriting these pieces. Each new project meant setting up databases, designing memory schemas, building Telegram/Slack integrations. It was tedious and error-prone.

What I wanted was a framework that handled all this infrastructure so I could focus on the agent’s actual behavior.

Finding VikingBot

VikingBot sits on top of OpenViking, which provides a context database designed for AI applications. The key insight: it treats memory as a first-class citizen, not an afterthought.

I tried it:

Terminal
pip install "openviking[bot]"

That gave me the core agent framework. Then I started the server:

Terminal
openviking-server --with-bot

And tested the CLI:

Terminal
ov chat

It worked. But the real test was whether it would remember things.

Testing Persistent Memory

I started a conversation through the CLI:

Conversation
Me: My name is Bob and I prefer Python over JavaScript.
Bot: Got it, Bob! I'll remember you prefer Python.
Me: What programming language do I prefer?
Bot: You prefer Python, Bob.

I ended the session and started a new one:

New Session
Me: What's my name and what language do I prefer?
Bot: Your name is Bob, and you prefer Python over JavaScript.

The memory persisted across sessions. This was exactly what I needed.

Under the hood, OpenViking extracts memories from conversations and stores them in a structured format:

Memory Structure
viking://user/memories/
├── profile.md
├── preferences/
│ └── programming-languages.md
└── entities/
└── bob.md

Building a Support Bot

I wanted to build a customer support bot that could remember user issues. Here’s what I came up with:

support_bot.py
from vikingbot import Bot, Skill
bot = Bot()
# Add skills
bot.add_skill("search_docs")
bot.add_skill("create_ticket")
bot.add_skill("escalate")
# Platform integrations
bot.connect_telegram(token="...")
bot.connect_slack(app_token="...")
# Start
bot.run()

The skill system uses markdown files for definitions:

skills/search_docs/SKILL.md
# Search Documentation
Search through the knowledge base for relevant articles.
## Usage
Provide a query and the skill will return matching documentation.
## Examples
User: "How do I reset my password?"
Skill searches docs and returns relevant articles.

This declarative approach made it easy to add new capabilities without modifying core logic.

Multi-Platform Support

One of my requirements was deploying the same agent across multiple platforms. VikingBot handles this through optional dependencies:

Terminal
# Telegram support
pip install "openviking[bot,bot-telegram]"
# Slack support
pip install "openviking[bot,bot-slack]"
# Feishu (for Chinese users)
pip install "openviking[bot,bot-feishu]"
# Everything
pip install "openviking[bot-full]"

I tested this with Telegram:

Terminal
export TELEGRAM_BOT_TOKEN="your-token-here"
openviking-server --with-bot

The same agent logic that worked in the CLI now responded to Telegram messages. No code changes required.

Session Management

The session management is where VikingBot shines. I looked at how it handles conversations:

session_example.py
# Sessions automatically tracked
session = client.session("user_123")
session.add_message("user", [TextPart("I need help with billing")])
session.add_message("assistant", [TextPart("I'll help you with that")])
session.commit() # Triggers memory extraction

When commit() is called, the system:

  1. Analyzes the conversation
  2. Extracts relevant memories
  3. Stores them in the context database
  4. Makes them available for future sessions

This automatic memory extraction meant I didn’t have to write custom logic for each type of information I wanted to remember.

Directory Structure

I explored how the framework organizes data:

Directory Structure
viking://agent/skills/
├── search_web/
│ ├── SKILL.md # Skill definition
│ └── scripts/ # Optional scripts
├── analyze_code/
└── ...
viking://agent/memories/
├── cases/ # Learned cases
└── patterns/ # Learned patterns
viking://user/memories/
├── profile.md
├── preferences/
└── entities/

The viking:// protocol is OpenViking’s way of providing a virtual filesystem for agent data. It abstracts away whether data is stored locally, in PostgreSQL, or elsewhere.

Integration with OpenViking Server

VikingBot runs as part of the OpenViking server:

Terminal
openviking-server --with-bot

This gives you:

  • HTTP API for programmatic access
  • MCP server for Claude/Cursor integration
  • Bot endpoints for messaging platforms
  • Unified context storage

I could access the agent through:

  1. The CLI (ov chat)
  2. HTTP API (for custom integrations)
  3. Messaging platforms (Telegram, Slack, etc.)
  4. MCP (for IDE integration)

All backed by the same persistent memory.

What I Built

With VikingBot, I built a research assistant that:

  1. Remembers my research interests
  2. Tracks papers I’ve read
  3. Reminds me of connections between topics
  4. Works across Telegram and CLI

The memory system meant I could ask “What did I think about that Transformer optimization paper?” and it would recall our previous discussion.

Trade-offs

VikingBot isn’t perfect:

  • The skill system requires learning a specific format
  • Memory extraction can be slow for long conversations
  • Platform-specific features (like Telegram keyboards) require custom handling
  • Documentation is still evolving

But for my use case—building agents that need to remember things—it solved the core problem.

Installation Options

For development, I installed from source:

Terminal
git clone https://github.com/bswen/openviking.git
cd openviking
uv pip install -e ".[bot]"

For production, PyPI works fine:

Terminal
pip install "openviking[bot]"

Configuration

The bot uses pydantic-settings for configuration, which means environment variables:

.env
# OpenAI (or compatible API)
OPENAI_API_KEY=sk-...
# Database (PostgreSQL for production)
DATABASE_URL=postgresql://user:pass@localhost/openviking
# Platform tokens
TELEGRAM_BOT_TOKEN=...
SLACK_APP_TOKEN=...

I appreciated that it follows the twelve-factor app pattern.

In this post, I shared my experience using VikingBot to build AI agents with persistent memory. The framework sits on top of OpenViking and handles the infrastructure pieces I kept rebuilding: memory management, session tracking, and platform integrations. The result is agents that actually remember user preferences and conversation history across sessions.

Final Words + More Resources

My intention with this article was to help others share my knowledge and experience. If you want to contact me, you can contact by email: Email me

Here are also the most important links from this article along with some further resources that will help you in this scope:

Oh, and if you found these resources useful, don’t forget to support me by starring the repo on GitHub!

Comments