# Send OnlyFans Notifications to Telegram with Webhooks

> Learn how to send OnlyFans notifications to Telegram using webhooks. See how to route near real-time events to your chat team so they reply faster.

**TL;DR**

- An OnlyFans webhook integration for Telegram requires a translation layer to receive POST requests and forward them to the Telegram Bot API.
- Faster replies close more sales: one slow reply can cost a $200 PPV sale, so Telegram alerts put inbound fan messages in front of on-duty chatters.
- Agencies can route webhooks through an n8n Webhook node or lightweight code microservices in Node.js or Python.
- Outbound webhooks originate from a dynamic edge network, requiring HMAC SHA-256 signature verification via the `Signature` header instead of IP allowlisting.
- Webhook delivery is included on OnlyFansAPI Basic plans ($69/month) and above.

Sending OnlyFans notifications to a Telegram chat requires routing outbound webhook payloads through an automation tool like n8n or a custom backend script. [OnlyFansAPI](https://fansapi.com) emits near real-time events for new messages, tips, and subscriptions, allowing developers to forward these JSON payloads directly to the Telegram Bot API.

**Key Takeaways**

- An OnlyFans webhook integration for Telegram requires a translation layer to receive POST requests and forward them to the Telegram Bot API.
- Faster replies close more sales: one slow reply can cost a $200 PPV sale, so Telegram alerts put inbound fan messages in front of on-duty chatters.
- Agencies can route webhooks through an n8n Webhook node or lightweight code microservices in Node.js or Python.
- Outbound webhooks originate from a dynamic edge network, requiring HMAC SHA-256 signature verification via the `Signature` header instead of IP allowlisting.
- Webhook delivery is included on OnlyFansAPI Basic plans ($69/month) and above.

## OnlyFans Webhook Integration for Telegram

Setting up an OnlyFans webhook integration for Telegram involves connecting your developer infrastructure to the Telegram Bot API via a webhook consumer. This translation layer receives near real-time webhook payloads (Basic plan and up) from OnlyFansAPI, extracts the relevant fan data, formats it into HTML or MarkdownV2, and posts it directly to a specified Telegram chat ID. By bridging these platforms, creator agencies and chat teams can monitor inbound revenue and high-value interactions without relying on manual dashboard checks or polling. If your team only wants to ask about earnings and fans from Telegram without code, [FansBot](https://fansapi.com/fansbot) is our ready-made assistant for Telegram, Slack and Discord; it answers questions rather than forwarding webhook events.

## Core Notification Events

Webhook support on OnlyFansAPI starts at the Basic tier ($69/month, see [OnlyFansAPI pricing](https://fansapi.com/pricing)). For a complete catalog of all webhook events and configuration schemas, refer to the [OnlyFans Webhooks Guide](/blog/onlyfans-webhooks-guide). The most common events used for Telegram operational notifications include the following.

| Event Name | Key Payload Fields | Telegram Notification Goal |
| --- | --- | --- |
| `subscriptions.new` | `user.username`, `replacePairs.{PRICE}` | Alert the creator or chatter to start the onboarding sequence. |
| `tips.received` | `amountGross`, `user.username`, `text` | Provide visibility on high-value transactions for custom media rewards. |
| `messages.received` | `text`, `fromUser.username`, `fromUser.id` | Route customer inquiries directly to on-duty chat operators to minimize inbox latency. |

## Setting Up the Telegram Bot API

Before deploying the webhook listener, you must configure a Telegram bot and obtain the target chat identifiers.

1. Open Telegram and send the `/newbot` command to `@BotFather`.
2. Choose a display name and a unique username ending in `bot`.
3. Save the generated HTTP API Bot Token.
4. Open a direct chat with your new bot and click **Start**, or add the bot as an administrator to your agency group channel.
5. Send a test message in the chat, then call the Telegram Bot API `getUpdates` method with your bot token to locate your destination `chat.id`.

## Implementation Pathway 1: No-Code Automation via n8n

For teams prioritizing visual workflow automation, [n8n](https://docs.fansapi.com/integrations/n8n) offers a flexible engine for receiving webhooks (Basic plan and up). Our [n8n integration](https://fansapi.com/no-code) is our own package and supports every endpoint in our API.

1. Add a **Webhook** node in n8n, set the HTTP Method to `POST`, and define a path like `onlyfans-events`.
2. Add a **Switch** node to route incoming payloads based on `json.body.event`.
3. Add a **Code** node to format the JSON payload into an actionable Telegram message.

```javascript
const event = $json.body.event;
const payload = $json.body.payload;
const accountId = $json.body.account_id;

let messageText = '';

if (event === 'subscriptions.new') {
  const user = payload.user || {};
  const price = payload.replacePairs?.['{PRICE}'] || 'Paid';
  messageText = `🎉 <b>New Subscription Alert!</b>\n\n` +
                `👤 <b>Fan:</b> ${user.name || 'Anonymous'} (@${user.username || 'unknown'})\n` +
                `💵 <b>Price:</b> ${price}\n` +
                `🆔 <b>Account:</b> <code>${accountId}</code>\n` +
                `🔗 <a href="https://onlyfans.com/${user.username}">Open Fan Profile</a>`;
}

return [{ json: { text: messageText, chat_id: "-1001234567890" } }];
```

4. Connect the **Telegram** node, set the operation to Send Text Message, and map your text and chat ID variables with Parse Mode set to HTML.

## Implementation Pathway 2: Lightweight Code Microservice

Engineering teams often prefer serverless microservices or containerized scripts. The following examples demonstrate how to receive webhooks (Basic plan and up), verify the signature, and dispatch the alert.

### Node.js with Express

```javascript
const express = require('express');
const crypto = require('crypto');

const app = express();

app.use(express.json({
  verify: (req, res, buf) => {
    req.rawBody = buf.toString('utf8');
  }
}));

const TELEGRAM_BOT_TOKEN = process.env.TELEGRAM_BOT_TOKEN;
const TELEGRAM_CHAT_ID = process.env.TELEGRAM_CHAT_ID;
const OF_SIGNING_SECRET = process.env.OF_SIGNING_SECRET;

async function sendTelegramMessage(text) {
  const url = `https://api.telegram.org/bot${TELEGRAM_BOT_TOKEN}/sendMessage`;
  const response = await fetch(url, {
    method: 'POST',
    headers: { 'Content-Type': 'application/json' },
    body: JSON.stringify({
      chat_id: TELEGRAM_CHAT_ID,
      text: text,
      parse_mode: 'HTML',
      disable_web_page_preview: true
    })
  });
  return response.json();
}

app.post('/webhook/onlyfans', async (req, res) => {
  const signature = req.headers['signature'];

  if (OF_SIGNING_SECRET) {
    const computedSignature = crypto
      .createHmac('sha256', OF_SIGNING_SECRET)
      .update(req.rawBody)
      .digest('hex');

    if (!signature || signature.length !== computedSignature.length ||
        !crypto.timingSafeEqual(Buffer.from(computedSignature), Buffer.from(signature))) {
      return res.status(401).send('Invalid signature');
    }
  }

  res.status(200).json({ received: true });

  const { event, account_id, payload } = req.body;

  if (event === 'messages.received') {
    const fromUser = payload.fromUser || {};
    const cleanText = payload.text ? payload.text.replace(/<[^>]*>?/gm, '') : '[Attachment]';
    const message = `📥 <b>New Inbound DM</b>\n\n` +
              `👤 <b>From:</b> ${fromUser.name} (@${fromUser.username})\n` +
              `💬 <b>Message:</b> ${cleanText}\n` +
              `⚡ <a href="https://onlyfans.com/my/chats/chat/${fromUser.id}">Open Chat</a>`;

    await sendTelegramMessage(message);
  }
});

app.listen(3000, () => console.log(`Listener active`));
```

### Python with FastAPI

```python
import hmac
import hashlib
import os
import re
from fastapi import BackgroundTasks, FastAPI, Request, Header, HTTPException, status
import httpx

app = FastAPI()

TELEGRAM_BOT_TOKEN = os.getenv("TELEGRAM_BOT_TOKEN")
TELEGRAM_CHAT_ID = os.getenv("TELEGRAM_CHAT_ID")
OF_SIGNING_SECRET = os.getenv("OF_SIGNING_SECRET")

async def send_telegram_alert(text: str):
    telegram_url = f"https://api.telegram.org/bot{TELEGRAM_BOT_TOKEN}/sendMessage"
    payload = {
        "chat_id": TELEGRAM_CHAT_ID,
        "text": text,
        "parse_mode": "HTML",
        "disable_web_page_preview": True
    }
    async with httpx.AsyncClient() as client:
        await client.post(telegram_url, json=payload)

@app.post("/webhook/onlyfans")
async def handle_onlyfans_webhook(
    request: Request,
    background_tasks: BackgroundTasks,
    signature: str | None = Header(default=None)
):
    raw_body = await request.body()

    if OF_SIGNING_SECRET:
        computed_signature = hmac.new(
            OF_SIGNING_SECRET.encode(),
            raw_body,
            hashlib.sha256
        ).hexdigest()
        if not signature or not hmac.compare_digest(computed_signature, signature):
            raise HTTPException(
                status_code=status.HTTP_401_UNAUTHORIZED,
                detail="Invalid signature"
            )

    body = await request.json()
    event_type = body.get("event")
    payload = body.get("payload", {})

    if event_type == "tips.received":
        user = payload.get("user", {})
        amount = payload.get("amountGross", 0)
        message_text = (
            f"💰 <b>Tip Received: ${amount:.2f}</b>\n\n"
            f"👤 <b>From:</b> {user.get('name')} (@{user.get('username')})\n"
            f"💬 <b>Details:</b> {payload.get('text', 'No note')}"
        )
        background_tasks.add_task(send_telegram_alert, message_text)

    return {"status": "ok"}
```

## Registering the Webhook Endpoint

Once your listener endpoint is deployed, you must register it inside the [OnlyFans API Console](https://app.fansapi.com) to begin receiving near real-time payloads (Basic plan and up).

1. Navigate to the Webhooks section and click **+ Add Webhook**.
2. Input your public Endpoint URL.
3. Enter a long, random string in the Signing Secret field so you can verify the payloads (recommended).
4. Select the specific events you want to subscribe to and save the configuration.

## Security and Delivery Architecture

For stable infrastructure, adhere to the [OnlyFansAPI Webhook Documentation rules for protecting your webhooks](https://docs.fansapi.com/webhooks/protecting-your-webhooks).

As the [webhook delivery and retries docs](https://docs.fansapi.com/webhooks/delivery-and-retries) explain, outbound webhook requests are routed across our edge network. Because source IP addresses originate dynamically, they cannot be allowlisted. You must verify payloads using HMAC SHA-256 signature verification via the `Signature` header.

Additionally, outbound calls supply an `X-OFAPI-Idempotency-Key` header. Store each key and ignore events you have already processed to deduplicate Telegram notifications in the event of retry delivery. Finally, return a 2xx status within 10 seconds: a slow or failed response counts as a failed attempt and is retried, and 20 consecutive failed deliveries pause the endpoint.