
Incoming message triggers webhook instantly

AI chatbot or rule engine processes message

Show typing for natural conversation feel

Send response via API — text, media, or PPV
// Webhook handler: messages.received
app.post('/webhooks/onlyfans', async (req, res) => {
const { event, account_id, payload } = req.body;
if (event === 'messages.received') {
// payload.fromUser = sender profile with subscription info
// payload.text = message content (HTML)
// payload.fanData.spending = fan's lifetime spend
const { fromUser, text, fanData } = payload;
// Skip if message is from the creator (outgoing)
if (fromUser.isPerformer) return res.sendStatus(200);
// Generate AI response (your chatbot logic)
const aiReply = await yourAIChatbot.generateReply({
message: text,
fanName: fromUser.name,
fanSpend: fanData.spending.total,
});
// Show typing indicator for natural feel
await fetch(
'https://app.onlyfansapi.com/api/' + account_id + '/chats/' + fromUser.id + '/typing',
{
method: 'POST',
headers: {
'Authorization': 'Bearer sk_your_api_key',
'Content-Type': 'application/json'
}
}
);
// Wait 2-4 seconds to simulate typing
await new Promise(r => setTimeout(r, 2000 + Math.random() * 2000));
// Send the reply
await fetch(
'https://app.onlyfansapi.com/api/' + account_id + '/chats/' + fromUser.id + '/messages',
{
method: 'POST',
headers: {
'Authorization': 'Bearer sk_your_api_key',
'Content-Type': 'application/json'
},
body: JSON.stringify({ text: aiReply })
}
);
}
res.sendStatus(200);
});
