Slack Bot With AI Memory (Per User, Per Channel)
Free · Open source (MIT) · Works with LangChain, CrewAI, AutoGen · No signup
Your Slack bot's AI forgets everything after each deploy. User context vanishes. Channel conversations restart from zero. You've built something smart, but it has amnesia. Here's how to give your Slack AI bot persistent memory that survives restarts, deployments, and crashes.
The Problem: AI Bots Without Memory
Every time you deploy your Slack bot, it loses all context. The AI doesn't remember previous conversations, user preferences, or channel-specific settings. Your bot starts every interaction as if it's meeting users for the first time.
This happens because most Slack bots store state in memory (variables, objects) that disappears when the process restarts. Even if you're using sophisticated AI frameworks, they typically don't persist conversation history or user context between sessions.
The result? Users get frustrated repeating themselves. Your AI agent can't build on previous conversations. Channel-specific configurations reset. Multi-turn conversations break. You end up with a bot that feels disconnected and unhelpful.
Traditional solutions like databases require setup, schema design, and maintenance. Session caches expire. File storage doesn't scale across multiple bot instances.
The Fix: BotWire Memory
Install BotWire and add persistent memory in three lines:
pip install botwire
from botwire import Memory
# Create persistent memory for your Slack bot
memory = Memory("slack-bot-v1")
# Store user context
memory.set("user-12345-preferences", {"timezone": "PST", "notifications": True})
# Store channel state
memory.set("channel-general-context", {"last_topic": "deployment issues", "active_users": 15})
# Retrieve across restarts
user_prefs = memory.get("user-12345-preferences")
channel_context = memory.get("channel-general-context")
Your Slack chatbot state now persists forever. No database setup, no API keys, no configuration.
How It Works
BotWire provides a simple key-value store that survives process restarts. Your memory calls hit a persistent backend at https://botwire.dev — no signup required.
from botwire import Memory
class SlackBot:
def __init__(self):
self.memory = Memory("mybot-prod") # namespace isolates your data
def handle_message(self, user_id, channel_id, message):
# Get conversation history
history_key = f"conversation-{channel_id}"
history = self.memory.get(history_key) or []
# Add current message
history.append({"user": user_id, "text": message, "timestamp": time.time()})
# Store updated history
self.memory.set(history_key, history[-50:]) # keep last 50 messages
# Get user profile
user_profile = self.memory.get(f"user-{user_id}") or {"interactions": 0}
user_profile["interactions"] += 1
self.memory.set(f"user-{user_id}", user_profile)
Cross-process memory: If you run multiple bot instances, they all share the same memory namespace. User data stays consistent across all instances.
No TTL by default: Data persists until you delete it. For temporary data, clear it manually:
# Clean up old conversations
memory.delete(f"temp-session-{session_id}")
# List all keys (for debugging)
all_keys = memory.list_keys()
print(f"Stored {len(all_keys)} items")
This Slack bot memory pattern works for user preferences, conversation context, feature flags, or any state your AI agent needs to remember.
Slack Bolt Integration
If you're using Slack's Bolt framework, integrate BotWire memory directly into your event handlers:
from slack_bolt import App
from botwire import Memory
app = App(token="xoxb-your-token")
memory = Memory("slack-bolt-bot")
@app.message("help")
def handle_help(message, say):
user_id = message["user"]
channel_id = message["channel"]
# Track help requests per user
help_count_key = f"help-count-{user_id}"
count = memory.get(help_count_key) or 0
memory.set(help_count_key, count + 1)
# Get channel-specific help context
channel_context = memory.get(f"channel-{channel_id}-help") or {}
if count > 3:
say(f"You've asked for help {count} times. Let me connect you with a human.")
else:
say("Here's what I can help with...")
# Update channel help stats
channel_context["last_help_request"] = time.time()
memory.set(f"channel-{channel_id}-help", channel_context)
Your Slack AI agent now remembers every user interaction and channel context, even after restarts.
When NOT to Use BotWire
- Vector search: BotWire isn't a vector database. For semantic similarity or embeddings, use Pinecone or Weaviate.
- High-throughput apps: Free tier caps at 1000 writes/day per namespace. Heavy bots need the paid tier or self-hosting.
- Sub-millisecond latency: Network calls add ~50-200ms. For ultra-fast lookups, use in-memory caching alongside BotWire.
FAQ
Why not Redis? Redis requires setup, hosting, and maintenance. BotWire works immediately with zero configuration. For production scale, self-host BotWire or use managed Redis.
Is this actually free? Yes, forever. 1000 writes/day, 50MB storage per namespace, unlimited reads. No credit card, no trial period.
What about data privacy? Self-host the open-source version (MIT license) for full control. The hosted version doesn't require signup, so no personal data collection.
Get Started
Stop losing bot context on every deploy. Install BotWire and give your Slack AI persistent memory in minutes.
pip install botwire
Full docs and self-hosting guide: https://botwire.dev