Skip to main content
Fans expect fast replies, but a creator cannot sit in the inbox all day. In this tutorial you build a chatbot that does the first pass for them: it finds every conversation with unread messages, reads the recent history, drafts a reply, and sends it. You can run it once or on a schedule (a cron job, a worker, a serverless function) to keep conversations warm around the clock. By the end you will have a single script that calls three Fanvue endpoints in sequence and posts a real reply to every unread chat.
This tutorial assumes you already have an access token. If you do not, the First Call guide walks you from zero to one authenticated request in about five minutes.

What you’ll build

A command-line chatbot that, on each run:

Finds unread chats

Lists every conversation that has unread messages, along with the fan’s userUuid you need to reply.

Reads the conversation

Pulls the most recent messages so the reply has context, and checks the last message actually came from the fan.

Drafts a reply

Turns the conversation into a short, on-brand reply. Start with a template, then swap in an LLM when you are ready.

Sends the reply

Posts the drafted text back into the chat and confirms with the returned messageUuid.

How it works

Three endpoints do the work. Everything is served from https://api.fanvue.com, authenticated with a Bearer token, and every request must carry the X-Fanvue-API-Version header.
There is also a GET /chats/unread endpoint, but it returns only counts (how many unread chats and messages you have), not the chats themselves. To get the list with each fan’s userUuid, use GET /chats with filter=unread, as shown below.

Prerequisites

1

An access token

A Bearer access token for the creator’s account. Get one with the First Call guide if you do not have it yet. Access tokens are short-lived (typically one hour), so refresh yours if it has expired.
2

The right scopes

The token must be granted these OAuth scopes:
3

A runtime

Python 3.9+ (the example uses the requests library) or Node.js 18+ (which has fetch built in). Pick one tab below.
Store the token in an environment variable rather than hard-coding it. The examples read it from FANVUE_TOKEN.

Step 1: Set up the API client

Every call shares the same base URL, Bearer token, and version header, so wrap them once. The client below exposes one helper per endpoint we need.
Install the one dependency, then create fanvue.py:
fanvue.py

Step 2: Find the unread chats

GET /chats?filter=unread returns a paginated list. Each item describes one conversation: the fan (user, including the user.uuid you reply to), how many messages are unread (unreadMessagesCount), and a preview of the lastMessage. A trimmed response looks like this:
The user.uuid field is the userUuid path parameter for the next two endpoints. Keep it.

Step 3: Read the conversation and draft a reply

For each unread chat, call GET /chats/{userUuid}/messages to pull recent history. Messages come back newest first, and every message carries a sender.uuid. Compare that against your own uuid from GET /users/me to confirm the latest message is from the fan and not a reply you already sent. A trimmed messages response:
Now turn that history into a reply. The function below starts with a simple template so the script runs end to end today. When you are ready, replace its body with a call to your LLM of choice: pass the recent messages as context and ask for a short, on-brand reply.
draft.py

Step 4: Send the reply

POST /chats/{userUuid}/message posts your drafted text. The body needs a single text field (1 to 5000 characters). On success the API returns 201 with the new message’s UUID:
A send can fail with a 400 and a contactability error if the fan cannot currently be messaged (for example, they are not subscribed or have blocked messages). Catch that case per chat so one un-messageable fan does not stop the whole run.
The request body also accepts optional mediaUuids, a price (in cents, minimum 300) to make the message pay-to-view, and a templateUuid. This tutorial sends plain text only.

Step 5: Put it together

Now wire the four calls into one loop: identify yourself, fetch unread chats, and for each one read the history, draft a reply, and send it. Set FANVUE_TOKEN in your environment first.
bot.py
Run it:

Expected result

With three unread chats, a run prints something like:
Each sent ... line is a real message now visible in the creator’s chat with that fan. Open the Fanvue inbox to confirm the replies landed. Run the script again and the chats you just answered no longer appear in the unread list, because your reply marked the conversation as read.
To turn this into a true co-pilot, schedule bot.py to run every few minutes with cron, a serverless timer, or a background worker. Pair it with the LLM draft from Step 3 so each reply is written in the creator’s own voice, and add a review step if you want a human to approve drafts before they send.

A note on what the spec does not cover

The Fanvue API gives you the conversation and lets you send a reply, but it does not write the reply for you. The quality of the draft is entirely up to the code in draft_reply. The TODO in Step 3 is where you plug in your own logic or an LLM. Everything else on this page (the endpoints, fields, and request shapes) is defined by the API and works as shown.

Next steps

Fanvue MCP Server

Prefer not to write code? Connect Fanvue to Claude, ChatGPT, or Cursor and ask your assistant to read and reply to chats in plain language.

API Reference

Browse the full chat surface: mass messages, templates, media attachments, custom lists, and more.