# Fansly AI Chatbot Infrastructure: API, Webhooks and an LLM

> Build a responsive Fansly AI chatbot using event-driven infrastructure. Connect LLMs to your workflow using OnlyFansAPI webhooks and secure REST API endpoints.

**TL;DR**

- A reliable Fansly chatbot relies on the `fansly.messages.received` webhook to trigger responses rather than polling the inbox.
- Your LLM sits on your own servers or in an AI client connected to our Model Context Protocol (MCP) server, separate from the API infrastructure.
- The core chat loop uses Fansly chat endpoints to list historical messages and send the generated AI response.
- Chatbot systems should retain a human-in-the-loop workflow so your team can review drafts or pause automated sending.

To build an AI chatbot for Fansly, you need an event-driven infrastructure that receives incoming messages via webhooks, processes them through your chosen Large Language Model (LLM), and sends the response back via API endpoints. [OnlyFansAPI](https://fansapi.com) provides the REST endpoints, webhook events, and dedicated proxies (Basic and up) needed to connect an LLM and to keep every account protected.

**Key Takeaways**

- A reliable Fansly chatbot relies on the `fansly.messages.received` webhook to trigger responses rather than polling the inbox.
- Your LLM sits on your own servers or in an AI client connected to our Model Context Protocol (MCP) server, separate from the API infrastructure.
- The core chat loop uses Fansly chat endpoints to list historical messages and send the generated AI response.
- Chatbot systems should retain a human-in-the-loop workflow so your team can review drafts or pause automated sending.

## Building an AI Chatbot for Fansly: What Infrastructure to Use?

The recommended infrastructure to build an AI chatbot for Fansly consists of HTTPS webhooks to listen for incoming messages, a background queue to hold requests, an LLM to generate replies, and REST API endpoints to send the message back to the platform.

Your backend server acts as the bridge between the Fansly platform and your AI service. OnlyFansAPI handles the connection and routing to keep every account protected, with 99.98% uptime and zero bans in 5+ years. The same loop on OnlyFans is covered in our tutorial on how to [build an OnlyFans AI chatbot](/blog/build-onlyfans-ai-chatbot).

The flow works like this:

1. A fan sends a message.
2. OnlyFansAPI sends a webhook to your HTTPS endpoint.
3. Your server returns a 200 OK immediately and queues the payload for processing.
4. Your background job queries the LLM with the fan's message and recent chat history.
5. You call the API to send the generated reply back to the chat.

## Fansly Webhook Events for Chatbots

Polling endpoints for new messages wastes rate limits and increases latency. A production-ready AI chatbot relies on webhooks.

### Triggering AI replies with fansly.messages.received

The `fansly.messages.received` webhook fires in near real-time when a message arrives from a fan. Your infrastructure receives a JSON payload containing the message content, sender ID, and chat group ID.

To prevent sending multiple replies before a fan finishes typing, instruct your background queue to wait until the fan has been quiet for a few seconds after the last message before calling the LLM.

### Following up on purchases with fansly.media.purchased

When a fan buys paid media, you can use the `fansly.media.purchased` webhook event to trigger a natural follow-up. This event tells you exactly what was bought and for how much.

Pass this context to your LLM so the AI can generate a thank-you message without attempting to resell the same content.

## Fansly Chat Endpoints for AI Replying

Your application needs to interact with the inbox to gather context and send the output. The primary Fansly chat endpoints are List Chats, List Chat Messages, and Send Chat Message.

List Chats retrieves the active conversations:

```http
GET https://app.fansapi.com/api/fansly/{fanslyAccount}/chats
```

List Chat Messages fetches the historical context for your LLM:

```http
GET https://app.fansapi.com/api/fansly/{fanslyAccount}/chats/{chat_id}/messages
```

Send Chat Message pushes the AI's reply to the fan:

```http
POST https://app.fansapi.com/api/fansly/{fanslyAccount}/chats/{chat_id}/messages
```

Call List Chat Messages only when your LLM requires historical context, not to check for new messages.

All Fansly API calls require the `Authorization: Bearer YOUR_API_KEY` header, and account-scoped calls take an account ID formatted as `fansly_acct_...`.

## Where the LLM Sits

The OnlyFansAPI platform provides the infrastructure to send and receive data, while the LLM sits entirely within your control. You choose whether to host an open-source model locally or call an external service like OpenAI or Anthropic.

For agencies that want to deploy Custom GPTs or Claude agents without building custom backends, OnlyFansAPI offers an [OnlyFans MCP server](https://fansapi.com/mcp). The server exposes 350+ tools, including 80+ Fansly tools, allowing clients like Claude, ChatGPT, and Manus to call the API directly based on natural language prompts. If you are building a custom integration, your LLM code interacts with the API from your own server environment. You can read the [OnlyFans MCP documentation](https://docs.fansapi.com/onlyfans-ai/mcp) to see how it works.

### Keeping a human in the loop

Autonomous chatbots carry operational risks. A secure architecture keeps a human in the loop, especially when handling paid content or sensitive account interactions.

Instead of sending AI-generated text immediately, you can architect your application to save responses as drafts. Your chatters review the queued drafts, edit them to match the creator's voice, and manually dispatch them. For automated routines, you should include a manual off-switch per chat so a human operator can take over the conversation when a fan asks complex questions.

## Rate Limits and Pricing Infrastructure

When building chatbots that constantly process messages, you must account for rate limits. REST API limits follow your plan: 60 RPM on Free, 1,000 RPM on Basic and 5,000 RPM on Pro, shared by every key on your team. The MCP server allows 120 requests per minute per API key.

If your chatbot exceeds its limit, the request returns a 429 status code. On the MCP server, you can split work across multiple API keys.

OnlyFansAPI pricing scales based on the number of accounts. The Basic plan is $69/mo for 1 account and includes 1,000 RPM and 20,000 credits/mo. Webhooks start on Basic; the Free plan has none. The Pro plan is $299/mo for 5 accounts and includes 5,000 RPM and 100,000 credits/mo, with extra accounts costing $29 and scaling down to $11.60. Plans cover both OnlyFans and Fansly connections, meaning you do not pay extra for connecting a [Fansly API](https://fansly-api.com) account.