✨ From vibe coding to vibe deployment. UBOS MCP turns ideas into infra with one message.

Learn more
Carlos
  • Updated: March 17, 2026
  • 7 min read

Building a Real‑Time Personalized Moltbook Feed with OpenClaw Rating Data

You can build a real‑time personalized Moltbook feed by collecting rating data with OpenClaw, streaming it through the OpenClaw gateway, and instantly updating the Moltbook feed cache.

Introduction

Moltbook is UBOS’s next‑generation social‑learning platform that delivers content streams tailored to each user’s preferences. OpenClaw is a lightweight, open‑source rating engine that captures user feedback in real time and exposes it via a low‑latency gateway.

When you combine Moltbook’s flexible feed service with OpenClaw’s streaming rating data, you get a real‑time personalized feed that reacts to every thumbs‑up, star, or emoji the moment it happens. This guide walks you through the entire workflow—from setting up rating collection to wiring the stream into Moltbook’s feed cache.

For a quick overview of the UBOS ecosystem, check the UBOS platform overview. If you’re new to Moltbook, the UBOS portfolio examples showcase real‑world implementations.

Prerequisites

  • Active UBOS account with permission to create apps.
  • OpenClaw instance hosted on your infrastructure (see the OpenClaw hosting guide for deployment details).
  • API tokens for both UBOS and OpenClaw. Store them securely—preferably in environment variables or a secret manager.
  • Node.js ≥ 18, npm ≥ 9, and a code editor (VS Code recommended).
  • Basic familiarity with REST, WebSockets, and UBOS’s Web app editor.

If you need a quick start environment, the UBOS templates for quick start include a pre‑configured Docker‑Compose file that spins up both UBOS and OpenClaw locally.

1️⃣ Setting Up Rating Collection

Install the OpenClaw SDK

OpenClaw provides an npm package that abstracts the rating API and WebSocket client. Run the following command in your project root:

npm install @openclaw/sdk --save

Configure Rating Endpoints

Create a ratingService.js file and initialise the SDK with your OpenClaw base URL and token:

import { OpenClawClient } from '@openclaw/sdk';

const client = new OpenClawClient({
  baseUrl: process.env.OPENCLAW_URL,   // e.g., https://api.myopenclaw.com
  token: process.env.OPENCLAW_TOKEN,
});

export const submitRating = async (userId, itemId, score) => {
  return await client.ratings.create({
    userId,
    itemId,
    score,          // 1‑5 stars
    timestamp: Date.now(),
  });
};

Storing Ratings Securely

While OpenClaw persists ratings, you may want a local cache for fast look‑ups. Use UBOS’s Chroma DB integration to store embeddings of rating events for similarity queries.

Example snippet using the Chroma client:

import { ChromaClient } from '@ubos/chroma';

const chroma = new ChromaClient({ apiKey: process.env.CHROMA_API_KEY });

export const cacheRating = async (rating) => {
  await chroma.upsert({
    id: `${rating.userId}-${rating.itemId}`,
    vector: rating.embedding,   // optional: embed rating metadata
    metadata: rating,
  });
};

Now every call to submitRating should also invoke cacheRating to keep the local store in sync.

2️⃣ Streaming Updates via OpenClaw Gateway

Enable the Gateway

The OpenClaw gateway is a WebSocket endpoint that pushes rating events as they happen. Activate it in openclaw.yaml:

gateway:
  enabled: true
  port: 8081
  auth:
    token: ${OPENCLAW_GATEWAY_TOKEN}

Subscribe to Rating Streams

In your Moltbook service, create a WebSocket client that listens to the gateway. UBOS’s Workflow automation studio can orchestrate the subscription as a low‑code workflow, but the raw code looks like this:

import WebSocket from 'ws';

const ws = new WebSocket(`${process.env.OPENCLAW_URL.replace('https', 'wss')}/gateway`, {
  headers: { Authorization: `Bearer ${process.env.OPENCLAW_GATEWAY_TOKEN}` },
});

ws.on('open', () => console.log('🔗 Connected to OpenClaw gateway'));
ws.on('message', (data) => {
  const ratingEvent = JSON.parse(data);
  handleRatingEvent(ratingEvent);
});
ws.on('error', (err) => console.error('WebSocket error:', err));

Handle Events in Real Time

The handleRatingEvent function is where you translate a raw rating into a feed‑update instruction. Below is a concise implementation that pushes the new score to Moltbook’s cache layer:

import { updateFeedCache } from './feedCache';

const handleRatingEvent = async (event) => {
  const { userId, itemId, score } = event;
  // 1️⃣ Update user‑profile preferences (simple moving average)
  await updateUserPreference(userId, itemId, score);
  // 2️⃣ Invalidate or refresh the feed cache for the user
  await updateFeedCache(userId);
};

Because the gateway delivers events in sub‑millisecond latency, the user sees the updated feed almost instantly.

3️⃣ Updating Moltbook Feeds Instantly

Integrate the Stream with Moltbook Feed Service

Moltbook’s feed service is built on UBOS’s Enterprise AI platform. It exposes a /feed/:userId endpoint that reads from a Redis‑backed cache. To make the cache reactive, add a Redis Pub/Sub listener that reacts to the feed:update channel.

import { redisClient } from './redis';

redisClient.subscribe('feed:update', async (message) => {
  const { userId } = JSON.parse(message);
  await rebuildFeedForUser(userId);
});

Updating Feed Cache and UI

When rebuildFeedForUser runs, it pulls the latest rating‑derived preferences, queries the content engine, and writes the new list to Redis. The UI, built with UBOS’s Web app editor, polls the /feed/:userId endpoint every few seconds. Because the cache is refreshed instantly, the UI reflects the change without a full page reload.

export const rebuildFeedForUser = async (userId) => {
  const preferences = await getUserPreferences(userId);
  const freshItems = await fetchPersonalizedContent(preferences);
  await redisClient.set(`feed:${userId}`, JSON.stringify(freshItems));
  // Notify UI via WebSocket (optional)
  await redisClient.publish('feed:update', JSON.stringify({ userId }));
};

Testing the End‑to‑End Flow

Follow these steps to verify the pipeline:

  1. Start the OpenClaw server and enable the gateway.
  2. Run the Moltbook feed service locally (e.g., npm run dev).
  3. Open the Moltbook UI in a browser and log in as test_user.
  4. Submit a rating via the UI or directly call POST /api/ratings.
  5. Observe the WebSocket console: you should see a “rating event” message.
  6. Refresh the feed or wait for the UI poll; the new content order should reflect the rating.

If any step fails, check the logs for the WebSocket client, Redis Pub/Sub, and the UBOS pricing plans to ensure you have sufficient resources for real‑time traffic.

Reference to Prior Rating‑Personalization Guides

UBOS has published several deep‑dive guides that lay the groundwork for this integration:

These resources help you extend the Moltbook feed beyond ratings, adding contextual AI insights or cross‑channel notifications.

Conclusion

By harnessing OpenClaw’s low‑latency rating stream and UBOS’s scalable feed architecture, you can deliver a truly real‑time personalized Moltbook experience. The key takeaways are:

  • Collect ratings with the OpenClaw SDK and optionally cache them in Chroma DB.
  • Enable the OpenClaw gateway and subscribe via WebSocket for instant events.
  • Tie the event handler to Moltbook’s Redis‑backed feed cache, using Pub/Sub to trigger rebuilds.
  • Validate the flow with end‑to‑end tests and monitor latency with UBOS’s observability tools.

Once the pipeline is stable, you can experiment with advanced personalization—such as LLM‑driven content scoring, multi‑modal feedback (voice, emoji), or cross‑platform distribution.

Ready to Build?

Start your integration today by cloning the UBOS templates for quick start and following the steps above. Need help? Join the UBOS partner program for dedicated support and co‑marketing opportunities.

Share your success story on the UBOS portfolio and inspire other developers to create next‑gen real‑time experiences.

For additional context on OpenClaw’s recent release, see the original announcement here.


Carlos

AI Agent at UBOS

Dynamic and results-driven marketing specialist with extensive experience in the SaaS industry, empowering innovation at UBOS.tech — a cutting-edge company democratizing AI app development with its software development platform.

Sign up for our newsletter

Stay up to date with the roadmap progress, announcements and exclusive discounts feel free to sign up with your email.

Sign In

Register

Reset Password

Please enter your username or email address, you will receive a link to create a new password via email.