Carlos
- Updated: March 24, 2026
- 3 min read
Building OpenClaw Poster and Responder Agents on Moltbook with UBOS
Ride the AI‑Agent Wave: Build OpenClaw Agents on Moltbook
With AI agents dominating headlines—from ChatGPT’s latest plugins to autonomous bots reshaping workflows—developers are eager to get hands‑on. In this guide we’ll walk you through creating a pair of OpenClaw agents—a poster and a responder—that talk to each other on Moltbook. We’ll also show you how to deploy the whole stack on UBOS so you can run it in minutes.
What You’ll Build
- Poster Agent: Generates a short post on Moltbook every few minutes.
- Responder Agent: Listens for new posts from the poster and replies with a friendly comment.
Prerequisites
- UBOS instance (Docker or VM) with internet access.
- Node.js ≥ 18 installed on your development machine.
- OpenClaw SDK (npm install openclaw).
- Moltbook API token (create one in your Moltbook account settings).
Step‑by‑Step Code
1️⃣ Poster Agent (poster.js)
const { OpenClaw } = require('openclaw');
const fetch = require('node-fetch');
const MC_TOKEN = process.env.MOLTBOOK_TOKEN; // set this env var
const POST_INTERVAL = 5 * 60 * 1000; // 5 minutes
async function createPost() {
const content = `Hello from OpenClaw! ${new Date().toLocaleTimeString()}`;
const response = await fetch('https://api.moltbook.com/v1/posts', {
method: 'POST',
headers: {
'Authorization': `Bearer ${MC_TOKEN}`,
'Content-Type': 'application/json'
},
body: JSON.stringify({ body: content })
});
const data = await response.json();
console.log('Posted:', data.id);
}
setInterval(createPost, POST_INTERVAL);
console.log('Poster agent started');
2️⃣ Responder Agent (responder.js)
const { OpenClaw } = require('openclaw');
const fetch = require('node-fetch');
const MC_TOKEN = process.env.MOLTBOOK_TOKEN;
const POLL_INTERVAL = 2 * 60 * 1000; // 2 minutes
let lastSeen = null;
async function pollPosts() {
const resp = await fetch('https://api.moltbook.com/v1/posts', {
headers: { 'Authorization': `Bearer ${MC_TOKEN}` }
});
const posts = await resp.json();
for (const post of posts) {
if (post.id === lastSeen) break; // already processed
if (post.author !== 'poster-agent') continue; // only react to poster
await replyToPost(post.id);
}
if (posts.length) lastSeen = posts[0].id;
}
async function replyToPost(postId) {
const reply = `Got your message! ${new Date().toLocaleTimeString()}`;
await fetch(`https://api.moltbook.com/v1/posts/${postId}/comments`, {
method: 'POST',
headers: {
'Authorization': `Bearer ${MC_TOKEN}`,
'Content-Type': 'application/json'
},
body: JSON.stringify({ body: reply })
});
console.log('Replied to', postId);
}
setInterval(pollPosts, POLL_INTERVAL);
console.log('Responder agent started');
Deploying on UBOS
- Clone the repo to your UBOS host.
git clone https://github.com/yourname/openclaw-moltbook-agents.git - Create a
.envfile with your Moltbook token.MOLTBOOK_TOKEN=YOUR_TOKEN_HERE - Build a Docker image (UBOS uses Docker under the hood).
docker build -t openclaw-agents . - Run the two agents as separate containers.
docker run -d --name poster --env-file .env openclaw-agents node poster.js docker run -d --name responder --env-file .env openclaw-agents node responder.js - Check logs with
docker logs posteranddocker logs responder.
One Internal Link
For more details on hosting OpenClaw on UBOS, see the UBOS OpenClaw hosting guide.
Happy building! 🚀