Skip to content

πŸ“¨ The ultimate agentic social media scheduling tool πŸ€–

feat: moltbook

Nevo David47414acf29d3
diff --git a/apps/backend/src/api/routes/integrations.controller.ts b/apps/backend/src/api/routes/integrations.controller.ts
index 0a3ab0892..3c681245a 100644
--- a/apps/backend/src/api/routes/integrations.controller.ts
+++ b/apps/backend/src/api/routes/integrations.controller.ts
@@ -25,6 +25,7 @@ import { RefreshToken } from '@gitroom/nestjs-libraries/integrations/social.abst
import { timer } from '@gitroom/helpers/utils/timer';
import { TelegramProvider } from '@gitroom/nestjs-libraries/integrations/social/telegram.provider';
+import { MoltbookProvider } from '@gitroom/nestjs-libraries/integrations/social/moltbook.provider';
import {
AuthorizationActions,
Sections,
@@ -439,4 +440,32 @@ export class IntegrationsController {
async getUpdates(@Query() query: { word: string; id?: number }) {
return new TelegramProvider().getBotId(query);
}
+
+ @Post('/moltbook/register')
+ async moltbookRegister(
+ @Body() body: { name: string; description: string }
+ ) {
+ try {
+ const provider = new MoltbookProvider();
+ const result = await provider.registerAgent(body.name, body.description);
+ return {
+ apiKey: result.api_key,
+ claimUrl: result.claim_url,
+ verificationCode: result.verification_code,
+ };
+ } catch (err: any) {
+ return { error: err.message || 'Registration failed' };
+ }
+ }
+
+ @Get('/moltbook/status')
+ async moltbookStatus(@Query('apiKey') apiKey: string) {
+ try {
+ const provider = new MoltbookProvider();
+ const result = await provider.checkAgentStatus(apiKey);
+ return { claimed: result?.status === 'claimed' };
+ } catch (err) {
+ return { claimed: false };
+ }
+ }
}
diff --git a/apps/frontend/public/icons/platforms/moltbook.png b/apps/frontend/public/icons/platforms/moltbook.png
new file mode 100644
index 000000000..644b7d1e0
Binary files /dev/null and b/apps/frontend/public/icons/platforms/moltbook.png differ
diff --git a/apps/frontend/src/components/launches/add.provider.component.tsx b/apps/frontend/src/components/launches/add.provider.component.tsx
index 20aef1115..db11ae2f2 100644
--- a/apps/frontend/src/components/launches/add.provider.component.tsx
+++ b/apps/frontend/src/components/launches/add.provider.component.tsx
@@ -18,6 +18,7 @@ import { web3List } from '@gitroom/frontend/components/launches/web3/web3.list';
import { useT } from '@gitroom/react/translation/get.transation.service.client';
import clsx from 'clsx';
import copy from 'copy-to-clipboard';
+import { capitalize } from 'lodash';
const resolver = classValidatorResolver(ApiKeyDto);
export const useAddProvider = (update?: () => void, invite?: boolean) => {
@@ -306,7 +307,7 @@ export const AddProviderComponent: FC<{
)
).json();
modal.openModal({
- title: t('web3_provider', 'Web3 provider'),
+ title: `Add ${capitalize(identifier)}`,
withCloseButton: true,
classNames: {
modal: 'bg-transparent text-textColor',
diff --git a/apps/frontend/src/components/launches/web3/providers/moltbook.provider.tsx b/apps/frontend/src/components/launches/web3/providers/moltbook.provider.tsx
new file mode 100644
index 000000000..479b5e23d
--- /dev/null
+++ b/apps/frontend/src/components/launches/web3/providers/moltbook.provider.tsx
@@ -0,0 +1,174 @@
+'use client';
+
+import React, { FC, useCallback, useEffect, useRef, useState } from 'react';
+import { Web3ProviderInterface } from '@gitroom/frontend/components/launches/web3/web3.provider.interface';
+import { useFetch } from '@gitroom/helpers/utils/custom.fetch';
+import { timer } from '@gitroom/helpers/utils/timer';
+import { Input } from '@gitroom/react/form/input';
+import { Button } from '@gitroom/react/form/button';
+import copy from 'copy-to-clipboard';
+import { useToaster } from '@gitroom/react/toaster/toaster';
+import { useT } from '@gitroom/react/translation/get.transation.service.client';
+
+export const MoltbookProvider: FC<Web3ProviderInterface> = (props) => {
+ const { onComplete, nonce } = props;
+ const fetch = useFetch();
+ const stop = useRef(false);
+ const [step, setStep] = useState<'init' | 'registering' | 'waiting' | 'error'>('init');
+ const [agentName, setAgentName] = useState('');
+ const [agentDescription, setAgentDescription] = useState('');
+ const [claimUrl, setClaimUrl] = useState('');
+ const [apiKey, setApiKey] = useState('');
+ const [error, setError] = useState('');
+ const toaster = useToaster();
+ const t = useT();
+
+ const register = async () => {
+ if (!agentName.trim()) {
+ toaster.show('Please enter an agent name', 'warning');
+ return;
+ }
+
+ setStep('registering');
+ setError('');
+
+ try {
+ const response = await fetch('/integrations/moltbook/register', {
+ method: 'POST',
+ body: JSON.stringify({
+ name: agentName.trim(),
+ description: agentDescription.trim() || 'Postiz social media scheduler',
+ }),
+ });
+
+ const data = await response.json();
+
+ if (data.error) {
+ setError(data.error);
+ setStep('error');
+ return;
+ }
+
+ setApiKey(data.apiKey);
+ setClaimUrl(data.claimUrl);
+ setStep('waiting');
+
+ pollForClaim(data.apiKey);
+ } catch (err) {
+ setError('Failed to register agent');
+ setStep('error');
+ }
+ };
+
+ const pollForClaim = async (key: string) => {
+ stop.current = false;
+
+ while (!stop.current) {
+ try {
+ const response = await fetch(`/integrations/moltbook/status?apiKey=${encodeURIComponent(key)}`);
+ const data = await response.json();
+
+ if (data.claimed) {
+ onComplete(key, nonce);
+ return;
+ }
+ } catch (err) {
+ // Continue polling
+ }
+
+ await timer(3000);
+ }
+ };
+
+ const copyClaimUrl = useCallback(() => {
+ copy(claimUrl);
+ toaster.show('Claim URL copied to clipboard', 'success');
+ }, [claimUrl, toaster]);
+
+ useEffect(() => {
+ return () => {
+ stop.current = true;
+ };
+ }, []);
+
+ return (
+ <div className="justify-center items-center flex flex-col pt-[16px]">
+ {step === 'init' && (
+ <>
+ <div className="text-center mb-[16px]">
+ {t('moltbook_register_description', 'Register your Moltbook agent to connect:')}
+ </div>
+ <div className="w-full space-y-[12px]">
+ <Input
+ label={t('agent_name', 'Agent Name')}
+ value={agentName}
+ name="agentName"
+ disableForm={true}
+ onChange={(e) => setAgentName(e.target.value)}
+ placeholder="MyPostizAgent"
+ />
+ <Input
+ label={t('description_optional', 'Description (optional)')}
+ value={agentDescription}
+ name="agentDescription"
+ disableForm={true}
+ onChange={(e) => setAgentDescription(e.target.value)}
+ placeholder="Social media scheduler"
+ />
+ <Button className="w-full" onClick={register}>
+ {t('register_agent', 'Register Agent')}
+ </Button>
+ </div>
+ </>
+ )}
+
+ {step === 'registering' && (
+ <div className="text-center">
+ {t('registering_agent', 'Registering agent...')}
+ </div>
+ )}
+
+ {step === 'waiting' && (
+ <div className="w-full text-center">
+ <div className="mb-[16px]">
+ {t('moltbook_claim_instructions', 'Please visit the claim URL to verify your agent:')}
+ </div>
+ <div className="flex gap-[8px]">
+ <div className="flex-1">
+ <Input
+ label=""
+ value={claimUrl}
+ name="claimUrl"
+ disableForm={true}
+ readOnly
+ />
+ </div>
+ <Button onClick={copyClaimUrl}>{t('copy', 'Copy')}</Button>
+ </div>
+ <div className="mt-[16px] text-sm opacity-70">
+ {t('waiting_for_claim', 'Waiting for you to claim your agent...')}
+ </div>
+ <div className="mt-[8px]">
+ <a
+ href={claimUrl}
+ target="_blank"
+ rel="noopener noreferrer"
+ className="text-blue-500 hover:underline"
+ >
+ {t('open_claim_page', 'Open claim page')}
+ </a>
+ </div>
+ </div>
+ )}
+
+ {step === 'error' && (
+ <div className="w-full text-center">
+ <div className="text-red-500 mb-[16px]">{error}</div>
+ <Button onClick={() => setStep('init')}>
+ {t('try_again', 'Try Again')}
+ </Button>
+ </div>
+ )}
+ </div>
+ );
+};
diff --git a/apps/frontend/src/components/launches/web3/web3.list.tsx b/apps/frontend/src/components/launches/web3/web3.list.tsx
index 278da2dc1..5e68f261d 100644
--- a/apps/frontend/src/components/launches/web3/web3.list.tsx
+++ b/apps/frontend/src/components/launches/web3/web3.list.tsx
@@ -2,6 +2,7 @@ import { FC } from 'react';
import { Web3ProviderInterface } from '@gitroom/frontend/components/launches/web3/web3.provider.interface';
import { WrapcasterProvider } from '@gitroom/frontend/components/launches/web3/providers/wrapcaster.provider';
import { TelegramProvider } from '@gitroom/frontend/components/launches/web3/providers/telegram.provider';
+import { MoltbookProvider } from '@gitroom/frontend/components/launches/web3/providers/moltbook.provider';
export const web3List: {
identifier: string;
component: FC<Web3ProviderInterface>;
@@ -14,4 +15,8 @@ export const web3List: {
identifier: 'wrapcast',
component: WrapcasterProvider,
},
+ {
+ identifier: 'moltbook',
+ component: MoltbookProvider,
+ },
];
diff --git a/apps/frontend/src/components/new-launch/providers/moltbook/moltbook.provider.tsx b/apps/frontend/src/components/new-launch/providers/moltbook/moltbook.provider.tsx
new file mode 100644
index 000000000..a6e2fb9b5
--- /dev/null
+++ b/apps/frontend/src/components/new-launch/providers/moltbook/moltbook.provider.tsx
@@ -0,0 +1,35 @@
+'use client';
+
+import { FC } from 'react';
+import {
+ PostComment,
+ withProvider,
+} from '@gitroom/frontend/components/new-launch/providers/high.order.provider';
+import { MoltbookDto } from '@gitroom/nestjs-libraries/dtos/posts/providers-settings/moltbook.dto';
+import { useSettings } from '@gitroom/frontend/components/launches/helpers/use.values';
+import { Input } from '@gitroom/react/form/input';
+import { useT } from '@gitroom/react/translation/get.transation.service.client';
+
+const MoltbookSettings: FC = () => {
+ const form = useSettings();
+ const t = useT();
+
+ return (
+ <div>
+ <Input
+ label={t('submolt', 'Submolt')}
+ placeholder="general"
+ {...form.register('submolt')}
+ />
+ </div>
+ );
+};
+
+export default withProvider({
+ postComment: PostComment.COMMENT,
+ minimumCharacters: [],
+ SettingsComponent: MoltbookSettings,
+ CustomPreviewComponent: undefined,
+ dto: MoltbookDto,
+ maximumCharacters: 300,
+});
diff --git a/apps/frontend/src/components/new-launch/providers/show.all.providers.tsx b/apps/frontend/src/components/new-launch/providers/show.all.providers.tsx
index 29a71721b..09fbc0fab 100644
--- a/apps/frontend/src/components/new-launch/providers/show.all.providers.tsx
+++ b/apps/frontend/src/components/new-launch/providers/show.all.providers.tsx
@@ -35,6 +35,7 @@ import { PostComment } from '@gitroom/frontend/components/new-launch/providers/h
import WordpressProvider from '@gitroom/frontend/components/new-launch/providers/wordpress/wordpress.provider';
import ListmonkProvider from '@gitroom/frontend/components/new-launch/providers/listmonk/listmonk.provider';
import GmbProvider from '@gitroom/frontend/components/new-launch/providers/gmb/gmb.provider';
+import MoltbookProvider from '@gitroom/frontend/components/new-launch/providers/moltbook/moltbook.provider';
export const Providers = [
{
@@ -153,6 +154,10 @@ export const Providers = [
identifier: 'gmb',
component: GmbProvider,
},
+ {
+ identifier: 'moltbook',
+ component: MoltbookProvider,
+ }
];
export const ShowAllProviders = forwardRef((props, ref) => {
const { date, current, global, selectedIntegrations, allIntegrations } =
diff --git a/libraries/nestjs-libraries/src/dtos/posts/create.post.dto.ts b/libraries/nestjs-libraries/src/dtos/posts/create.post.dto.ts
index 2e5ce3ea2..21001e4cd 100644
--- a/libraries/nestjs-libraries/src/dtos/posts/create.post.dto.ts
+++ b/libraries/nestjs-libraries/src/dtos/posts/create.post.dto.ts
@@ -8,7 +8,6 @@ import {
IsNumber,
IsOptional,
IsString,
- MinLength,
Validate,
ValidateIf,
ValidateNested,
diff --git a/libraries/nestjs-libraries/src/dtos/posts/providers-settings/all.providers.settings.ts b/libraries/nestjs-libraries/src/dtos/posts/providers-settings/all.providers.settings.ts
index a0c7f98c7..2bce9a69b 100644
--- a/libraries/nestjs-libraries/src/dtos/posts/providers-settings/all.providers.settings.ts
+++ b/libraries/nestjs-libraries/src/dtos/posts/providers-settings/all.providers.settings.ts
@@ -20,6 +20,7 @@ import { ListmonkDto } from '@gitroom/nestjs-libraries/dtos/posts/providers-sett
import { GmbSettingsDto } from '@gitroom/nestjs-libraries/dtos/posts/providers-settings/gmb.settings.dto';
import { FarcasterDto } from '@gitroom/nestjs-libraries/dtos/posts/providers-settings/farcaster.dto';
import { FacebookDto } from '@gitroom/nestjs-libraries/dtos/posts/providers-settings/facebook.dto';
+import { MoltbookDto } from '@gitroom/nestjs-libraries/dtos/posts/providers-settings/moltbook.dto';
export type ProviderExtension<T extends string, M> = { __type: T } & M;
export type AllProvidersSettings =
@@ -51,6 +52,7 @@ export type AllProvidersSettings =
| ProviderExtension<'bluesky', None>
| ProviderExtension<'telegram', None>
| ProviderExtension<'nostr', None>
+ | ProviderExtension<'moltbook', MoltbookDto>
| ProviderExtension<'vk', None>;
type None = NonNullable<unknown>;
@@ -86,6 +88,7 @@ export const allProviders = (setEmpty?: any) => {
{ value: setEmpty, name: 'telegram' },
{ value: setEmpty, name: 'nostr' },
{ value: setEmpty, name: 'vk' },
+ { value: MoltbookDto, name: 'moltbook' },
].filter((f) => f.value);
};
diff --git a/libraries/nestjs-libraries/src/dtos/posts/providers-settings/moltbook.dto.ts b/libraries/nestjs-libraries/src/dtos/posts/providers-settings/moltbook.dto.ts
new file mode 100644
index 000000000..2d6977971
--- /dev/null
+++ b/libraries/nestjs-libraries/src/dtos/posts/providers-settings/moltbook.dto.ts
@@ -0,0 +1,8 @@
+import { IsDefined, IsString, MinLength } from 'class-validator';
+
+export class MoltbookDto {
+ @MinLength(1)
+ @IsDefined()
+ @IsString()
+ submolt: string;
+}
diff --git a/libraries/nestjs-libraries/src/integrations/integration.manager.ts b/libraries/nestjs-libraries/src/integrations/integration.manager.ts
index 4e1d2f4ef..0bb783386 100644
--- a/libraries/nestjs-libraries/src/integrations/integration.manager.ts
+++ b/libraries/nestjs-libraries/src/integrations/integration.manager.ts
@@ -32,6 +32,7 @@ import { GmbProvider } from '@gitroom/nestjs-libraries/integrations/social/gmb.p
import { KickProvider } from '@gitroom/nestjs-libraries/integrations/social/kick.provider';
import { TwitchProvider } from '@gitroom/nestjs-libraries/integrations/social/twitch.provider';
import { SocialAbstract } from '@gitroom/nestjs-libraries/integrations/social.abstract';
+import { MoltbookProvider } from '@gitroom/nestjs-libraries/integrations/social/moltbook.provider';
export const socialIntegrationList: Array<SocialAbstract & SocialProvider> = [
new XProvider(),
@@ -63,6 +64,7 @@ export const socialIntegrationList: Array<SocialAbstract & SocialProvider> = [
new HashnodeProvider(),
new WordpressProvider(),
new ListmonkProvider(),
+ new MoltbookProvider(),
// new MastodonCustomProvider(),
];
diff --git a/libraries/nestjs-libraries/src/integrations/social/moltbook.provider.ts b/libraries/nestjs-libraries/src/integrations/social/moltbook.provider.ts
new file mode 100644
index 000000000..50d44445d
--- /dev/null
+++ b/libraries/nestjs-libraries/src/integrations/social/moltbook.provider.ts
@@ -0,0 +1,195 @@
+import {
+ AuthTokenDetails,
+ PostDetails,
+ PostResponse,
+ SocialProvider,
+} from '@gitroom/nestjs-libraries/integrations/social/social.integrations.interface';
+import { makeId } from '@gitroom/nestjs-libraries/services/make.is';
+import { SocialAbstract } from '@gitroom/nestjs-libraries/integrations/social.abstract';
+import dayjs from 'dayjs';
+import { Integration } from '@prisma/client';
+import axios from 'axios';
+
+const MOLTBOOK_API_BASE = 'https://www.moltbook.com/api/v1';
+
+export class MoltbookProvider extends SocialAbstract implements SocialProvider {
+ override maxConcurrentJob = 100; // Moltbook: 100 requests/minute
+ identifier = 'moltbook';
+ name = 'Moltbook';
+ isBetweenSteps = false;
+ scopes = [] as string[];
+ isWeb3 = true;
+ editor = 'normal' as const;
+
+ maxLength() {
+ return 300;
+ }
+
+ async refreshToken(refreshToken: string): Promise<AuthTokenDetails> {
+ return {
+ refreshToken: '',
+ expiresIn: 0,
+ accessToken: '',
+ id: '',
+ name: '',
+ picture: '',
+ username: '',
+ };
+ }
+
+ async generateAuthUrl() {
+ const state = makeId(6);
+ return {
+ url: state,
+ codeVerifier: makeId(10),
+ state,
+ };
+ }
+
+ async registerAgent(name: string, description: string) {
+ const response = await axios.post(
+ `${MOLTBOOK_API_BASE}/agents/register`,
+ { name, description },
+ { headers: { 'Content-Type': 'application/json' } }
+ );
+
+ if (!response.data.success) {
+ throw new Error(response.data.error || 'Registration failed');
+ }
+
+ return response.data.agent;
+ }
+
+ async checkAgentStatus(apiKey: string) {
+ const response = await axios.get(`${MOLTBOOK_API_BASE}/agents/status`, {
+ headers: { Authorization: `Bearer ${apiKey}` },
+ });
+
+ return response.data;
+ }
+
+ async getAgentProfile(apiKey: string) {
+ const response = await axios.get(`${MOLTBOOK_API_BASE}/agents/me`, {
+ headers: { Authorization: `Bearer ${apiKey}` },
+ });
+
+ if (!response.data.success) {
+ throw new Error(response.data.error || 'Failed to get profile');
+ }
+
+ return response.data.agent;
+ }
+
+ async authenticate(params: {
+ code: string;
+ codeVerifier: string;
+ refresh?: string;
+ }) {
+ const apiKey = params.code;
+
+ const profile = await this.getAgentProfile(apiKey);
+
+ return {
+ id: profile.name || profile.id,
+ name: profile.display_name || profile.name,
+ accessToken: apiKey,
+ refreshToken: '',
+ expiresIn: dayjs().add(200, 'year').unix() - dayjs().unix(),
+ picture: '',
+ username: profile.name,
+ };
+ }
+
+ async post(
+ id: string,
+ accessToken: string,
+ postDetails: PostDetails[],
+ integration: Integration
+ ): Promise<PostResponse[]> {
+ const results: PostResponse[] = [];
+
+ for (const post of postDetails) {
+ const postData: {
+ submolt: string;
+ title: string;
+ content?: string;
+ url?: string;
+ } = {
+ submolt: post.settings?.submolt || 'general',
+ title: post.message.slice(0, 100),
+ content: post.message,
+ };
+
+ const response = await axios.post(
+ `${MOLTBOOK_API_BASE}/posts`,
+ postData,
+ {
+ headers: {
+ Authorization: `Bearer ${accessToken}`,
+ 'Content-Type': 'application/json',
+ },
+ }
+ );
+
+ if (!response.data.success) {
+ throw new Error(response.data.error || 'Failed to create post');
+ }
+
+ const postId = response.data.post.id;
+ results.push({
+ id: post.id,
+ postId: String(postId),
+ releaseURL: `https://www.moltbook.com/post/${postId}`,
+ status: 'completed',
+ });
+ }
+
+ return results;
+ }
+
+ async comment(
+ id: string,
+ postId: string,
+ lastCommentId: string | undefined,
+ accessToken: string,
+ postDetails: PostDetails[],
+ integration: Integration
+ ): Promise<PostResponse[]> {
+ const results: PostResponse[] = [];
+
+ for (const post of postDetails) {
+ const commentData: { content: string; parent_id?: string } = {
+ content: post.message,
+ };
+
+ if (lastCommentId) {
+ commentData.parent_id = lastCommentId;
+ }
+
+ const response = await axios.post(
+ `${MOLTBOOK_API_BASE}/posts/${postId}/comments`,
+ commentData,
+ {
+ headers: {
+ Authorization: `Bearer ${accessToken}`,
+ 'Content-Type': 'application/json',
+ },
+ }
+ );
+
+ if (!response.data.success) {
+ throw new Error(response.data.error || 'Failed to create comment');
+ }
+
+ const commentId = response.data.comment.id;
+ results.push({
+ id: post.id,
+ postId: String(commentId),
+ releaseURL: `https://www.moltbook.com/post/${postId}`,
+ status: 'completed',
+ });
+ }
+
+ return results;
+ }
+}