Files
t66_langmem/matrix_notifier.py
Docker Config Backup 46faa78237 Initial commit: LangMem fact-based AI memory system with docs and MCP integration
- Complete fact-based memory API with mem0-inspired approach
- Individual fact extraction and deduplication
- ADD/UPDATE/DELETE memory actions
- Precision search with 0.86+ similarity scores
- MCP server for Claude Code integration
- Neo4j graph relationships and PostgreSQL vector storage
- Comprehensive documentation with architecture and API docs
- Matrix communication integration
- Production-ready Docker setup with Ollama and Supabase

🤖 Generated with [Claude Code](https://claude.ai/code)

Co-Authored-By: Claude <noreply@anthropic.com>
2025-07-17 13:16:19 +02:00

67 lines
2.0 KiB
Python

#!/usr/bin/env python3
"""
Simple Matrix message sender for LangMem notifications
"""
import asyncio
import json
import sys
import httpx
# Matrix configuration
MATRIX_HOMESERVER = "https://matrix.klas.chat"
MATRIX_ACCESS_TOKEN = "syt_a2xhcw_ZcjbRgfRFEdMHnutAVOa_1M7eD4"
HOME_ASSISTANT_ROOM_ID = "!xZkScMybPseErYMJDz:matrix.klas.chat"
async def send_matrix_notification(message: str) -> bool:
"""Send notification to Matrix Home Assistant room"""
headers = {
"Authorization": f"Bearer {MATRIX_ACCESS_TOKEN}",
"Content-Type": "application/json"
}
message_data = {
"msgtype": "m.text",
"body": message
}
try:
async with httpx.AsyncClient() as client:
response = await client.post(
f"{MATRIX_HOMESERVER}/_matrix/client/v3/rooms/{HOME_ASSISTANT_ROOM_ID}/send/m.room.message",
headers=headers,
json=message_data,
timeout=30.0
)
if response.status_code == 200:
data = response.json()
print(f"✅ Matrix notification sent: {data.get('event_id')}")
return True
else:
print(f"❌ Failed to send Matrix notification: {response.status_code}")
print(f"Response: {response.text}")
return False
except Exception as e:
print(f"❌ Error sending Matrix notification: {e}")
return False
async def main():
"""Main function"""
if len(sys.argv) > 1:
message = " ".join(sys.argv[1:])
else:
message = "📋 Matrix notification test - please confirm you received this message"
print(f"📤 Sending: {message}")
success = await send_matrix_notification(message)
if success:
print("🎉 Matrix notification sent successfully!")
print("💬 Please check your Home Assistant room in Matrix")
else:
print("❌ Failed to send Matrix notification")
if __name__ == "__main__":
asyncio.run(main())