Referral tracking and wallet commission payouts for telegram-bot-essentials/essence

Maintainers

Package info

github.com/Telegram-Bot-Essentials/affiliates

pkg:composer/telegram-bot-essentials/affiliates

Transparency log

Statistics

Installs: 1

Dependents: 0

Suggesters: 0

Stars: 0

Open Issues: 0

v0.0.16 2026-09-01 12:27 UTC

This package is auto-updated.

Last update: 2026-09-02 12:18:28 UTC


README

Latest Version tests License: MIT

A referral program for the telegram-bot-essentials/essence ecosystem. Every user gets a shareable deep link; signups through it are tracked; both the referrer and (optionally) the new user can be paid a signup bonus; and referrers earn an ongoing commission on their referred users' purchases. Bonuses and commissions are paid straight into user-wallet.

Depends on essence's deep-link handling, settings, billing events, and user-wallet.

Installation

composer require telegram-bot-essentials/affiliates
php artisan migrate

Everything is configured per-bot through Settings:

Setting Type Default
affiliates.affiliates_status CHECKBOX false
affiliates.allow_existing_users CHECKBOX false
affiliates.share_percentage NUMBER 10
affiliates.referrer_signup_bonus NUMBER 0
affiliates.referred_signup_bonus NUMBER 0
affiliates.share_tagline TEXT

How it works

  • Each user's affiliate menu builds https://t.me/{bot}?start={referral_code}.
  • A new user opening that link fires essence's BotDeepLinkReceived; the package creates a Referral and pays the signup bonuses.
  • Attribution is first-touch-wins (a unique(bot_id, bot_user_id) constraint) and, by default, new users only. Self-referral is rejected.
  • Every paid Billing invoice from a referred user credits the referrer a percentage (rounded down, wallet top-ups excluded). A later invoice revocation claws it back.

Commission listeners are queued (queue: billing) and restore the webhook context first, since invoice events can fire from a gateway callback with no "current user".

Documentation

Full documentation — the attribution rules, commission math, data model, and member UI — lives on the Telegram Bot Essentials documentation site under Modules → Affiliates.

License

MIT.