Skip to content

Chatbots and automation

Build an OnlyFans chatbot on a real API

A chatbot needs two things: a stream of incoming messages and a way to answer them. BetterFans Link gives you both. One WebSocket delivers chat_message events from every creator you manage, each tagged with its account id, and a scoped client sends the reply. Wire in your own logic or an LLM in between.

chatbot.ts
const ws = new OfWsClient({
  apiKey: process.env.BFL_API_KEY,
  wsToken: process.env.BFL_WS_TOKEN,
  subscribe: ["chat_message"],
})

ws.onEnvelope("chat_message", async (ctx) => {
  if (!ctx.accountId) return
  const msg = ctx.payload.api2_chat_message
  const account = client.for(ctx.accountId)

  const reply = await yourBot.answer(msg.text) // rules, CRM, or an LLM

  await account.request("POST /chats/:id/messages", {
    pathParams: { id: msg.fromUser!.id.toString() },
    body: { text: reply },
  })
})

ws.connect()

Chatbot API

What's included

One connection, every account

The EventBus streams events from all managed creators over a single WebSocket, with automatic reconnection.

Account-scoped replies

client.for(accountId) returns a client bound to the account the message arrived on, so replies never cross wires.

Media in one call

The media plugin uploads a photo or video from a URL and hands back an id to attach, with deduplication built in.

Typing and presence

typing and online events let your bot behave like a person instead of answering instantly at 3am.

Bring your own brain

Rules, a CRM lookup, or an LLM: the SDK stays out of your decision logic and handles the OnlyFans side.

AI-assisted development

Every route and payload is typed, so Cursor, Claude Code and Copilot can autocomplete the whole bot.

FAQ

Frequently asked questions

Can I build an OnlyFans chatbot without scraping?

Yes. BetterFans Link exposes OnlyFans chats as a typed API and a real-time event stream, so your bot never drives a browser or parses pages. You subscribe to chat_message events, decide on a reply in your own code, and send it with a single request. Session management, proxies and reconnection are handled by the platform, which is what makes a bot stable enough to leave running.

How much code does an OnlyFans chatbot take?

The multi-account chatbot in our tutorial is about 50 lines of TypeScript. It opens one WebSocket, listens for new messages on every creator account, uploads a welcome image through the media plugin and sends a typed reply. Real bots grow from there with your own rules or model calls, but the OnlyFans plumbing stays roughly that size no matter how many accounts you add.

Can I connect an LLM like Claude or GPT to OnlyFans chats?

Yes. The SDK handles receiving and sending messages; what happens in between is your code. Pass the incoming text and any fan context you store to the model of your choice, then send its answer back with POST /chats/:id/messages. Many teams keep a human in the loop by drafting replies for chatters to approve instead of sending automatically.

Does the chatbot work across multiple creator accounts?

Yes. One EventBus connection receives events from every account your API key can act as. Each event carries the account id it came from, and client.for(accountId) gives you a client scoped to that creator for the reply. You can also filter the stream to specific account ids when a bot should only run for some creators.

LET’S BUILD SOMETHING BETTER

Your next big idea starts with a connection.

Build the tools your team has been waiting for. We’ll handle the connection to OnlyFans.

Your ideas. Your interface. BetterFans Link underneath.