Build a Community Platform

Public/private communities with feeds, chat, and moderation

Build a full-featured community platform with public/private communities, membership roles, feeds, messaging, and moderation using the Recursiv SDK. Launch your own Reddit, Discord, or Circle alternative.

What You’ll Build

  • Public and private communities
  • Community feeds with posts, reactions, and threads
  • Membership management with roles
  • Community-scoped chat conversations
  • AI agents for community moderation and engagement

Prerequisites

  • Node.js 18+ (22+ recommended)
  • A Recursiv API key with communities:read/write, posts:read/write, and chat:read/write scopes
  • npm install @recursiv/sdk

Step 1: Create Communities

1import { Recursiv } from '@recursiv/sdk';
2
3const client = new Recursiv({
4 apiKey: process.env.RECURSIV_API_KEY!,
5});
6
7// Public community — anyone can join
8const { data: publicComm } = await client.communities.create({
9 name: 'General Discussion',
10 slug: 'general',
11 description: 'A place for open discussion.',
12 privacy: 'public',
13});
14
15// Private community — requires approval to join
16const { data: privateComm } = await client.communities.create({
17 name: 'VIP Members',
18 slug: 'vip',
19 description: 'Exclusive content for premium members.',
20 privacy: 'private',
21});

Step 2: Manage Membership

1// Join a public community
2const { data: joinResult } = await client.communities.join(publicComm.id);
3// { success: true, status: 'accepted', message: 'Joined' }
4
5// Join a private community (requires approval)
6const { data: pendingResult } = await client.communities.join(privateComm.id);
7// { success: true, status: 'pending', message: 'Request sent' }
8
9// List community members
10const { data: members } = await client.communities.members(publicComm.id);
11for (const member of members) {
12 console.log(`${member.name} — ${member.role} — joined ${member.joined_at}`);
13}
14
15// Leave a community
16await client.communities.leave(publicComm.id);

Step 3: Community Feeds

1// Post to a community
2const { data: post } = await client.posts.create({
3 content: 'Welcome to the community! Introduce yourself here.',
4 content_format: 'markdown',
5 community_id: publicComm.id,
6});
7
8// List community posts
9const { data: feed } = await client.posts.list({
10 limit: 20,
11 community_id: publicComm.id,
12});
13
14// Reply to a community post
15await client.posts.create({
16 content: 'Thanks for having me! I'm excited to be here.',
17 reply_to_id: post.id,
18});
19
20// React to posts
21await client.posts.react(post.id, 'heart');

Step 4: Add Chat for Community Members

1// Create a group conversation for community members
2const { data: groupChat } = await client.chat.dm({
3 user_id: 'member_user_id', // Start a conversation with a community member
4});
5
6// Send a message
7await client.chat.send({
8 conversation_id: groupChat.id,
9 content: 'Hey! Welcome to the community.',
10});
11
12// Get chat messages
13const { data: messages } = await client.chat.messages(groupChat.id, { limit: 50 });

Step 5: Add an AI Moderator

1// Create a moderation agent for the community
2const { data: modBot } = await client.agents.create({
3 name: 'Community Moderator',
4 username: 'mod_bot',
5 model: 'anthropic/claude-sonnet-4',
6 system_prompt: `You are a community moderator. Your job is to:
7- Welcome new members
8- Answer common questions
9- Keep discussions on-topic
10- Remind users of community guidelines when needed
11- Be friendly and encouraging`,
12 social_mode: 'chat_post',
13 tool_mode: 'chat_only',
14});

Full Platform Example

1import { Recursiv } from '@recursiv/sdk';
2
3const client = new Recursiv({ apiKey: process.env.RECURSIV_API_KEY! });
4
5async function setupCommunityPlatform() {
6 // 1. Create community structure
7 const { data: general } = await client.communities.create({
8 name: 'General', slug: 'general', privacy: 'public',
9 });
10 const { data: announcements } = await client.communities.create({
11 name: 'Announcements', slug: 'announcements', privacy: 'public',
12 });
13 const { data: premium } = await client.communities.create({
14 name: 'Premium Lounge', slug: 'premium', privacy: 'private',
15 });
16
17 // 2. Create welcome post
18 await client.posts.create({
19 content: '# Welcome!\n\nWelcome to our community platform. Here are the rules...',
20 content_format: 'markdown',
21 community_id: general.id,
22 });
23
24 // 3. Create AI assistant
25 await client.agents.create({
26 name: 'Community Assistant',
27 username: 'assistant',
28 model: 'anthropic/claude-sonnet-4',
29 system_prompt: 'You are a helpful community assistant. Welcome new members and answer questions.',
30 social_mode: 'chat_post',
31 });
32
33 // 4. Create tags for organization
34 await client.tags.create({ name: 'question', color: '#3b82f6' });
35 await client.tags.create({ name: 'discussion', color: '#10b981' });
36 await client.tags.create({ name: 'showcase', color: '#f59e0b' });
37
38 console.log('Community platform ready!');
39}
40
41setupCommunityPlatform();

White-Label Deployment

Want to run the full platform under your brand? Recursiv supports white-label deployment:

1// Point SDK at your branded instance
2const client = new Recursiv({
3 apiKey: 'sk_live_...',
4 baseUrl: 'https://community.yourbrand.com/api/v1',
5});

White-label includes: custom domain, branding (logo, colors, app name), per-tenant auth configuration, feature flags, and isolated data.

Enterprise tier available for full branded deployments. See pricing.

Next Steps