Download the PHP package telegram-bot-essentials/campaigns without Composer

On this page you can find all versions of the php package telegram-bot-essentials/campaigns. It is possible to download/install these versions without Composer. Possible dependencies are resolved automatically.

FAQ

After the download, you have to make one include require_once('vendor/autoload.php');. After that you have to import the classes with use statements.

Example:
If you use only one package a project is not needed. But if you use more then one package, without a project it is not possible to import the classes with use statements.

In general, it is recommended to use always a project to download your libraries. In an application normally there is more than one library needed.
Some PHP packages are not free to download and because of that hosted in private repositories. In this case some credentials are needed to access such packages. Please use the auth.json textarea to insert credentials, if a package is coming from a private repository. You can look here for more information.

  • Some hosting areas are not accessible by a terminal or SSH. Then it is not possible to use Composer.
  • To use Composer is sometimes complicated. Especially for beginners.
  • Composer needs much resources. Sometimes they are not available on a simple webspace.
  • If you are using private repositories you don't need to share your credentials. You can set up everything on our site and then you provide a simple download link to your team member.
  • Simplify your Composer build process. Use our own command line tool to download the vendor folder as binary. This makes your build process faster and you don't need to expose your credentials for private repositories.
Please rate this library. Is it a good library?

Informations about the package campaigns

Telegram Bot Essentials — Campaigns

Tracked marketing links for the telegram-bot-essentials/essence ecosystem. An admin creates a named campaign from the bot's admin menu and gets a t.me link and a QR code. Brand-new users who arrive through it are attributed to the campaign, and the campaign screen shows who joined, who was turned away and, with billing installed, what they paid.

Status: 0.0.x. The prize contract may still change between 0.0.x releases.

Installation

There is nothing to switch on: installing the package enables it.

Add the admin key

A companion's ReplyKeys are not auto-discovered, so list the campaigns key in your app's config/tbe-essence.php:

The admin menu

📣 Campaigns opens a paginated list. From there an admin can:

How it works

Prizes

An admin can attach prizes to a campaign: a reward every new user who joins through it receives. Campaigns owns everything generic; a prize type owns what is specific to one kind of reward.

Campaigns does The prize type does
Stores which prizes a campaign has, with a cap each Names itself (key, label)
Shows the admin screens (add, enable, cap, retry) Provides the config form an admin fills in
Reserves a prize per new user, once, atomically Says how it reads to a human (describe)
Sends the claim message and handles the tap Hands the prize over (grant)
Keeps the ledger: status, error, invoice, attempts Says what the prize is and describes it

In the admin menu, a campaign has a 🎁 Prizes screen. Add a prize lists every registered type, hands over to that type's own form, and attaches the result. Each prize has an optional limit (0 = unlimited), can be disabled, and has a retry button when hand-overs failed.

Shipped type

💰 Wallet credit is registered automatically when user-wallet is installed. It is handed over the moment the user joins.

Registering your own type

Implement TelegramBotEssentials\Campaigns\Contracts\PrizeType and register it from your service provider's boot():

The config form extends PrizeConfigForm: name the type and turn the answers into the prize's config; campaigns attaches it and returns the admin to the prize list.

grant(BotUser $user, array $config, CampaignPrizeGrant $grant) runs for that user. Throw to fail: the ledger records the message and an admin can retry, which calls grant() again for the same grant, so it must be safe to run twice. Keep the ids of anything already created in $grant->meta.

Prizes that are an order

For a reward that is an order of another package (a service, a plan), build the order and call PrizeSettlement::pay($order, $grant). It creates the invoice and settles it with a PrizePaymentAttempt (a payment method that moves no money and is never offered on any invoice), so the order's own paid hook runs exactly as for a paying customer. On a retry, reuse $grant->order instead of creating another order: pay() then re-runs only the paid hook, never a second invoice or attempt.

Claiming

Every prize is reserved as pending, wallet credit included, so the user sees something waiting for them and taps to receive it. Each prize gets its own message with its own claim button, and nothing costly is created for someone who never uses it. Tapping the button runs grant(), then the message is rewritten to say the prize was received (or that it failed) and loses its button. A double tap hands the prize over once, and a forwarded button does nothing for anyone but its owner. An admin retry of a failed grant does not re-message the user.

Claim methods

How the user earns the button's outcome is a second registry, separate from the prize type: the type says what they get, the claim method says how they get it. An admin picks it per prize from the prize screen (🎯 Received by). A prize starts as a plain tap.

Method What the user does
click Taps the button.
dice Taps Play, then sends the bot a 🎲. They win if it lands on a number the admin picked (1-6, comma separated), and get the admin's number of tries.

Register another with claimMethods()->register(new MyMethod) from a provider's boot(). Implement Contracts\ClaimMethod: key, label, describe, an optional configForm() (extend Telegram\Forms\ClaimMethodConfigForm, started with ['prize' => id, 'lastPage' => n]), buttonLabel and start($grant), which runs when the user taps. When the user has done what the method asks, call PrizeGranting::claim($grant) to hand the prize over, or forfeit($grant) to end it as lost. Then PrizeMessages::settle() rewrites the message.

Consequences

Read these before turning prizes on.

Stats

Each campaign screen shows the users it brought in and the users it turned away, by reason, and paying users and revenue, worked out live from paid invoices of the campaign's users. Nothing is stored: a revoked invoice stops being paid and drops out. Invoices settled as a prize and wallet top-ups (when user-wallet is installed) are left out, since neither is a sale.

With user-management

When user-management is installed, the admin user screen shows which campaign a user joined through, and the user list gains a From a campaign filter.

Development

Built from the skeleton template. composer test && composer lint && composer analyse.

License

MIT.


All versions of campaigns with dependencies

PHP Build Version
Package Version
Requires php Version ^8.3
ext-gd Version *
chillerlan/php-qrcode Version ^5.0 || ^6.0
laravel/framework Version ^12 || ^13
telegram-bot-essentials/billing Version ~0.0.49
telegram-bot-essentials/essence Version ^0.19.0-beta.9@beta
Composer command for our command line client (download client) This client runs in each environment. You don't need a specific PHP version etc. The first 20 API calls are free. Standard composer command

The package telegram-bot-essentials/campaigns contains the following files

Loading the files please wait ...